feat(issue-62): make cherry-pick strategy configurable (#63)

fix https://github.com/kiegroup/git-backporting/issues/62
This commit is contained in:
Andrea Lamparelli 2023-07-12 13:50:59 +02:00 committed by GitHub
parent ead1322c0f
commit 265955dda7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 312 additions and 58 deletions

View file

@ -70,6 +70,8 @@ describe("gha args parser", () => {
expect(args.labels).toEqual([]);
expect(args.inheritLabels).toEqual(false);
expect(args.squash).toEqual(true);
expect(args.strategy).toEqual(undefined);
expect(args.strategyOption).toEqual(undefined);
});
test("valid execution [override]", () => {
@ -109,6 +111,8 @@ describe("gha args parser", () => {
expectArrayEqual(args.labels!, ["cherry-pick :cherries:", "another spaced label"]);
expect(args.inheritLabels).toEqual(true);
expect(args.squash).toEqual(true);
expect(args.strategy).toEqual(undefined);
expect(args.strategyOption).toEqual(undefined);
});
test("using config file", () => {
@ -134,6 +138,8 @@ describe("gha args parser", () => {
expectArrayEqual(args.labels!, []);
expect(args.inheritLabels).toEqual(false);
expect(args.squash).toEqual(true);
expect(args.strategy).toEqual(undefined);
expect(args.strategyOption).toEqual(undefined);
});
test("ignore custom options when using config file", () => {
@ -174,6 +180,8 @@ describe("gha args parser", () => {
expectArrayEqual(args.labels!, ["cherry-pick :cherries:"]);
expect(args.inheritLabels).toEqual(true);
expect(args.squash).toEqual(true);
expect(args.strategy).toEqual(undefined);
expect(args.strategyOption).toEqual(undefined);
});
test("override squash to false", () => {
@ -200,4 +208,32 @@ describe("gha args parser", () => {
expect(args.inheritLabels).toEqual(false);
expect(args.squash).toEqual(false);
});
test("override cherry pick strategy", () => {
spyGetInput({
"target-branch": "target",
"pull-request": "https://localhost/whatever/pulls/1",
"strategy": "ort",
"strategy-option": "ours",
});
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(true);
expect(args.strategy).toEqual("ort");
expect(args.strategyOption).toEqual("ours");
});
});