mirror of
https://code.forgejo.org/actions/git-backporting.git
synced 2025-02-23 19:15:43 -05:00
fix: gha input parser
This commit is contained in:
parent
941beda208
commit
95b35aa4ef
2 changed files with 29 additions and 10 deletions
19
dist/gha/index.js
vendored
19
dist/gha/index.js
vendored
|
@ -30,17 +30,26 @@ runner.run();
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const core_1 = __nccwpck_require__(2186);
|
const core_1 = __nccwpck_require__(2186);
|
||||||
class GHAArgsParser {
|
class GHAArgsParser {
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
_getOrUndefined(key) {
|
||||||
|
const value = (0, core_1.getInput)(key);
|
||||||
|
return value !== "" ? value : undefined;
|
||||||
|
}
|
||||||
parse() {
|
parse() {
|
||||||
return {
|
return {
|
||||||
dryRun: (0, core_1.getInput)("dry-run") === "true",
|
dryRun: (0, core_1.getInput)("dry-run") === "true",
|
||||||
auth: (0, core_1.getInput)("auth") ? (0, core_1.getInput)("auth") : "",
|
auth: (0, core_1.getInput)("auth") ? (0, core_1.getInput)("auth") : "",
|
||||||
pullRequest: (0, core_1.getInput)("pull-request"),
|
pullRequest: (0, core_1.getInput)("pull-request"),
|
||||||
targetBranch: (0, core_1.getInput)("target-branch"),
|
targetBranch: (0, core_1.getInput)("target-branch"),
|
||||||
folder: (0, core_1.getInput)("folder") !== "" ? (0, core_1.getInput)("folder") : undefined,
|
folder: this._getOrUndefined("folder"),
|
||||||
title: (0, core_1.getInput)("title"),
|
title: this._getOrUndefined("title"),
|
||||||
body: (0, core_1.getInput)("body"),
|
body: this._getOrUndefined("body"),
|
||||||
bodyPrefix: (0, core_1.getInput)("body-prefix"),
|
bodyPrefix: this._getOrUndefined("body-prefix"),
|
||||||
bpBranchName: (0, core_1.getInput)("bp-branch-name"),
|
bpBranchName: this._getOrUndefined("bp-branch-name"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,17 +4,27 @@ import { getInput } from "@actions/core";
|
||||||
|
|
||||||
export default class GHAArgsParser implements ArgsParser {
|
export default class GHAArgsParser implements 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
|
||||||
|
*/
|
||||||
|
private _getOrUndefined(key: string): string | undefined {
|
||||||
|
const value = getInput(key);
|
||||||
|
return value !== "" ? value : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
parse(): Args {
|
parse(): Args {
|
||||||
return {
|
return {
|
||||||
dryRun: getInput("dry-run") === "true",
|
dryRun: getInput("dry-run") === "true",
|
||||||
auth: getInput("auth") ? getInput("auth") : "",
|
auth: getInput("auth") ? getInput("auth") : "",
|
||||||
pullRequest: getInput("pull-request"),
|
pullRequest: getInput("pull-request"),
|
||||||
targetBranch: getInput("target-branch"),
|
targetBranch: getInput("target-branch"),
|
||||||
folder: getInput("folder") !== "" ? getInput("folder") : undefined,
|
folder: this._getOrUndefined("folder"),
|
||||||
title: getInput("title"),
|
title: this._getOrUndefined("title"),
|
||||||
body: getInput("body"),
|
body: this._getOrUndefined("body"),
|
||||||
bodyPrefix: getInput("body-prefix"),
|
bodyPrefix: this._getOrUndefined("body-prefix"),
|
||||||
bpBranchName: getInput("bp-branch-name"),
|
bpBranchName: this._getOrUndefined("bp-branch-name"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue