mirror of
https://github.com/kiegroup/git-backporting.git
synced 2025-06-28 21:53:47 +00: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
|
@ -1,53 +1,34 @@
|
|||
import ArgsParser from "@bp/service/args/args-parser";
|
||||
import { Args } from "@bp/service/args/args.types";
|
||||
import { getInput } from "@actions/core";
|
||||
import { readConfigFile } from "@bp/service/args/args-utils";
|
||||
import { getAsBooleanOrDefault, getAsCleanedCommaSeparatedList, getAsCommaSeparatedList, getOrUndefined, readConfigFile } from "@bp/service/args/args-utils";
|
||||
|
||||
export default class GHAArgsParser extends ArgsParser {
|
||||
|
||||
/**
|
||||
* Return the input only if it is not a blank or null string, otherwise returns undefined
|
||||
* @param key input key
|
||||
* @returns the value or undefined
|
||||
*/
|
||||
public getOrUndefined(key: string): string | undefined {
|
||||
const value = getInput(key);
|
||||
return value !== "" ? value : undefined;
|
||||
}
|
||||
|
||||
public getAsCommaSeparatedList(key: string): string[] | undefined {
|
||||
// trim the value
|
||||
const value: string = (getInput(key) ?? "").trim();
|
||||
return value !== "" ? value.replace(/\s/g, "").split(",") : undefined;
|
||||
}
|
||||
|
||||
private getAsBooleanOrDefault(key: string): boolean | undefined {
|
||||
const value = getInput(key).trim();
|
||||
return value !== "" ? value.toLowerCase() === "true" : undefined;
|
||||
}
|
||||
|
||||
readArgs(): Args {
|
||||
const configFile = this.getOrUndefined("config-file");
|
||||
const configFile = getOrUndefined(getInput("config-file"));
|
||||
|
||||
let args: Args;
|
||||
if (configFile) {
|
||||
args = readConfigFile(configFile);
|
||||
} else {
|
||||
args = {
|
||||
dryRun: this.getAsBooleanOrDefault("dry-run"),
|
||||
auth: this.getOrUndefined("auth"),
|
||||
dryRun: getAsBooleanOrDefault(getInput("dry-run")),
|
||||
auth: getOrUndefined(getInput("auth")),
|
||||
pullRequest: getInput("pull-request"),
|
||||
targetBranch: getInput("target-branch"),
|
||||
folder: this.getOrUndefined("folder"),
|
||||
gitUser: this.getOrUndefined("git-user"),
|
||||
gitEmail: this.getOrUndefined("git-email"),
|
||||
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"),
|
||||
folder: getOrUndefined(getInput("folder")),
|
||||
gitUser: getOrUndefined(getInput("git-user")),
|
||||
gitEmail: getOrUndefined(getInput("git-email")),
|
||||
title: getOrUndefined(getInput("title")),
|
||||
body: getOrUndefined(getInput("body")),
|
||||
bodyPrefix: getOrUndefined(getInput("body-prefix")),
|
||||
bpBranchName: getOrUndefined(getInput("bp-branch-name")),
|
||||
reviewers: getAsCleanedCommaSeparatedList(getInput("reviewers")),
|
||||
assignees: getAsCleanedCommaSeparatedList(getInput("assignees")),
|
||||
inheritReviewers: !getAsBooleanOrDefault(getInput("no-inherit-reviewers")),
|
||||
labels: getAsCommaSeparatedList(getInput("labels")),
|
||||
inheritLabels: getAsBooleanOrDefault(getInput("inherit-labels")),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue