feat(issue-54): backport pr commits without squash

Fix https://github.com/kiegroup/git-backporting/issues/54
This commit is contained in:
Andrea Lamparelli 2023-07-10 16:57:38 +02:00
parent a737aa7c4c
commit a2f3ff013c
29 changed files with 1004 additions and 161 deletions

View file

@ -48,10 +48,6 @@ describe("gha args parser", () => {
parser = new GHAArgsParser();
});
afterEach(() => {
jest.clearAllMocks();
});
test("valid execution [default]", () => {
spyGetInput({
"target-branch": "target",
@ -73,6 +69,7 @@ describe("gha args parser", () => {
expect(args.inheritReviewers).toEqual(true);
expect(args.labels).toEqual([]);
expect(args.inheritLabels).toEqual(false);
expect(args.squash).toEqual(true);
});
test("valid execution [override]", () => {
@ -111,6 +108,7 @@ describe("gha args parser", () => {
expect(args.inheritReviewers).toEqual(false);
expectArrayEqual(args.labels!, ["cherry-pick :cherries:", "another spaced label"]);
expect(args.inheritLabels).toEqual(true);
expect(args.squash).toEqual(true);
});
test("using config file", () => {
@ -135,6 +133,7 @@ describe("gha args parser", () => {
expect(args.inheritReviewers).toEqual(true);
expectArrayEqual(args.labels!, []);
expect(args.inheritLabels).toEqual(false);
expect(args.squash).toEqual(true);
});
test("ignore custom options when using config file", () => {
@ -174,5 +173,31 @@ describe("gha args parser", () => {
expect(args.inheritReviewers).toEqual(true);
expectArrayEqual(args.labels!, ["cherry-pick :cherries:"]);
expect(args.inheritLabels).toEqual(true);
expect(args.squash).toEqual(true);
});
test("override squash to false", () => {
spyGetInput({
"target-branch": "target",
"pull-request": "https://localhost/whatever/pulls/1",
"no-squash": "true",
});
const args: Args = parser.parse();
expect(args.dryRun).toEqual(false);
expect(args.auth).toEqual(undefined);
expect(args.gitUser).toEqual(undefined);
expect(args.gitEmail).toEqual(undefined);
expect(args.folder).toEqual(undefined);
expect(args.targetBranch).toEqual("target");
expect(args.pullRequest).toEqual("https://localhost/whatever/pulls/1");
expect(args.title).toEqual(undefined);
expect(args.body).toEqual(undefined);
expect(args.reviewers).toEqual([]);
expect(args.assignees).toEqual([]);
expect(args.inheritReviewers).toEqual(true);
expect(args.labels).toEqual([]);
expect(args.inheritLabels).toEqual(false);
expect(args.squash).toEqual(false);
});
});