mirror of
https://code.forgejo.org/actions/git-backporting.git
synced 2025-05-15 10:09: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
|
@ -3,6 +3,11 @@ import { Args } from "@bp/service/args/args.types";
|
|||
import { Command } from "commander";
|
||||
import { name, version, description } from "@bp/../package.json";
|
||||
|
||||
function commaSeparatedList(value: string, _prev: unknown): string[] {
|
||||
// remove all whitespaces
|
||||
const cleanedValue: string = value.trim();
|
||||
return cleanedValue !== "" ? cleanedValue.replace(/\s/g, "").split(",") : [];
|
||||
}
|
||||
|
||||
export default class CLIArgsParser implements ArgsParser {
|
||||
|
||||
|
@ -11,14 +16,19 @@ export default class CLIArgsParser implements ArgsParser {
|
|||
.version(version)
|
||||
.description(description)
|
||||
.requiredOption("-tb, --target-branch <branch>", "branch where changes must be backported to.")
|
||||
.requiredOption("-pr, --pull-request <pr url>", "pull request url, e.g., https://github.com/lampajr/backporting/pull/1.")
|
||||
.requiredOption("-pr, --pull-request <pr-url>", "pull request url, e.g., https://github.com/lampajr/backporting/pull/1.")
|
||||
.option("-d, --dry-run", "if enabled the tool does not create any pull request nor push anything remotely", false)
|
||||
.option("-a, --auth <auth>", "git service authentication string, e.g., github token.", "")
|
||||
.option("-gu, --git-user <git-user>", "local git user name, default is 'GitHub'.", "GitHub")
|
||||
.option("-ge, --git-email <git-email>", "local git user email, default is 'noreply@github.com'.", "noreply@github.com")
|
||||
.option("-f, --folder <folder>", "local folder where the repo will be checked out, e.g., /tmp/folder.", undefined)
|
||||
.option("--title <folder>", "backport pr title, default original pr title prefixed by target branch.", undefined)
|
||||
.option("--body <folder>", "backport pr title, default original pr body prefixed by bodyPrefix.", undefined)
|
||||
.option("--body-prefix <folder>", "backport pr body prefix, default `backport <original-pr-link>`.", undefined)
|
||||
.option("--bp-branch-name <folder>", "backport pr branch name, default auto-generated by the commit.", undefined);
|
||||
.option("--title <bp-title>", "backport pr title, default original pr title prefixed by target branch.", undefined)
|
||||
.option("--body <bp-body>", "backport pr title, default original pr body prefixed by bodyPrefix.", undefined)
|
||||
.option("--body-prefix <bp-body-prefix>", "backport pr body prefix, default `backport <original-pr-link>`.", undefined)
|
||||
.option("--bp-branch-name <bp-branch-name>", "backport pr branch name, default auto-generated by the commit.", undefined)
|
||||
.option("--reviewers <reviewers>", "comma separated list of reviewers for the backporting pull request.", commaSeparatedList, [])
|
||||
.option("--assignees <assignees>", "comma separated list of assignees for the backporting pull request.", commaSeparatedList, [])
|
||||
.option("--no-inherit-reviewers", "if provided and reviewers option is empty then inherit them from original pull request", true);
|
||||
}
|
||||
|
||||
parse(): Args {
|
||||
|
@ -32,10 +42,15 @@ export default class CLIArgsParser implements ArgsParser {
|
|||
pullRequest: opts.pullRequest,
|
||||
targetBranch: opts.targetBranch,
|
||||
folder: opts.folder,
|
||||
gitUser: opts.gitUser,
|
||||
gitEmail: opts.gitEmail,
|
||||
title: opts.title,
|
||||
body: opts.body,
|
||||
bodyPrefix: opts.bodyPrefix,
|
||||
bpBranchName: opts.bpBranchName,
|
||||
reviewers: opts.reviewers,
|
||||
assignees: opts.assignees,
|
||||
inheritReviewers: opts.inheritReviewers,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue