mirror of
https://github.com/kiegroup/git-backporting.git
synced 2025-07-01 23:23:46 +00:00
feat: pull request backporting
feat: backport still open pull requests
This commit is contained in:
commit
b3936e019a
53 changed files with 48467 additions and 0 deletions
10
src/service/args/args-parser.ts
Normal file
10
src/service/args/args-parser.ts
Normal file
|
@ -0,0 +1,10 @@
|
|||
import { Args } from "@bp/service/args/args.types";
|
||||
|
||||
/**
|
||||
* Abstract arguments parser interface in charge to parse inputs and
|
||||
* produce a common Args object
|
||||
*/
|
||||
export default interface ArgsParser {
|
||||
|
||||
parse(): Args;
|
||||
}
|
11
src/service/args/args.types.ts
Normal file
11
src/service/args/args.types.ts
Normal file
|
@ -0,0 +1,11 @@
|
|||
/**
|
||||
* Input arguments
|
||||
*/
|
||||
export interface Args {
|
||||
dryRun: boolean, // if enabled do not push anything remotely
|
||||
auth: string, // git service auth, like github token
|
||||
targetBranch: string, // branch on the target repo where the change should be backported to
|
||||
pullRequest: string, // url of the pull request to backport
|
||||
folder?: string, // local folder where the repositories should be cloned
|
||||
author?: string, // backport pr author, default taken from pr
|
||||
}
|
34
src/service/args/cli/cli-args-parser.ts
Normal file
34
src/service/args/cli/cli-args-parser.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
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";
|
||||
|
||||
|
||||
export default class CLIArgsParser implements ArgsParser {
|
||||
|
||||
private getCommand(): Command {
|
||||
return new Command(name)
|
||||
.version(version)
|
||||
.description(description)
|
||||
.requiredOption("-tb, --target-branch <branch>", "branch where changes must be backported to.")
|
||||
.requiredOption("-pr, --pull-request <pr url>", "pull request url, e.g., https://github.com/lampajr/backporting/pull/1.")
|
||||
.option("-d, --dry-run", "if enabled the tool does not create any pull request nor push anything remotely", false)
|
||||
.option("-a, --auth <auth>", "git service authentication string, e.g., github token.", "")
|
||||
.option("-f, --folder <folder>", "local folder where the repo will be checked out, e.g., /tmp/folder.", undefined);
|
||||
}
|
||||
|
||||
parse(): Args {
|
||||
const opts = this.getCommand()
|
||||
.parse()
|
||||
.opts();
|
||||
|
||||
return {
|
||||
dryRun: opts.dryRun,
|
||||
auth: opts.auth,
|
||||
pullRequest: opts.pullRequest,
|
||||
targetBranch: opts.targetBranch,
|
||||
folder: opts.folder
|
||||
};
|
||||
}
|
||||
|
||||
}
|
17
src/service/args/gha/gha-args-parser.ts
Normal file
17
src/service/args/gha/gha-args-parser.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import ArgsParser from "@bp/service/args/args-parser";
|
||||
import { Args } from "@bp/service/args/args.types";
|
||||
import { getInput } from "@actions/core";
|
||||
|
||||
export default class GHAArgsParser implements ArgsParser {
|
||||
|
||||
parse(): Args {
|
||||
return {
|
||||
dryRun: getInput("dry-run") === "true",
|
||||
auth: getInput("auth") ? getInput("auth") : "",
|
||||
pullRequest: getInput("pull-request"),
|
||||
targetBranch: getInput("target-branch"),
|
||||
folder: getInput("folder") !== "" ? getInput("folder") : undefined
|
||||
};
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue