mirror of
https://code.forgejo.org/actions/git-backporting.git
synced 2025-05-13 00:59:12 -04:00
feat: override backporting pr fields (#38)
* feat: override local git user config * feat(issue-32): override reviewers and assignees
This commit is contained in:
parent
22bec0c537
commit
a32e8cd34c
21 changed files with 671 additions and 107 deletions
|
@ -1,6 +1,6 @@
|
|||
import { Args } from "@bp/service/args/args.types";
|
||||
import CLIArgsParser from "@bp/service/args/cli/cli-args-parser";
|
||||
import { addProcessArgs, resetProcessArgs } from "../../../support/utils";
|
||||
import { addProcessArgs, resetProcessArgs, expectArrayEqual } from "../../../support/utils";
|
||||
|
||||
describe("cli args parser", () => {
|
||||
let parser: CLIArgsParser;
|
||||
|
@ -24,7 +24,8 @@ describe("cli args parser", () => {
|
|||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(false);
|
||||
expect(args.auth).toEqual("");
|
||||
expect(args.author).toEqual(undefined);
|
||||
expect(args.gitUser).toEqual("GitHub");
|
||||
expect(args.gitEmail).toEqual("noreply@github.com");
|
||||
expect(args.folder).toEqual(undefined);
|
||||
expect(args.targetBranch).toEqual("target");
|
||||
expect(args.pullRequest).toEqual("https://localhost/whatever/pulls/1");
|
||||
|
@ -32,6 +33,9 @@ describe("cli args parser", () => {
|
|||
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);
|
||||
});
|
||||
|
||||
test("valid execution [default, long]", () => {
|
||||
|
@ -45,7 +49,8 @@ describe("cli args parser", () => {
|
|||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(false);
|
||||
expect(args.auth).toEqual("");
|
||||
expect(args.author).toEqual(undefined);
|
||||
expect(args.gitUser).toEqual("GitHub");
|
||||
expect(args.gitEmail).toEqual("noreply@github.com");
|
||||
expect(args.folder).toEqual(undefined);
|
||||
expect(args.targetBranch).toEqual("target");
|
||||
expect(args.pullRequest).toEqual("https://localhost/whatever/pulls/1");
|
||||
|
@ -53,6 +58,9 @@ describe("cli args parser", () => {
|
|||
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);
|
||||
});
|
||||
|
||||
test("valid execution [override, short]", () => {
|
||||
|
@ -63,13 +71,18 @@ describe("cli args parser", () => {
|
|||
"-tb",
|
||||
"target",
|
||||
"-pr",
|
||||
"https://localhost/whatever/pulls/1"
|
||||
"https://localhost/whatever/pulls/1",
|
||||
"-gu",
|
||||
"Me",
|
||||
"-ge",
|
||||
"me@email.com",
|
||||
]);
|
||||
|
||||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(true);
|
||||
expect(args.auth).toEqual("bearer-token");
|
||||
expect(args.author).toEqual(undefined);
|
||||
expect(args.gitUser).toEqual("Me");
|
||||
expect(args.gitEmail).toEqual("me@email.com");
|
||||
expect(args.folder).toEqual(undefined);
|
||||
expect(args.targetBranch).toEqual("target");
|
||||
expect(args.pullRequest).toEqual("https://localhost/whatever/pulls/1");
|
||||
|
@ -77,6 +90,9 @@ describe("cli args parser", () => {
|
|||
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);
|
||||
});
|
||||
|
||||
test("valid execution [override, long]", () => {
|
||||
|
@ -88,6 +104,10 @@ describe("cli args parser", () => {
|
|||
"target",
|
||||
"--pull-request",
|
||||
"https://localhost/whatever/pulls/1",
|
||||
"--git-user",
|
||||
"Me",
|
||||
"--git-email",
|
||||
"me@email.com",
|
||||
"--title",
|
||||
"New Title",
|
||||
"--body",
|
||||
|
@ -96,12 +116,18 @@ describe("cli args parser", () => {
|
|||
"New Body Prefix",
|
||||
"--bp-branch-name",
|
||||
"bp_branch_name",
|
||||
"--reviewers",
|
||||
"al , john, jack",
|
||||
"--assignees",
|
||||
" pippo,pluto, paperino",
|
||||
"--no-inherit-reviewers",
|
||||
]);
|
||||
|
||||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(true);
|
||||
expect(args.auth).toEqual("bearer-token");
|
||||
expect(args.author).toEqual(undefined);
|
||||
expect(args.gitUser).toEqual("Me");
|
||||
expect(args.gitEmail).toEqual("me@email.com");
|
||||
expect(args.folder).toEqual(undefined);
|
||||
expect(args.targetBranch).toEqual("target");
|
||||
expect(args.pullRequest).toEqual("https://localhost/whatever/pulls/1");
|
||||
|
@ -109,6 +135,9 @@ describe("cli args parser", () => {
|
|||
expect(args.body).toEqual("New Body");
|
||||
expect(args.bodyPrefix).toEqual("New Body Prefix");
|
||||
expect(args.bpBranchName).toEqual("bp_branch_name");
|
||||
expectArrayEqual(["al", "john", "jack"], args.reviewers!);
|
||||
expectArrayEqual(["pippo", "pluto", "paperino"], args.assignees!);
|
||||
expect(args.inheritReviewers).toEqual(false);
|
||||
});
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue