mirror of
https://github.com/kiegroup/git-backporting.git
synced 2025-06-28 21:53:47 +00: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
|
@ -21,11 +21,14 @@ export default class PullRequestConfigsParser extends ConfigsParser {
|
|||
return {
|
||||
dryRun: args.dryRun,
|
||||
auth: args.auth,
|
||||
author: args.author ?? pr.author,
|
||||
folder: `${folder.startsWith("/") ? "" : process.cwd() + "/"}${args.folder ?? this.getDefaultFolder()}`,
|
||||
targetBranch: args.targetBranch,
|
||||
originalPullRequest: pr,
|
||||
backportPullRequest: this.getDefaultBackportPullRequest(pr, args)
|
||||
backportPullRequest: this.getDefaultBackportPullRequest(pr, args),
|
||||
git: {
|
||||
user: args.gitUser,
|
||||
email: args.gitEmail,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -41,20 +44,24 @@ export default class PullRequestConfigsParser extends ConfigsParser {
|
|||
* @returns {GitPullRequest}
|
||||
*/
|
||||
private getDefaultBackportPullRequest(originalPullRequest: GitPullRequest, args: Args): GitPullRequest {
|
||||
const reviewers = [];
|
||||
reviewers.push(originalPullRequest.author);
|
||||
if (originalPullRequest.mergedBy) {
|
||||
reviewers.push(originalPullRequest.mergedBy);
|
||||
const reviewers = args.reviewers ?? [];
|
||||
if (reviewers.length == 0 && args.inheritReviewers) {
|
||||
// inherit only if args.reviewers is empty and args.inheritReviewers set to true
|
||||
reviewers.push(originalPullRequest.author);
|
||||
if (originalPullRequest.mergedBy) {
|
||||
reviewers.push(originalPullRequest.mergedBy);
|
||||
}
|
||||
}
|
||||
|
||||
const bodyPrefix = args.bodyPrefix ?? `**Backport:** ${originalPullRequest.htmlUrl}\r\n\r\n`;
|
||||
const body = args.body ?? `${originalPullRequest.body}\r\n\r\nPowered by [BPer](https://github.com/lampajr/backporting).`;
|
||||
|
||||
return {
|
||||
author: originalPullRequest.author,
|
||||
author: args.gitUser,
|
||||
title: args.title ?? `[${args.targetBranch}] ${originalPullRequest.title}`,
|
||||
body: `${bodyPrefix}${body}`,
|
||||
reviewers: [...new Set(reviewers)],
|
||||
assignees: [...new Set(args.assignees)],
|
||||
targetRepo: originalPullRequest.targetRepo,
|
||||
sourceRepo: originalPullRequest.targetRepo,
|
||||
branchName: args.bpBranchName,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue