mirror of
https://github.com/kiegroup/git-backporting.git
synced 2025-06-27 21:23:48 +00:00
feat: add --git-client to explicitly set the type of forge (#106)
codeberg is running Forgejo and it may not be possible to infer that from the URL alone. The same is true for GitHub Enterprise Server.
This commit is contained in:
parent
646d8fe41c
commit
80a0b554f0
11 changed files with 70 additions and 3 deletions
11
dist/cli/index.js
vendored
11
dist/cli/index.js
vendored
|
@ -49,6 +49,7 @@ class ArgsParser {
|
|||
dryRun: this.getOrDefault(args.dryRun, false),
|
||||
auth: this.getOrDefault(args.auth),
|
||||
folder: this.getOrDefault(args.folder),
|
||||
gitClient: this.getOrDefault(args.gitClient),
|
||||
gitUser: this.getOrDefault(args.gitUser),
|
||||
gitEmail: this.getOrDefault(args.gitEmail),
|
||||
title: this.getOrDefault(args.title),
|
||||
|
@ -183,6 +184,7 @@ class CLIArgsParser extends args_parser_1.default {
|
|||
.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 authentication string, if not provided fallback by looking for existing env variables like GITHUB_TOKEN")
|
||||
.option("--git-client <github|gitlab|codeberg>", "git client type, if not set it is infered from --pull-request")
|
||||
.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")
|
||||
|
@ -217,6 +219,7 @@ class CLIArgsParser extends args_parser_1.default {
|
|||
pullRequest: opts.pullRequest,
|
||||
targetBranch: opts.targetBranch,
|
||||
folder: opts.folder,
|
||||
gitClient: opts.gitClient,
|
||||
gitUser: opts.gitUser,
|
||||
gitEmail: opts.gitEmail,
|
||||
title: opts.title,
|
||||
|
@ -1343,7 +1346,13 @@ class Runner {
|
|||
this.logger.warn("Dry run enabled");
|
||||
}
|
||||
// 2. init git service
|
||||
const gitClientType = (0, git_util_1.inferGitClient)(args.pullRequest);
|
||||
let gitClientType;
|
||||
if (args.gitClient === undefined) {
|
||||
gitClientType = (0, git_util_1.inferGitClient)(args.pullRequest);
|
||||
}
|
||||
else {
|
||||
gitClientType = args.gitClient;
|
||||
}
|
||||
// the api version is ignored in case of github
|
||||
const apiUrl = (0, git_util_1.inferGitApiUrl)(args.pullRequest, gitClientType === git_types_1.GitClientType.CODEBERG ? "v1" : undefined);
|
||||
const token = this.fetchToken(args, gitClientType);
|
||||
|
|
10
dist/gha/index.js
vendored
10
dist/gha/index.js
vendored
|
@ -49,6 +49,7 @@ class ArgsParser {
|
|||
dryRun: this.getOrDefault(args.dryRun, false),
|
||||
auth: this.getOrDefault(args.auth),
|
||||
folder: this.getOrDefault(args.folder),
|
||||
gitClient: this.getOrDefault(args.gitClient),
|
||||
gitUser: this.getOrDefault(args.gitUser),
|
||||
gitEmail: this.getOrDefault(args.gitEmail),
|
||||
title: this.getOrDefault(args.title),
|
||||
|
@ -187,6 +188,7 @@ class GHAArgsParser extends args_parser_1.default {
|
|||
pullRequest: (0, core_1.getInput)("pull-request"),
|
||||
targetBranch: (0, core_1.getInput)("target-branch"),
|
||||
folder: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("folder")),
|
||||
gitClient: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("git-client")),
|
||||
gitUser: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("git-user")),
|
||||
gitEmail: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("git-email")),
|
||||
title: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("title")),
|
||||
|
@ -1313,7 +1315,13 @@ class Runner {
|
|||
this.logger.warn("Dry run enabled");
|
||||
}
|
||||
// 2. init git service
|
||||
const gitClientType = (0, git_util_1.inferGitClient)(args.pullRequest);
|
||||
let gitClientType;
|
||||
if (args.gitClient === undefined) {
|
||||
gitClientType = (0, git_util_1.inferGitClient)(args.pullRequest);
|
||||
}
|
||||
else {
|
||||
gitClientType = args.gitClient;
|
||||
}
|
||||
// the api version is ignored in case of github
|
||||
const apiUrl = (0, git_util_1.inferGitApiUrl)(args.pullRequest, gitClientType === git_types_1.GitClientType.CODEBERG ? "v1" : undefined);
|
||||
const token = this.fetchToken(args, gitClientType);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue