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
|
@ -9,22 +9,43 @@ export default class GHAArgsParser implements ArgsParser {
|
|||
* @param key input key
|
||||
* @returns the value or undefined
|
||||
*/
|
||||
private _getOrUndefined(key: string): string | undefined {
|
||||
public getOrUndefined(key: string): string | undefined {
|
||||
const value = getInput(key);
|
||||
return value !== "" ? value : undefined;
|
||||
}
|
||||
|
||||
public getOrDefault(key: string, defaultValue: string): string {
|
||||
const value = getInput(key);
|
||||
return value !== "" ? value : defaultValue;
|
||||
}
|
||||
|
||||
public getAsCommaSeparatedList(key: string): string[] {
|
||||
// trim the value
|
||||
const value: string = (getInput(key) ?? "").trim();
|
||||
return value !== "" ? value.replace(/\s/g, "").split(",") : [];
|
||||
}
|
||||
|
||||
public getAsBooleanOrDefault(key: string, defaultValue: boolean): boolean {
|
||||
const value = getInput(key).trim();
|
||||
return value !== "" ? value.toLowerCase() === "true" : defaultValue;
|
||||
}
|
||||
|
||||
parse(): Args {
|
||||
return {
|
||||
dryRun: getInput("dry-run") === "true",
|
||||
auth: getInput("auth") ? getInput("auth") : "",
|
||||
dryRun: this.getAsBooleanOrDefault("dry-run", false),
|
||||
auth: getInput("auth"),
|
||||
pullRequest: getInput("pull-request"),
|
||||
targetBranch: getInput("target-branch"),
|
||||
folder: this._getOrUndefined("folder"),
|
||||
title: this._getOrUndefined("title"),
|
||||
body: this._getOrUndefined("body"),
|
||||
bodyPrefix: this._getOrUndefined("body-prefix"),
|
||||
bpBranchName: this._getOrUndefined("bp-branch-name"),
|
||||
folder: this.getOrUndefined("folder"),
|
||||
gitUser: this.getOrDefault("git-user", "GitHub"),
|
||||
gitEmail: this.getOrDefault("git-email", "noreply@github.com"),
|
||||
title: this.getOrUndefined("title"),
|
||||
body: this.getOrUndefined("body"),
|
||||
bodyPrefix: this.getOrUndefined("body-prefix"),
|
||||
bpBranchName: this.getOrUndefined("bp-branch-name"),
|
||||
reviewers: this.getAsCommaSeparatedList("reviewers"),
|
||||
assignees: this.getAsCommaSeparatedList("assignees"),
|
||||
inheritReviewers: !this.getAsBooleanOrDefault("no-inherit-reviewers", false),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue