feat: override backporting pr fields (#38)

* feat: override local git user config

* feat(issue-32): override reviewers and assignees
This commit is contained in:
Andrea Lamparelli 2023-06-22 17:44:14 +02:00 committed by GitHub
parent 22bec0c537
commit a32e8cd34c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 671 additions and 107 deletions

View file

@ -87,7 +87,8 @@ describe("gha runner", () => {
base: "target",
title: "[target] PR Title",
body: expect.stringContaining("**Backport:** https://github.com/owner/reponame/pull/2368"),
reviewers: ["gh-user", "that-s-a-user"]
reviewers: ["gh-user", "that-s-a-user"],
assignees: [],
}
);
});
@ -134,7 +135,8 @@ describe("gha runner", () => {
base: "target",
title: "[target] PR Title",
body: expect.stringContaining("**Backport:** https://github.com/owner/reponame/pull/4444"),
reviewers: ["gh-user", "that-s-a-user"]
reviewers: ["gh-user", "that-s-a-user"],
assignees: [],
}
);
});
@ -147,6 +149,8 @@ describe("gha runner", () => {
"body": "New Body",
"body-prefix": "New Body Prefix - ",
"bp-branch-name": "bp_branch_name",
"reviewers": "user1, user2",
"assignees": "user3, user4",
});
await runner.execute();
@ -176,7 +180,54 @@ describe("gha runner", () => {
base: "target",
title: "New Title",
body: "New Body Prefix - New Body",
reviewers: ["gh-user", "that-s-a-user"]
reviewers: ["user1", "user2"],
assignees: ["user3", "user4"],
}
);
});
test("set empty reviewers", async () => {
spyGetInput({
"target-branch": "target",
"pull-request": "https://github.com/owner/reponame/pull/2368",
"title": "New Title",
"body": "New Body",
"body-prefix": "New Body Prefix - ",
"bp-branch-name": "bp_branch_name",
"reviewers": "",
"assignees": "user3, user4",
"no-inherit-reviewers": "true",
});
await runner.execute();
const cwd = process.cwd() + "/bp";
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp_branch_name");
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc");
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
expect(GitHubService.prototype.createPullRequest).toBeCalledTimes(1);
expect(GitHubService.prototype.createPullRequest).toBeCalledWith({
owner: "owner",
repo: "reponame",
head: "bp_branch_name",
base: "target",
title: "New Title",
body: "New Body Prefix - New Body",
reviewers: [],
assignees: ["user3", "user4"],
}
);
});