mirror of
https://code.forgejo.org/actions/git-backporting.git
synced 2025-05-18 19:49:13 -04:00
feat(issue-62): make cherry-pick strategy configurable (#63)
fix https://github.com/kiegroup/git-backporting/issues/62
This commit is contained in:
parent
ead1322c0f
commit
265955dda7
18 changed files with 312 additions and 58 deletions
|
@ -77,6 +77,8 @@ describe("cli 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("with config file [default, short]", () => {
|
||||
|
@ -103,6 +105,8 @@ describe("cli 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 [default, long]", () => {
|
||||
|
@ -131,6 +135,8 @@ describe("cli 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("with config file [default, long]", () => {
|
||||
|
@ -157,6 +163,8 @@ describe("cli 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, short]", () => {
|
||||
|
@ -192,6 +200,8 @@ describe("cli 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, long]", () => {
|
||||
|
@ -243,6 +253,8 @@ describe("cli 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("override using config file", () => {
|
||||
|
@ -269,6 +281,8 @@ describe("cli 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("ignore custom option when config file is set", () => {
|
||||
|
@ -322,6 +336,8 @@ describe("cli 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", () => {
|
||||
|
@ -352,4 +368,38 @@ describe("cli args parser", () => {
|
|||
expect(args.inheritLabels).toEqual(false);
|
||||
expect(args.squash).toEqual(false);
|
||||
});
|
||||
|
||||
test("override cherry pick strategies", () => {
|
||||
addProcessArgs([
|
||||
"--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.bodyPrefix).toEqual(undefined);
|
||||
expect(args.bpBranchName).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");
|
||||
});
|
||||
});
|
|
@ -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");
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue