mirror of
https://code.forgejo.org/actions/git-backporting.git
synced 2025-05-15 18:19:13 -04:00
feat(issue-41): set and inherit labels (#48)
fix https://github.com/kiegroup/git-backporting/issues/41
This commit is contained in:
parent
f923f7f4c2
commit
fcc01673f4
28 changed files with 962 additions and 140 deletions
|
@ -2,13 +2,7 @@ import ArgsParser from "@bp/service/args/args-parser";
|
|||
import { Args } from "@bp/service/args/args.types";
|
||||
import { Command } from "commander";
|
||||
import { name, version, description } from "@bp/../package.json";
|
||||
import { readConfigFile } from "@bp/service/args/args-utils";
|
||||
|
||||
function commaSeparatedList(value: string, _prev: unknown): string[] {
|
||||
// remove all whitespaces
|
||||
const cleanedValue: string = value.trim();
|
||||
return cleanedValue !== "" ? cleanedValue.replace(/\s/g, "").split(",") : [];
|
||||
}
|
||||
import { getAsCleanedCommaSeparatedList, getAsCommaSeparatedList, readConfigFile } from "@bp/service/args/args-utils";
|
||||
|
||||
export default class CLIArgsParser extends ArgsParser {
|
||||
|
||||
|
@ -16,21 +10,23 @@ export default class CLIArgsParser extends ArgsParser {
|
|||
return new Command(name)
|
||||
.version(version)
|
||||
.description(description)
|
||||
.option("-tb, --target-branch <branch>", "branch where changes must be backported to.")
|
||||
.option("-pr, --pull-request <pr-url>", "pull request url, e.g., https://github.com/kiegroup/git-backporting/pull/1.")
|
||||
.option("-tb, --target-branch <branch>", "branch where changes must be backported to")
|
||||
.option("-pr, --pull-request <pr-url>", "pull request url, e.g., https://github.com/kiegroup/git-backporting/pull/1")
|
||||
.option("-d, --dry-run", "if enabled the tool does not create any pull request nor push anything remotely")
|
||||
.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'.")
|
||||
.option("-ge, --git-email <git-email>", "local git user email, default is 'noreply@github.com'.")
|
||||
.option("-f, --folder <folder>", "local folder where the repo will be checked out, e.g., /tmp/folder.")
|
||||
.option("--title <bp-title>", "backport pr title, default original pr title prefixed by target branch.")
|
||||
.option("--body <bp-body>", "backport pr title, default original pr body prefixed by bodyPrefix.")
|
||||
.option("--body-prefix <bp-body-prefix>", "backport pr body prefix, default `backport <original-pr-link>`.")
|
||||
.option("--bp-branch-name <bp-branch-name>", "backport pr branch name, default auto-generated by the commit.")
|
||||
.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("-a, --auth <auth>", "git service authentication string, e.g., github token")
|
||||
.option("-gu, --git-user <git-user>", "local git user name, default is 'GitHub'")
|
||||
.option("-ge, --git-email <git-email>", "local git user email, default is 'noreply@github.com'")
|
||||
.option("-f, --folder <folder>", "local folder where the repo will be checked out, e.g., /tmp/folder")
|
||||
.option("--title <bp-title>", "backport pr title, default original pr title prefixed by target branch")
|
||||
.option("--body <bp-body>", "backport pr title, default original pr body prefixed by bodyPrefix")
|
||||
.option("--body-prefix <bp-body-prefix>", "backport pr body prefix, default `backport <original-pr-link>`")
|
||||
.option("--bp-branch-name <bp-branch-name>", "backport pr branch name, default auto-generated by the commit")
|
||||
.option("--reviewers <reviewers>", "comma separated list of reviewers for the backporting pull request", getAsCleanedCommaSeparatedList)
|
||||
.option("--assignees <assignees>", "comma separated list of assignees for the backporting pull request", getAsCleanedCommaSeparatedList)
|
||||
.option("--no-inherit-reviewers", "if provided and reviewers option is empty then inherit them from original pull request")
|
||||
.option("-cf, --config-file <config-file>", "configuration file containing all valid options, the json must match Args interface.");
|
||||
.option("--labels <labels>", "comma separated list of labels to be assigned to the backported pull request", getAsCommaSeparatedList)
|
||||
.option("--inherit-labels", "if true the backported pull request will inherit labels from the original one")
|
||||
.option("-cf, --config-file <config-file>", "configuration file containing all valid options, the json must match Args interface");
|
||||
}
|
||||
|
||||
readArgs(): Args {
|
||||
|
@ -58,6 +54,8 @@ export default class CLIArgsParser extends ArgsParser {
|
|||
reviewers: opts.reviewers,
|
||||
assignees: opts.assignees,
|
||||
inheritReviewers: opts.inheritReviewers,
|
||||
labels: opts.labels,
|
||||
inheritLabels: opts.inheritLabels,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue