Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc5dba6703 | ||
|
|
e6f86f8f83 | ||
|
|
0a07bf30c8 | ||
|
|
6d9b9db590 | ||
|
|
fe6be83074 | ||
|
|
53cc505f17 | ||
|
|
b2e2e271b9 | ||
|
|
ee7a87f26f | ||
|
|
b30ba6021a | ||
|
|
ffe625d8b3 | ||
|
|
80a0b554f0 | ||
|
|
646d8fe41c | ||
|
|
a36b740991 |
27
CHANGELOG.md
27
CHANGELOG.md
@@ -1,5 +1,32 @@
|
||||
# Changelog
|
||||
|
||||
## [4.7.1](https://github.com/kiegroup/git-backporting/compare/v4.7.0...v4.7.1) (2024-04-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* gha input is target-branch-pattern, not target-reg-exp ([#120](https://github.com/kiegroup/git-backporting/issues/120)) ([e6f86f8](https://github.com/kiegroup/git-backporting/commit/e6f86f8f839bc86adf36fa0d3c8dcad6cab2f92e))
|
||||
|
||||
## [4.7.0](https://github.com/kiegroup/git-backporting/compare/v4.6.0...v4.7.0) (2024-04-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add --cherry-pick-options to add to all cherry-pick run ([#116](https://github.com/kiegroup/git-backporting/issues/116)) ([fe6be83](https://github.com/kiegroup/git-backporting/commit/fe6be83074476d91c1b038fd7f03c4868e96f113))
|
||||
* **gh75:** extract target branched from pr labels ([#112](https://github.com/kiegroup/git-backporting/issues/112)) ([53cc505](https://github.com/kiegroup/git-backporting/commit/53cc505f17630fb30daa70f75895323325cc0c7d))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* return GitHub no-squash commits in order ([#115](https://github.com/kiegroup/git-backporting/issues/115)) ([6d9b9db](https://github.com/kiegroup/git-backporting/commit/6d9b9db590f9713e2b056bcc8e20fc3f3c70618b))
|
||||
|
||||
## [4.6.0](https://github.com/kiegroup/git-backporting/compare/v4.5.2...v4.6.0) (2024-03-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add --git-client to explicitly set the type of forge ([#106](https://github.com/kiegroup/git-backporting/issues/106)) ([80a0b55](https://github.com/kiegroup/git-backporting/commit/80a0b554f0c1920a178e28bd678f709581a1b224))
|
||||
|
||||
## [4.5.2](https://github.com/kiegroup/git-backporting/compare/v4.5.1...v4.5.2) (2024-03-08)
|
||||
|
||||
### Improvements
|
||||
|
||||
47
README.md
47
README.md
@@ -24,7 +24,6 @@ Table of content
|
||||
* **[CLI tool](#cli-tool)**
|
||||
* **[GitHub action](#github-action)**
|
||||
* **[Future works](#future-works)**
|
||||
* **[Migrating to v4](#migrating-to-v4)**
|
||||
* **[Development](#development)**
|
||||
* **[Contributing](#contributing)**
|
||||
* **[License](#license)**
|
||||
@@ -39,7 +38,7 @@ Therefore this tools is for anybody who is working on projects where they have t
|
||||
|
||||
## CLI tool
|
||||
|
||||
> All instructions provided below pertain to version `v4` of the tool. If you wish to use an earlier version, we strongly encourage you to consider migrating to version `v4` as there are no valid reason to keep using older versions. Please refer to [Migrating to v4](#migrating-to-v4) section for comprehensive details on how to properly migrate to version `v4`.
|
||||
> All instructions provided below pertain to version `v4` of the tool. If you wish to use an earlier version, please refer to the documentation from the corresponding tag/release.
|
||||
|
||||
This tool is released on the [public npm registry](https://www.npmjs.com/), therefore it can be easily installed using `npm`:
|
||||
|
||||
@@ -47,7 +46,7 @@ This tool is released on the [public npm registry](https://www.npmjs.com/), ther
|
||||
$ npm install -g @kie/git-backporting
|
||||
```
|
||||
|
||||
Then you just have to choose the pull request (or merge request on *Gitlab*) that you would like to backport and the target branch and the simply run the following command:
|
||||
Then you just have to choose the pull request (or merge request on *Gitlab*) that you would like to backport and the target branch and then simply run the following command:
|
||||
|
||||
```bash
|
||||
$ git-backporting -tb <branch> -pr <pull-request-url> -a <git-token>
|
||||
@@ -67,7 +66,7 @@ This is the easiest invocation where you let the tool set / compute most of the
|
||||
|
||||
### How it works?
|
||||
|
||||
The simply works in this way: given the provided `pull/merge request` it infers the git client to use (either *Github* or *Gitlab* for now) and it retrieve the corresponding pull request object (original pull/merge request to be backported into another branch).
|
||||
It works in this way: given the provided `pull/merge request` it infers the server API to use (either *Github* or *Gitlab* for now) and retrieves the corresponding pull request object (original pull/merge request to be backported into another branch).
|
||||
|
||||
After that it clones the corresponding git repository, check out in the provided `target branch` and create a new branch from that (name automatically generated if not provided as option).
|
||||
|
||||
@@ -75,14 +74,24 @@ By default the tool will try to cherry-pick the single squashed/merged commit in
|
||||
|
||||
Based on the original pull request, creates a new one containing the backporting to the target branch. Note that most of these information can be overridden with appropriate CLI options or GHA inputs.
|
||||
|
||||
#### Default cherry-pick strategy
|
||||
#### cherry-pick strategy
|
||||
|
||||
The default cherry-pick strategy is `recursive` with `theirs` option for automatic conflicts resolution. Therefore, by default, all commits are cherry-picked using the following git-equivalent command:
|
||||
```bash
|
||||
$ git cherry-pick -m 1 --strategy=recursive --strategy-option=theirs <sha>
|
||||
```
|
||||
|
||||
From version `v4.2.0` we made both `strategy` and `strategy-option` fully configurable from CLI or GitHub action, so if users need a specific strategy which differs from the default one please consider using either `--strategy` or `--strategy-option`, or their equivalent GitHub action inputs, more details in [inputs](#inputs) section.
|
||||
From version `v4.2.0` both can be configured via the `strategy` or `strategy-option` inputs if using the action and the `--strategy` or `--strategy-option` arguments if using the CLI.
|
||||
|
||||
The [default strategy](https://git-scm.com/docs/git-merge#Documentation/git-merge.txt--sltstrategygt) of the `git-cherry-pick` command is different from the defaults of `git-backporting`.
|
||||
```bash
|
||||
$ git cherry-pick -m 1 <sha>
|
||||
```
|
||||
is the same as:
|
||||
```bash
|
||||
$ git cherry-pick -m 1 --strategy=ort --strategy-option=find-renames <sha>
|
||||
```
|
||||
If there is a conflict the backport will fail and require manual intervention.
|
||||
|
||||
> **NOTE**: If there are any conflicts, the tool will block the process and exit signalling the failure as there are still no ways to interactively resolve them. In these cases a manual cherry-pick is needed, or alternatively users could manually resume the process in the cloned repository (here the user will have to resolve the conflicts, push the branch and create the pull request - all manually).
|
||||
|
||||
@@ -95,10 +104,12 @@ This tool comes with some inputs that allow users to override the default behavi
|
||||
| Version | -V, --version | - | Current version of the tool | |
|
||||
| Help | -h, --help | - | Display the help message | |
|
||||
| Target Branches | -tb, --target-branch | N | Comma separated list of branches where the changes must be backported to | |
|
||||
| Target Branches Pattern | -tbp, --target-branch-pattern | N | Regular expression pattern to extract target branch(es) from pr labels. The branches will be extracted from the pattern's required `target` named capturing group, e.g., `^backport (?<target>([^ ]+))$` | |
|
||||
| Pull Request | -pr, --pull-request | N | Original pull request url, the one that must be backported, e.g., https://github.com/kiegroup/git-backporting/pull/1 | |
|
||||
| Configuration File | -cf, --config-file | N | Configuration file, in JSON format, containing all options to be overridded, note that if provided all other CLI options will be ignored | |
|
||||
| Auth | -a, --auth | N | Git access/authorization token, if provided all token env variables will be ignored. See [auth token](#authorization-token) section for more details | "" |
|
||||
| Folder | -f, --folder | N | Local folder full name of the repository that will be checked out, e.g., /tmp/folder | {cwd}/bp |
|
||||
| Git Client | --git-client | N | Git client type <github|gitlab|codeberg>, if not set it is infered from pull-request
|
||||
| Git User | -gu, --git-user | N | Local git user name | "GitHub" |
|
||||
| Git Email | -ge, --git-email | N | Local git user email | "noreply@github.com" |
|
||||
| Title | --title | N | Backporting pull request title | "{original-pr-title}" |
|
||||
@@ -113,10 +124,11 @@ This tool comes with some inputs that allow users to override the default behavi
|
||||
| No squash | --no-squash | N | If provided the backporting will try to backport all pull request commits without squashing | false |
|
||||
| Strategy | --strategy | N | Cherry pick merging strategy, see [git-merge](https://git-scm.com/docs/git-merge#_merge_strategies) doc for all possible values | "recursive" |
|
||||
| Strategy Option | --strategy-option | N | Cherry pick merging strategy option, see [git-merge](https://git-scm.com/docs/git-merge#_merge_strategies) doc for all possible values | "theirs" |
|
||||
| Cherry-pick Options | --cherry-pick-options | N | Additional cherry-pick options, see [git-cherry-pick](https://git-scm.com/docs/git-cherry-pick) doc for all possible values | "theirs" |
|
||||
| Additional comments | --comments | N | Semicolon separated list of additional comments to be posted to the backported pull request | [] |
|
||||
| Dry Run | -d, --dry-run | N | If enabled the tool does not push nor create anything remotely, use this to skip PR creation | false |
|
||||
|
||||
> **NOTE**: `pull request` and `target branch` are *mandatory*, they must be provided as CLI options or as part of the configuration file (if used).
|
||||
> **NOTE**: `pull request` and (`target branch` or `target branch pattern`) are *mandatory*, they must be provided as CLI options or as part of the configuration file (if used).
|
||||
|
||||
#### Authorization token
|
||||
|
||||
@@ -141,7 +153,7 @@ This is an example of a configuration file that can be used.
|
||||
"auth": "*****"
|
||||
}
|
||||
```
|
||||
Keep in mind that its structue MUST match the [Args](src/service/args/args.types.ts) interface, which is actually a camel-case version of the CLI options.
|
||||
Keep in mind that its structure MUST match the [Args](src/service/args/args.types.ts) interface, which is actually a camel-case version of the CLI options.
|
||||
|
||||
### Supported git services
|
||||
|
||||
@@ -243,23 +255,6 @@ For a complete description of all inputs see [Inputs section](#inputs).
|
||||
- Integrate it into other CI/CD services like gitlab CI.
|
||||
- Provide some reusable *GitHub* workflows.
|
||||
|
||||
## Migrating to v4
|
||||
|
||||
From version `v4` the project has been moved under [@kiegroup](https://github.com/kiegroup) organization. During this migration we changed some things that you should be aware of. I'll try to summarize them in the following table:
|
||||
|
||||
> **NOTE**: these changes did not affect the tool features.
|
||||
|
||||
| | **v4 (after migration)** | v3 or older (before migration) |
|
||||
|-------------|--------------------------|--------------------------------|
|
||||
| Owner | kiegroup | lampajr |
|
||||
| Repository | git-backporting | backporting |
|
||||
| NPM package | @kie/git-backporting | @lampajr/bper |
|
||||
| CLI tool | git-backporting | bper |
|
||||
|
||||
So everytime you would use older version keep in mind that these changes are madnatory to make the tool working.
|
||||
|
||||
> **NOTE**: Versions `v3.1.1` and `v4.0.0` offer identical features; the only distinction lies in the project's renaming and organization movement.
|
||||
|
||||
## Development
|
||||
|
||||
### Package release
|
||||
@@ -321,4 +316,4 @@ Every change must be submitted through a *GitHub* pull request (PR). Backporting
|
||||
|
||||
## License
|
||||
|
||||
Git backporting open source project is licensed under the [MIT](./LICENSE) license.
|
||||
Git backporting open source project is licensed under the [MIT](./LICENSE) license.
|
||||
|
||||
77
action.yml
77
action.yml
@@ -1,74 +1,109 @@
|
||||
name: "Backporting GitHub Action"
|
||||
description: "GitHub action providing an automated way to backport pull requests from one branch to another"
|
||||
description: GitHub action providing an automated way to backport pull requests from one branch to another
|
||||
inputs:
|
||||
pull-request:
|
||||
description: "URL of the pull request to backport, e.g., https://github.com/kiegroup/git-backporting/pull/1"
|
||||
description: >
|
||||
URL of the pull request to backport, e.g., "https://github.com/kiegroup/git-backporting/pull/1"
|
||||
required: false
|
||||
target-branch:
|
||||
description: "Comma separated list of branches where the pull request must be backported to"
|
||||
description: >
|
||||
Comma separated list of branches where the pull request must be backported to
|
||||
required: false
|
||||
target-branch-pattern:
|
||||
description: >
|
||||
Regular expression pattern to extract target branch(es) from pr labels.
|
||||
The branches will be extracted from the pattern's required `target` named capturing group,
|
||||
for instance "^backport (?<target>([^ ]+))$"
|
||||
required: false
|
||||
config-file:
|
||||
description: "Path to a file containing the json configuration for this tool, the object must match the Args interface"
|
||||
description: >
|
||||
Path to a file containing the json configuration for this tool,
|
||||
the object must match the Args interface
|
||||
required: false
|
||||
dry-run:
|
||||
description: "If enabled the tool does not create any pull request nor push anything remotely"
|
||||
description: >
|
||||
If enabled the tool does not create any pull request nor push anything remotely
|
||||
required: false
|
||||
default: "false"
|
||||
auth:
|
||||
description: "GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT), if not provided will look for existing env variables like GITHUB_TOKEN"
|
||||
description: >
|
||||
GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT),
|
||||
if not provided will look for existing env variables like GITHUB_TOKEN
|
||||
default: ${{ github.token }}
|
||||
required: false
|
||||
git-client:
|
||||
description: >
|
||||
Git client type <github|gitlab|codeberg>, if not set it is infered from pull-request
|
||||
required: false
|
||||
git-user:
|
||||
description: "Local git user name"
|
||||
description: Local git user name
|
||||
default: "GitHub"
|
||||
required: false
|
||||
git-email:
|
||||
description: "Local git user email"
|
||||
description: Local git user email
|
||||
default: "noreply@github.com"
|
||||
required: false
|
||||
title:
|
||||
description: "Backporting PR title. Default is the original PR title prefixed by the target branch"
|
||||
description: >
|
||||
Backporting PR title. Default is the original PR title prefixed by the target branch
|
||||
required: false
|
||||
body-prefix:
|
||||
description: "Backporting PR body prefix. Default is `Backport: <original-pr-link>`"
|
||||
description: >
|
||||
Backporting PR body prefix. Default is `Backport: <original-pr-link>`
|
||||
required: false
|
||||
body:
|
||||
description: "Backporting PR body. Default is the original PR body"
|
||||
description: >
|
||||
Backporting PR body. Default is the original PR body
|
||||
required: false
|
||||
bp-branch-name:
|
||||
description: "Comma separated list of backporting PR branch names. Default is auto-generated from commit and target branches"
|
||||
description: >
|
||||
Comma separated list of backporting PR branch names.
|
||||
Default is auto-generated from commit and target branches
|
||||
required: false
|
||||
reviewers:
|
||||
description: "Comma separated list of reviewers for the backporting pull request"
|
||||
description: >
|
||||
Comma separated list of reviewers for the backporting pull request
|
||||
required: false
|
||||
assignees:
|
||||
description: "Comma separated list of reviewers for the backporting pull request"
|
||||
description: >
|
||||
Comma separated list of reviewers for the backporting pull request
|
||||
required: false
|
||||
no-inherit-reviewers:
|
||||
description: "Considered only if reviewers is empty, if true keep reviewers as empty list, otherwise inherit from original pull request"
|
||||
description: >
|
||||
Considered only if reviewers is empty, if true keep reviewers as empty list,
|
||||
otherwise inherit from original pull request
|
||||
required: false
|
||||
default: "false"
|
||||
labels:
|
||||
description: "Comma separated list of labels to be assigned to the backported pull request"
|
||||
description: >
|
||||
Comma separated list of labels to be assigned to the backported pull request
|
||||
required: false
|
||||
inherit-labels:
|
||||
description: "If true the backported pull request will inherit labels from the original one"
|
||||
description: >
|
||||
If true the backported pull request will inherit labels from the original one
|
||||
required: false
|
||||
default: "false"
|
||||
no-squash:
|
||||
description: "If set to true the tool will backport all commits as part of the pull request instead of the suqashed one"
|
||||
description: >
|
||||
If set to true the tool will backport all commits as part of the pull request
|
||||
instead of the suqashed one
|
||||
required: false
|
||||
default: "false"
|
||||
strategy:
|
||||
description: "Cherry-pick merge strategy"
|
||||
description: Cherry-pick merge strategy
|
||||
required: false
|
||||
default: "recursive"
|
||||
strategy-option:
|
||||
description: "Cherry-pick merge strategy option"
|
||||
description: Cherry-pick merge strategy option
|
||||
required: false
|
||||
default: "theirs"
|
||||
cherry-pick-options:
|
||||
description: >
|
||||
Additional cherry-pick options
|
||||
required: false
|
||||
comments:
|
||||
description: "Semicolon separated list of additional comments to be posted to the backported pull request"
|
||||
description: >
|
||||
Semicolon separated list of additional comments to be posted to the backported pull request
|
||||
required: false
|
||||
|
||||
runs:
|
||||
|
||||
78
dist/cli/index.js
vendored
78
dist/cli/index.js
vendored
@@ -39,16 +39,21 @@ class ArgsParser {
|
||||
}
|
||||
parse() {
|
||||
const args = this.readArgs();
|
||||
if (!args.pullRequest) {
|
||||
throw new Error("Missing option: pull request must be provided");
|
||||
}
|
||||
// validate and fill with defaults
|
||||
if (!args.pullRequest || !args.targetBranch || args.targetBranch.trim().length == 0) {
|
||||
throw new Error("Missing option: pull request and target branches must be provided");
|
||||
if ((!args.targetBranch || args.targetBranch.trim().length == 0) && !args.targetBranchPattern) {
|
||||
throw new Error("Missing option: target branch(es) or target regular expression must be provided");
|
||||
}
|
||||
return {
|
||||
pullRequest: args.pullRequest,
|
||||
targetBranch: args.targetBranch,
|
||||
targetBranchPattern: args.targetBranchPattern,
|
||||
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),
|
||||
@@ -63,6 +68,7 @@ class ArgsParser {
|
||||
squash: this.getOrDefault(args.squash, true),
|
||||
strategy: this.getOrDefault(args.strategy),
|
||||
strategyOption: this.getOrDefault(args.strategyOption),
|
||||
cherryPickOptions: this.getOrDefault(args.cherryPickOptions),
|
||||
comments: this.getOrDefault(args.comments)
|
||||
};
|
||||
}
|
||||
@@ -180,9 +186,11 @@ class CLIArgsParser extends args_parser_1.default {
|
||||
.version(package_json_1.version)
|
||||
.description(package_json_1.description)
|
||||
.option("-tb, --target-branch <branches>", "comma separated list of branches where changes must be backported to")
|
||||
.option("-tbp, --target-branch-pattern <pattern>", "regular expression pattern to extract target branch(es) from pr labels, the branches will be extracted from the pattern's required `target` named capturing group")
|
||||
.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")
|
||||
@@ -198,6 +206,7 @@ class CLIArgsParser extends args_parser_1.default {
|
||||
.option("--no-squash", "if provided the tool will backport all commits as part of the pull request")
|
||||
.option("--strategy <strategy>", "cherry-pick merge strategy, default to 'recursive'", undefined)
|
||||
.option("--strategy-option <strategy-option>", "cherry-pick merge strategy option, default to 'theirs'")
|
||||
.option("--cherry-pick-options <options>", "additional cherry-pick options")
|
||||
.option("--comments <comments>", "semicolon separated list of additional comments to be posted to the backported pull request", args_utils_1.getAsSemicolonSeparatedList)
|
||||
.option("-cf, --config-file <config-file>", "configuration file containing all valid options, the json must match Args interface");
|
||||
}
|
||||
@@ -216,7 +225,9 @@ class CLIArgsParser extends args_parser_1.default {
|
||||
auth: opts.auth,
|
||||
pullRequest: opts.pullRequest,
|
||||
targetBranch: opts.targetBranch,
|
||||
targetBranchPattern: opts.targetBranchPattern,
|
||||
folder: opts.folder,
|
||||
gitClient: opts.gitClient,
|
||||
gitUser: opts.gitUser,
|
||||
gitEmail: opts.gitEmail,
|
||||
title: opts.title,
|
||||
@@ -231,6 +242,7 @@ class CLIArgsParser extends args_parser_1.default {
|
||||
squash: opts.squash,
|
||||
strategy: opts.strategy,
|
||||
strategyOption: opts.strategyOption,
|
||||
cherryPickOptions: opts.cherryPickOptions,
|
||||
comments: opts.comments,
|
||||
};
|
||||
}
|
||||
@@ -328,7 +340,18 @@ class PullRequestConfigsParser extends configs_parser_1.default {
|
||||
throw error;
|
||||
}
|
||||
const folder = args.folder ?? this.getDefaultFolder();
|
||||
const targetBranches = [...new Set((0, args_utils_1.getAsCommaSeparatedList)(args.targetBranch))];
|
||||
let targetBranches = [];
|
||||
if (args.targetBranchPattern) {
|
||||
// parse labels to extract target branch(es)
|
||||
targetBranches = this.getTargetBranchesFromLabels(args.targetBranchPattern, pr.labels);
|
||||
if (targetBranches.length === 0) {
|
||||
throw new Error(`Unable to extract target branches with regular expression "${args.targetBranchPattern}"`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// target branch must be provided if targetRegExp is missing
|
||||
targetBranches = [...new Set((0, args_utils_1.getAsCommaSeparatedList)(args.targetBranch))];
|
||||
}
|
||||
const bpBranchNames = [...new Set(args.bpBranchName ? ((0, args_utils_1.getAsCleanedCommaSeparatedList)(args.bpBranchName) ?? []) : [])];
|
||||
if (bpBranchNames.length > 1 && bpBranchNames.length != targetBranches.length) {
|
||||
throw new Error(`The number of backport branch names, if provided, must match the number of target branches or just one, provided ${bpBranchNames.length} branch names instead`);
|
||||
@@ -339,6 +362,7 @@ class PullRequestConfigsParser extends configs_parser_1.default {
|
||||
folder: `${folder.startsWith("/") ? "" : process.cwd() + "/"}${args.folder ?? this.getDefaultFolder()}`,
|
||||
mergeStrategy: args.strategy,
|
||||
mergeStrategyOption: args.strategyOption,
|
||||
cherryPickOptions: args.cherryPickOptions,
|
||||
originalPullRequest: pr,
|
||||
backportPullRequests: this.generateBackportPullRequestsData(pr, args, targetBranches, bpBranchNames),
|
||||
git: {
|
||||
@@ -350,6 +374,28 @@ class PullRequestConfigsParser extends configs_parser_1.default {
|
||||
getDefaultFolder() {
|
||||
return "bp";
|
||||
}
|
||||
/**
|
||||
* Parse the provided labels and return a list of target branches
|
||||
* obtained by applying the provided pattern as regular expression extractor
|
||||
* @param pattern reg exp pattern to extract target branch from label name
|
||||
* @param labels list of labels to check
|
||||
* @returns list of target branches
|
||||
*/
|
||||
getTargetBranchesFromLabels(pattern, labels) {
|
||||
this.logger.debug(`Extracting branches from [${labels}] using ${pattern}`);
|
||||
const regExp = new RegExp(pattern);
|
||||
const branches = [];
|
||||
for (const l of labels) {
|
||||
const result = regExp.exec(l);
|
||||
if (result?.groups) {
|
||||
const { target } = result.groups;
|
||||
if (target) {
|
||||
branches.push(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
return [...new Set(branches)];
|
||||
}
|
||||
/**
|
||||
* Create a backport pull request starting from the target branch and
|
||||
* the original pr to be backported
|
||||
@@ -513,9 +559,14 @@ class GitCLIService {
|
||||
* @param cwd repository in which the sha should be cherry picked to
|
||||
* @param sha commit sha
|
||||
*/
|
||||
async cherryPick(cwd, sha, strategy = "recursive", strategyOption = "theirs") {
|
||||
async cherryPick(cwd, sha, strategy = "recursive", strategyOption = "theirs", cherryPickOptions) {
|
||||
this.logger.info(`Cherry picking ${sha}`);
|
||||
const options = ["cherry-pick", "-m", "1", `--strategy=${strategy}`, `--strategy-option=${strategyOption}`, sha];
|
||||
let options = ["cherry-pick", "-m", "1", `--strategy=${strategy}`, `--strategy-option=${strategyOption}`];
|
||||
if (cherryPickOptions !== undefined) {
|
||||
options = options.concat(cherryPickOptions.split(" "));
|
||||
}
|
||||
options.push(sha);
|
||||
this.logger.debug(`Cherry picking command git ${options}`);
|
||||
try {
|
||||
await this.git(cwd).raw(options);
|
||||
}
|
||||
@@ -1343,7 +1394,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);
|
||||
@@ -1412,8 +1469,8 @@ class Runner {
|
||||
}
|
||||
// 7. apply all changes to the new branch
|
||||
this.logger.debug("Cherry picking commits..");
|
||||
for (const sha of originalPR.commits) {
|
||||
await git.gitCli.cherryPick(configs.folder, sha, configs.mergeStrategy, configs.mergeStrategyOption);
|
||||
for (const sha of originalPR.commits.reverse()) {
|
||||
await git.gitCli.cherryPick(configs.folder, sha, configs.mergeStrategy, configs.mergeStrategyOption, configs.cherryPickOptions);
|
||||
}
|
||||
if (!configs.dryRun) {
|
||||
// 8. push the new branch to origin
|
||||
@@ -5882,6 +5939,7 @@ var preservedUrlFields = [
|
||||
"protocol",
|
||||
"query",
|
||||
"search",
|
||||
"hash",
|
||||
];
|
||||
|
||||
// Create handlers that pass events from native requests
|
||||
@@ -6315,7 +6373,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
||||
redirectUrl.protocol !== "https:" ||
|
||||
redirectUrl.host !== currentHost &&
|
||||
!isSubdomain(redirectUrl.host, currentHost)) {
|
||||
removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
|
||||
removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
|
||||
}
|
||||
|
||||
// Evaluate the beforeRedirect callback
|
||||
@@ -23687,7 +23745,7 @@ module.exports = axios;
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = JSON.parse('{"name":"@kie/git-backporting","version":"4.5.2","description":"Git backporting is a tool to execute automatic pull request git backporting.","author":"","license":"MIT","private":false,"main":"./dist/gha/index.js","bin":{"git-backporting":"./dist/cli/index.js"},"files":["dist/cli/index.js"],"publishConfig":{"access":"public"},"scripts":{"prepare":"husky install","clean":"rm -rf ./build ./dist","compile":"tsc -p tsconfig.json && tsc-alias -p tsconfig.json","package":"npm run package:cli && npm run package:gha","package:cli":"ncc build ./build/src/bin/cli.js -o dist/cli","package:gha":"ncc build ./build/src/bin/gha.js -o dist/gha","build":"npm run clean && npm run compile && npm run package","test":"jest --silent","test:report":"npm test -- --coverage --testResultsProcessor=jest-sonar-reporter","lint":"eslint . --ext .ts","lint:fix":"npm run lint -- --fix","ts-node":"ts-node","postversion":"npm run build && git add dist && rm -rf build","release":"release-it","release:branch":"git checkout -b release/$(release-it --release-version) main","release:prepare":"release-it --no-npm.publish --no-github.release --no-git.push --no-git.tag --no-git.requireUpstream","release:prepare:all":"npm run release:branch && npm run release:prepare"},"repository":{"type":"git","url":"git+https://github.com/kiegroup/git-backporting.git"},"keywords":["backporting","pull-requests","merge-requests","github-action","cherry-pick"],"bugs":{"url":"https://github.com/kiegroup/git-backporting/issues"},"homepage":"https://github.com/kiegroup/git-backporting#readme","devDependencies":{"@commitlint/cli":"^17.4.0","@commitlint/config-conventional":"^17.4.0","@gitbeaker/rest":"^39.1.0","@kie/mock-github":"^1.1.0","@octokit/webhooks-types":"^6.8.0","@release-it/conventional-changelog":"^7.0.0","@types/fs-extra":"^9.0.13","@types/jest":"^29.2.4","@types/node":"^18.11.17","@typescript-eslint/eslint-plugin":"^5.47.0","@typescript-eslint/parser":"^5.47.0","@vercel/ncc":"^0.36.0","eslint":"^8.30.0","husky":"^8.0.2","jest":"^29.0.0","jest-sonar-reporter":"^2.0.0","release-it":"^16.1.3","semver":"^7.3.8","ts-jest":"^29.0.0","ts-node":"^10.8.1","tsc-alias":"^1.8.2","tsconfig-paths":"^4.1.0","typescript":"^4.9.3"},"dependencies":{"@actions/core":"^1.10.0","@octokit/rest":"^18.12.0","axios":"^1.4.0","commander":"^9.3.0","fs-extra":"^11.1.0","https":"^1.0.0","simple-git":"^3.15.1"}}');
|
||||
module.exports = JSON.parse('{"name":"@kie/git-backporting","version":"4.7.1","description":"Git backporting is a tool to execute automatic pull request git backporting.","author":"","license":"MIT","private":false,"main":"./dist/gha/index.js","bin":{"git-backporting":"./dist/cli/index.js"},"files":["dist/cli/index.js"],"publishConfig":{"access":"public"},"scripts":{"prepare":"husky install","clean":"rm -rf ./build ./dist","compile":"tsc -p tsconfig.json && tsc-alias -p tsconfig.json","package":"npm run package:cli && npm run package:gha","package:cli":"ncc build ./build/src/bin/cli.js -o dist/cli","package:gha":"ncc build ./build/src/bin/gha.js -o dist/gha","build":"npm run clean && npm run compile && npm run package","test":"jest --silent","test:report":"npm test -- --coverage --testResultsProcessor=jest-sonar-reporter","lint":"eslint . --ext .ts","lint:fix":"npm run lint -- --fix","ts-node":"ts-node","postversion":"npm run build && git add dist && rm -rf build","release":"release-it","release:branch":"git checkout -b release/$(release-it --release-version) main","release:prepare":"release-it --no-npm.publish --no-github.release --no-git.push --no-git.tag --no-git.requireUpstream","release:prepare:all":"npm run release:branch && npm run release:prepare"},"repository":{"type":"git","url":"git+https://github.com/kiegroup/git-backporting.git"},"keywords":["backporting","pull-requests","merge-requests","github-action","cherry-pick"],"bugs":{"url":"https://github.com/kiegroup/git-backporting/issues"},"homepage":"https://github.com/kiegroup/git-backporting#readme","devDependencies":{"@commitlint/cli":"^17.4.0","@commitlint/config-conventional":"^17.4.0","@gitbeaker/rest":"^39.1.0","@kie/mock-github":"^1.1.0","@octokit/webhooks-types":"^6.8.0","@release-it/conventional-changelog":"^7.0.0","@types/fs-extra":"^9.0.13","@types/jest":"^29.2.4","@types/node":"^18.11.17","@typescript-eslint/eslint-plugin":"^5.47.0","@typescript-eslint/parser":"^5.47.0","@vercel/ncc":"^0.36.0","eslint":"^8.30.0","husky":"^8.0.2","jest":"^29.0.0","jest-sonar-reporter":"^2.0.0","release-it":"^16.1.3","semver":"^7.3.8","ts-jest":"^29.0.0","ts-node":"^10.8.1","tsc-alias":"^1.8.2","tsconfig-paths":"^4.1.0","typescript":"^4.9.3"},"dependencies":{"@actions/core":"^1.10.0","@octokit/rest":"^18.12.0","axios":"^1.4.0","commander":"^9.3.0","fs-extra":"^11.1.0","https":"^1.0.0","simple-git":"^3.15.1"}}');
|
||||
|
||||
/***/ }),
|
||||
|
||||
|
||||
75
dist/gha/index.js
vendored
75
dist/gha/index.js
vendored
@@ -39,16 +39,21 @@ class ArgsParser {
|
||||
}
|
||||
parse() {
|
||||
const args = this.readArgs();
|
||||
if (!args.pullRequest) {
|
||||
throw new Error("Missing option: pull request must be provided");
|
||||
}
|
||||
// validate and fill with defaults
|
||||
if (!args.pullRequest || !args.targetBranch || args.targetBranch.trim().length == 0) {
|
||||
throw new Error("Missing option: pull request and target branches must be provided");
|
||||
if ((!args.targetBranch || args.targetBranch.trim().length == 0) && !args.targetBranchPattern) {
|
||||
throw new Error("Missing option: target branch(es) or target regular expression must be provided");
|
||||
}
|
||||
return {
|
||||
pullRequest: args.pullRequest,
|
||||
targetBranch: args.targetBranch,
|
||||
targetBranchPattern: args.targetBranchPattern,
|
||||
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),
|
||||
@@ -63,6 +68,7 @@ class ArgsParser {
|
||||
squash: this.getOrDefault(args.squash, true),
|
||||
strategy: this.getOrDefault(args.strategy),
|
||||
strategyOption: this.getOrDefault(args.strategyOption),
|
||||
cherryPickOptions: this.getOrDefault(args.cherryPickOptions),
|
||||
comments: this.getOrDefault(args.comments)
|
||||
};
|
||||
}
|
||||
@@ -185,8 +191,10 @@ class GHAArgsParser extends args_parser_1.default {
|
||||
dryRun: (0, args_utils_1.getAsBooleanOrDefault)((0, core_1.getInput)("dry-run")),
|
||||
auth: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("auth")),
|
||||
pullRequest: (0, core_1.getInput)("pull-request"),
|
||||
targetBranch: (0, core_1.getInput)("target-branch"),
|
||||
targetBranch: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("target-branch")),
|
||||
targetBranchPattern: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("target-branch-pattern")),
|
||||
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")),
|
||||
@@ -201,6 +209,7 @@ class GHAArgsParser extends args_parser_1.default {
|
||||
squash: !(0, args_utils_1.getAsBooleanOrDefault)((0, core_1.getInput)("no-squash")),
|
||||
strategy: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("strategy")),
|
||||
strategyOption: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("strategy-option")),
|
||||
cherryPickOptions: (0, args_utils_1.getOrUndefined)((0, core_1.getInput)("cherry-pick-options")),
|
||||
comments: (0, args_utils_1.getAsSemicolonSeparatedList)((0, core_1.getInput)("comments")),
|
||||
};
|
||||
}
|
||||
@@ -298,7 +307,18 @@ class PullRequestConfigsParser extends configs_parser_1.default {
|
||||
throw error;
|
||||
}
|
||||
const folder = args.folder ?? this.getDefaultFolder();
|
||||
const targetBranches = [...new Set((0, args_utils_1.getAsCommaSeparatedList)(args.targetBranch))];
|
||||
let targetBranches = [];
|
||||
if (args.targetBranchPattern) {
|
||||
// parse labels to extract target branch(es)
|
||||
targetBranches = this.getTargetBranchesFromLabels(args.targetBranchPattern, pr.labels);
|
||||
if (targetBranches.length === 0) {
|
||||
throw new Error(`Unable to extract target branches with regular expression "${args.targetBranchPattern}"`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// target branch must be provided if targetRegExp is missing
|
||||
targetBranches = [...new Set((0, args_utils_1.getAsCommaSeparatedList)(args.targetBranch))];
|
||||
}
|
||||
const bpBranchNames = [...new Set(args.bpBranchName ? ((0, args_utils_1.getAsCleanedCommaSeparatedList)(args.bpBranchName) ?? []) : [])];
|
||||
if (bpBranchNames.length > 1 && bpBranchNames.length != targetBranches.length) {
|
||||
throw new Error(`The number of backport branch names, if provided, must match the number of target branches or just one, provided ${bpBranchNames.length} branch names instead`);
|
||||
@@ -309,6 +329,7 @@ class PullRequestConfigsParser extends configs_parser_1.default {
|
||||
folder: `${folder.startsWith("/") ? "" : process.cwd() + "/"}${args.folder ?? this.getDefaultFolder()}`,
|
||||
mergeStrategy: args.strategy,
|
||||
mergeStrategyOption: args.strategyOption,
|
||||
cherryPickOptions: args.cherryPickOptions,
|
||||
originalPullRequest: pr,
|
||||
backportPullRequests: this.generateBackportPullRequestsData(pr, args, targetBranches, bpBranchNames),
|
||||
git: {
|
||||
@@ -320,6 +341,28 @@ class PullRequestConfigsParser extends configs_parser_1.default {
|
||||
getDefaultFolder() {
|
||||
return "bp";
|
||||
}
|
||||
/**
|
||||
* Parse the provided labels and return a list of target branches
|
||||
* obtained by applying the provided pattern as regular expression extractor
|
||||
* @param pattern reg exp pattern to extract target branch from label name
|
||||
* @param labels list of labels to check
|
||||
* @returns list of target branches
|
||||
*/
|
||||
getTargetBranchesFromLabels(pattern, labels) {
|
||||
this.logger.debug(`Extracting branches from [${labels}] using ${pattern}`);
|
||||
const regExp = new RegExp(pattern);
|
||||
const branches = [];
|
||||
for (const l of labels) {
|
||||
const result = regExp.exec(l);
|
||||
if (result?.groups) {
|
||||
const { target } = result.groups;
|
||||
if (target) {
|
||||
branches.push(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
return [...new Set(branches)];
|
||||
}
|
||||
/**
|
||||
* Create a backport pull request starting from the target branch and
|
||||
* the original pr to be backported
|
||||
@@ -483,9 +526,14 @@ class GitCLIService {
|
||||
* @param cwd repository in which the sha should be cherry picked to
|
||||
* @param sha commit sha
|
||||
*/
|
||||
async cherryPick(cwd, sha, strategy = "recursive", strategyOption = "theirs") {
|
||||
async cherryPick(cwd, sha, strategy = "recursive", strategyOption = "theirs", cherryPickOptions) {
|
||||
this.logger.info(`Cherry picking ${sha}`);
|
||||
const options = ["cherry-pick", "-m", "1", `--strategy=${strategy}`, `--strategy-option=${strategyOption}`, sha];
|
||||
let options = ["cherry-pick", "-m", "1", `--strategy=${strategy}`, `--strategy-option=${strategyOption}`];
|
||||
if (cherryPickOptions !== undefined) {
|
||||
options = options.concat(cherryPickOptions.split(" "));
|
||||
}
|
||||
options.push(sha);
|
||||
this.logger.debug(`Cherry picking command git ${options}`);
|
||||
try {
|
||||
await this.git(cwd).raw(options);
|
||||
}
|
||||
@@ -1313,7 +1361,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);
|
||||
@@ -1382,8 +1436,8 @@ class Runner {
|
||||
}
|
||||
// 7. apply all changes to the new branch
|
||||
this.logger.debug("Cherry picking commits..");
|
||||
for (const sha of originalPR.commits) {
|
||||
await git.gitCli.cherryPick(configs.folder, sha, configs.mergeStrategy, configs.mergeStrategyOption);
|
||||
for (const sha of originalPR.commits.reverse()) {
|
||||
await git.gitCli.cherryPick(configs.folder, sha, configs.mergeStrategy, configs.mergeStrategyOption, configs.cherryPickOptions);
|
||||
}
|
||||
if (!configs.dryRun) {
|
||||
// 8. push the new branch to origin
|
||||
@@ -7613,6 +7667,7 @@ var preservedUrlFields = [
|
||||
"protocol",
|
||||
"query",
|
||||
"search",
|
||||
"hash",
|
||||
];
|
||||
|
||||
// Create handlers that pass events from native requests
|
||||
@@ -8046,7 +8101,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
||||
redirectUrl.protocol !== "https:" ||
|
||||
redirectUrl.host !== currentHost &&
|
||||
!isSubdomain(redirectUrl.host, currentHost)) {
|
||||
removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
|
||||
removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
|
||||
}
|
||||
|
||||
// Evaluate the beforeRedirect callback
|
||||
|
||||
92
package-lock.json
generated
92
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@kie/git-backporting",
|
||||
"version": "4.5.2",
|
||||
"version": "4.7.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@kie/git-backporting",
|
||||
"version": "4.5.2",
|
||||
"version": "4.7.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
@@ -2915,13 +2915,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/body-parser": {
|
||||
"version": "1.20.1",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
|
||||
"integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==",
|
||||
"version": "1.20.2",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz",
|
||||
"integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
"content-type": "~1.0.4",
|
||||
"content-type": "~1.0.5",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "1.2.0",
|
||||
@@ -2929,7 +2929,7 @@
|
||||
"iconv-lite": "0.4.24",
|
||||
"on-finished": "2.4.1",
|
||||
"qs": "6.11.0",
|
||||
"raw-body": "2.5.1",
|
||||
"raw-body": "2.5.2",
|
||||
"type-is": "~1.6.18",
|
||||
"unpipe": "1.0.0"
|
||||
},
|
||||
@@ -3632,9 +3632,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/content-type": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
|
||||
"integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==",
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
|
||||
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
@@ -4321,9 +4321,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/cookie": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz",
|
||||
"integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==",
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz",
|
||||
"integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
@@ -5364,17 +5364,17 @@
|
||||
}
|
||||
},
|
||||
"node_modules/express": {
|
||||
"version": "4.18.2",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz",
|
||||
"integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==",
|
||||
"version": "4.19.2",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz",
|
||||
"integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.8",
|
||||
"array-flatten": "1.1.1",
|
||||
"body-parser": "1.20.1",
|
||||
"body-parser": "1.20.2",
|
||||
"content-disposition": "0.5.4",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "0.5.0",
|
||||
"cookie": "0.6.0",
|
||||
"cookie-signature": "1.0.6",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
@@ -5642,9 +5642,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.4",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz",
|
||||
"integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==",
|
||||
"version": "1.15.6",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
|
||||
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
@@ -9501,9 +9501,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/raw-body": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz",
|
||||
"integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==",
|
||||
"version": "2.5.2",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
|
||||
"integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
@@ -14018,13 +14018,13 @@
|
||||
}
|
||||
},
|
||||
"body-parser": {
|
||||
"version": "1.20.1",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
|
||||
"integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==",
|
||||
"version": "1.20.2",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz",
|
||||
"integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bytes": "3.1.2",
|
||||
"content-type": "~1.0.4",
|
||||
"content-type": "~1.0.5",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "1.2.0",
|
||||
@@ -14032,7 +14032,7 @@
|
||||
"iconv-lite": "0.4.24",
|
||||
"on-finished": "2.4.1",
|
||||
"qs": "6.11.0",
|
||||
"raw-body": "2.5.1",
|
||||
"raw-body": "2.5.2",
|
||||
"type-is": "~1.6.18",
|
||||
"unpipe": "1.0.0"
|
||||
},
|
||||
@@ -14517,9 +14517,9 @@
|
||||
}
|
||||
},
|
||||
"content-type": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
|
||||
"integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==",
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
|
||||
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
|
||||
"dev": true
|
||||
},
|
||||
"conventional-changelog": {
|
||||
@@ -14985,9 +14985,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"cookie": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz",
|
||||
"integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==",
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz",
|
||||
"integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==",
|
||||
"dev": true
|
||||
},
|
||||
"cookie-signature": {
|
||||
@@ -15726,17 +15726,17 @@
|
||||
}
|
||||
},
|
||||
"express": {
|
||||
"version": "4.18.2",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz",
|
||||
"integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==",
|
||||
"version": "4.19.2",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz",
|
||||
"integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"accepts": "~1.3.8",
|
||||
"array-flatten": "1.1.1",
|
||||
"body-parser": "1.20.1",
|
||||
"body-parser": "1.20.2",
|
||||
"content-disposition": "0.5.4",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "0.5.0",
|
||||
"cookie": "0.6.0",
|
||||
"cookie-signature": "1.0.6",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
@@ -15957,9 +15957,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"follow-redirects": {
|
||||
"version": "1.15.4",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz",
|
||||
"integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw=="
|
||||
"version": "1.15.6",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
|
||||
"integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA=="
|
||||
},
|
||||
"for-each": {
|
||||
"version": "0.3.3",
|
||||
@@ -18708,9 +18708,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"raw-body": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz",
|
||||
"integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==",
|
||||
"version": "2.5.2",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
|
||||
"integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bytes": "3.1.2",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@kie/git-backporting",
|
||||
"version": "4.5.2",
|
||||
"version": "4.7.1",
|
||||
"description": "Git backporting is a tool to execute automatic pull request git backporting.",
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -16,17 +16,22 @@ export default abstract class ArgsParser {
|
||||
public parse(): Args {
|
||||
const args = this.readArgs();
|
||||
|
||||
if (!args.pullRequest) {
|
||||
throw new Error("Missing option: pull request must be provided");
|
||||
}
|
||||
// validate and fill with defaults
|
||||
if (!args.pullRequest || !args.targetBranch || args.targetBranch.trim().length == 0) {
|
||||
throw new Error("Missing option: pull request and target branches must be provided");
|
||||
if ((!args.targetBranch || args.targetBranch.trim().length == 0) && !args.targetBranchPattern) {
|
||||
throw new Error("Missing option: target branch(es) or target regular expression must be provided");
|
||||
}
|
||||
|
||||
return {
|
||||
pullRequest: args.pullRequest,
|
||||
targetBranch: args.targetBranch,
|
||||
targetBranchPattern: args.targetBranchPattern,
|
||||
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),
|
||||
@@ -41,6 +46,7 @@ export default abstract class ArgsParser {
|
||||
squash: this.getOrDefault(args.squash, true),
|
||||
strategy: this.getOrDefault(args.strategy),
|
||||
strategyOption: this.getOrDefault(args.strategyOption),
|
||||
cherryPickOptions: this.getOrDefault(args.cherryPickOptions),
|
||||
comments: this.getOrDefault(args.comments)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
*/
|
||||
export interface Args {
|
||||
// NOTE: keep targetBranch as singular and of type string for backward compatibilities
|
||||
targetBranch: string, // comma separated list of branches on the target repo where the change should be backported to
|
||||
targetBranch?: string, // comma separated list of branches on the target repo where the change should be backported to
|
||||
targetBranchPattern?: string, // regular expression to extract target branch(es) from pull request labels
|
||||
pullRequest: string, // url of the pull request to backport
|
||||
dryRun?: boolean, // if enabled do not push anything remotely
|
||||
auth?: string, // git service auth, like github token
|
||||
folder?: string, // local folder where the repositories should be cloned
|
||||
gitClient?: string, // git client
|
||||
gitUser?: string, // local git user, default 'GitHub'
|
||||
gitEmail?: string, // local git email, default 'noreply@github.com'
|
||||
title?: string, // backport pr title, default original pr title prefixed by target branch
|
||||
@@ -23,5 +25,6 @@ export interface Args {
|
||||
squash?: boolean, // if false use squashed/merged commit otherwise backport all commits as part of the pr
|
||||
strategy?: string, // cherry-pick merge strategy
|
||||
strategyOption?: string, // cherry-pick merge strategy option
|
||||
cherryPickOptions?: string, // additional cherry-pick options
|
||||
comments?: string[], // additional comments to be posted
|
||||
}
|
||||
@@ -11,9 +11,11 @@ export default class CLIArgsParser extends ArgsParser {
|
||||
.version(version)
|
||||
.description(description)
|
||||
.option("-tb, --target-branch <branches>", "comma separated list of branches where changes must be backported to")
|
||||
.option("-tbp, --target-branch-pattern <pattern>", "regular expression pattern to extract target branch(es) from pr labels, the branches will be extracted from the pattern's required `target` named capturing group")
|
||||
.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")
|
||||
@@ -29,6 +31,7 @@ export default class CLIArgsParser extends ArgsParser {
|
||||
.option("--no-squash", "if provided the tool will backport all commits as part of the pull request")
|
||||
.option("--strategy <strategy>", "cherry-pick merge strategy, default to 'recursive'", undefined)
|
||||
.option("--strategy-option <strategy-option>", "cherry-pick merge strategy option, default to 'theirs'")
|
||||
.option("--cherry-pick-options <options>", "additional cherry-pick options")
|
||||
.option("--comments <comments>", "semicolon separated list of additional comments to be posted to the backported pull request", getAsSemicolonSeparatedList)
|
||||
.option("-cf, --config-file <config-file>", "configuration file containing all valid options, the json must match Args interface");
|
||||
}
|
||||
@@ -48,7 +51,9 @@ export default class CLIArgsParser extends ArgsParser {
|
||||
auth: opts.auth,
|
||||
pullRequest: opts.pullRequest,
|
||||
targetBranch: opts.targetBranch,
|
||||
targetBranchPattern: opts.targetBranchPattern,
|
||||
folder: opts.folder,
|
||||
gitClient: opts.gitClient,
|
||||
gitUser: opts.gitUser,
|
||||
gitEmail: opts.gitEmail,
|
||||
title: opts.title,
|
||||
@@ -63,6 +68,7 @@ export default class CLIArgsParser extends ArgsParser {
|
||||
squash: opts.squash,
|
||||
strategy: opts.strategy,
|
||||
strategyOption: opts.strategyOption,
|
||||
cherryPickOptions: opts.cherryPickOptions,
|
||||
comments: opts.comments,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,8 +16,10 @@ export default class GHAArgsParser extends ArgsParser {
|
||||
dryRun: getAsBooleanOrDefault(getInput("dry-run")),
|
||||
auth: getOrUndefined(getInput("auth")),
|
||||
pullRequest: getInput("pull-request"),
|
||||
targetBranch: getInput("target-branch"),
|
||||
targetBranch: getOrUndefined(getInput("target-branch")),
|
||||
targetBranchPattern: getOrUndefined(getInput("target-branch-pattern")),
|
||||
folder: getOrUndefined(getInput("folder")),
|
||||
gitClient: getOrUndefined(getInput("git-client")),
|
||||
gitUser: getOrUndefined(getInput("git-user")),
|
||||
gitEmail: getOrUndefined(getInput("git-email")),
|
||||
title: getOrUndefined(getInput("title")),
|
||||
@@ -32,6 +34,7 @@ export default class GHAArgsParser extends ArgsParser {
|
||||
squash: !getAsBooleanOrDefault(getInput("no-squash")),
|
||||
strategy: getOrUndefined(getInput("strategy")),
|
||||
strategyOption: getOrUndefined(getInput("strategy-option")),
|
||||
cherryPickOptions: getOrUndefined(getInput("cherry-pick-options")),
|
||||
comments: getAsSemicolonSeparatedList(getInput("comments")),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ export interface Configs {
|
||||
folder: string,
|
||||
mergeStrategy?: string, // cherry-pick merge strategy
|
||||
mergeStrategyOption?: string, // cherry-pick merge strategy option
|
||||
cherryPickOptions?: string, // additional cherry-pick options
|
||||
originalPullRequest: GitPullRequest,
|
||||
backportPullRequests: BackportPullRequest[],
|
||||
}
|
||||
|
||||
@@ -26,7 +26,17 @@ export default class PullRequestConfigsParser extends ConfigsParser {
|
||||
|
||||
const folder: string = args.folder ?? this.getDefaultFolder();
|
||||
|
||||
const targetBranches: string[] = [...new Set(getAsCommaSeparatedList(args.targetBranch)!)];
|
||||
let targetBranches: string[] = [];
|
||||
if (args.targetBranchPattern) {
|
||||
// parse labels to extract target branch(es)
|
||||
targetBranches = this.getTargetBranchesFromLabels(args.targetBranchPattern, pr.labels);
|
||||
if (targetBranches.length === 0) {
|
||||
throw new Error(`Unable to extract target branches with regular expression "${args.targetBranchPattern}"`);
|
||||
}
|
||||
} else {
|
||||
// target branch must be provided if targetRegExp is missing
|
||||
targetBranches = [...new Set(getAsCommaSeparatedList(args.targetBranch!)!)];
|
||||
}
|
||||
const bpBranchNames: string[] = [...new Set(args.bpBranchName ? (getAsCleanedCommaSeparatedList(args.bpBranchName) ?? []) : [])];
|
||||
|
||||
if (bpBranchNames.length > 1 && bpBranchNames.length != targetBranches.length) {
|
||||
@@ -39,6 +49,7 @@ export default class PullRequestConfigsParser extends ConfigsParser {
|
||||
folder: `${folder.startsWith("/") ? "" : process.cwd() + "/"}${args.folder ?? this.getDefaultFolder()}`,
|
||||
mergeStrategy: args.strategy,
|
||||
mergeStrategyOption: args.strategyOption,
|
||||
cherryPickOptions: args.cherryPickOptions,
|
||||
originalPullRequest: pr,
|
||||
backportPullRequests: this.generateBackportPullRequestsData(pr, args, targetBranches, bpBranchNames),
|
||||
git: {
|
||||
@@ -52,6 +63,33 @@ export default class PullRequestConfigsParser extends ConfigsParser {
|
||||
return "bp";
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the provided labels and return a list of target branches
|
||||
* obtained by applying the provided pattern as regular expression extractor
|
||||
* @param pattern reg exp pattern to extract target branch from label name
|
||||
* @param labels list of labels to check
|
||||
* @returns list of target branches
|
||||
*/
|
||||
private getTargetBranchesFromLabels(pattern: string, labels: string[]): string[] {
|
||||
this.logger.debug(`Extracting branches from [${labels}] using ${pattern}`);
|
||||
const regExp = new RegExp(pattern);
|
||||
|
||||
const branches: string[] = [];
|
||||
for (const l of labels) {
|
||||
const result = regExp.exec(l);
|
||||
|
||||
if (result?.groups) {
|
||||
const { target } = result.groups;
|
||||
if (target){
|
||||
branches.push(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return [...new Set(branches)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a backport pull request starting from the target branch and
|
||||
* the original pr to be backported
|
||||
|
||||
@@ -110,10 +110,15 @@ export default class GitCLIService {
|
||||
* @param cwd repository in which the sha should be cherry picked to
|
||||
* @param sha commit sha
|
||||
*/
|
||||
async cherryPick(cwd: string, sha: string, strategy = "recursive", strategyOption = "theirs"): Promise<void> {
|
||||
async cherryPick(cwd: string, sha: string, strategy = "recursive", strategyOption = "theirs", cherryPickOptions: string | undefined): Promise<void> {
|
||||
this.logger.info(`Cherry picking ${sha}`);
|
||||
|
||||
const options = ["cherry-pick", "-m", "1", `--strategy=${strategy}`, `--strategy-option=${strategyOption}`, sha];
|
||||
let options = ["cherry-pick", "-m", "1", `--strategy=${strategy}`, `--strategy-option=${strategyOption}`];
|
||||
if (cherryPickOptions !== undefined) {
|
||||
options = options.concat(cherryPickOptions.split(" "));
|
||||
}
|
||||
options.push(sha);
|
||||
this.logger.debug(`Cherry picking command git ${options}`);
|
||||
try {
|
||||
await this.git(cwd).raw(options);
|
||||
} catch(error) {
|
||||
|
||||
@@ -60,7 +60,12 @@ export default class Runner {
|
||||
}
|
||||
|
||||
// 2. init git service
|
||||
const gitClientType: GitClientType = inferGitClient(args.pullRequest);
|
||||
let gitClientType: GitClientType;
|
||||
if (args.gitClient === undefined) {
|
||||
gitClientType = inferGitClient(args.pullRequest);
|
||||
} else {
|
||||
gitClientType = args.gitClient as GitClientType;
|
||||
}
|
||||
// the api version is ignored in case of github
|
||||
const apiUrl = inferGitApiUrl(args.pullRequest, gitClientType === GitClientType.CODEBERG ? "v1" : undefined);
|
||||
const token = this.fetchToken(args, gitClientType);
|
||||
@@ -141,8 +146,8 @@ export default class Runner {
|
||||
|
||||
// 7. apply all changes to the new branch
|
||||
this.logger.debug("Cherry picking commits..");
|
||||
for (const sha of originalPR.commits!) {
|
||||
await git.gitCli.cherryPick(configs.folder, sha, configs.mergeStrategy, configs.mergeStrategyOption);
|
||||
for (const sha of originalPR.commits.reverse()!) {
|
||||
await git.gitCli.cherryPick(configs.folder, sha, configs.mergeStrategy, configs.mergeStrategyOption, configs.cherryPickOptions);
|
||||
}
|
||||
|
||||
if (!configs.dryRun) {
|
||||
|
||||
@@ -15,6 +15,7 @@ const RANDOM_CONFIG_FILE_CONTENT = {
|
||||
"targetBranch": "target-branch-name",
|
||||
"pullRequest": "https://github.com/user/repo/pull/123",
|
||||
"folder": "/path/to/local/folder",
|
||||
"gitClient": "codeberg",
|
||||
"gitUser": "YourGitUser",
|
||||
"gitEmail": "your-email@example.com",
|
||||
"title": "Backport: Original PR Title",
|
||||
@@ -62,6 +63,7 @@ describe("cli args parser", () => {
|
||||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(false);
|
||||
expect(args.auth).toEqual(undefined);
|
||||
expect(args.gitClient).toEqual(undefined);
|
||||
expect(args.gitUser).toEqual(undefined);
|
||||
expect(args.gitEmail).toEqual(undefined);
|
||||
expect(args.folder).toEqual(undefined);
|
||||
@@ -79,6 +81,7 @@ describe("cli args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual(undefined);
|
||||
expect(args.strategyOption).toEqual(undefined);
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("with config file [default, short]", () => {
|
||||
@@ -90,6 +93,7 @@ describe("cli args parser", () => {
|
||||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(false);
|
||||
expect(args.auth).toEqual(undefined);
|
||||
expect(args.gitClient).toEqual(undefined);
|
||||
expect(args.gitUser).toEqual(undefined);
|
||||
expect(args.gitEmail).toEqual(undefined);
|
||||
expect(args.folder).toEqual(undefined);
|
||||
@@ -107,6 +111,7 @@ describe("cli args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual(undefined);
|
||||
expect(args.strategyOption).toEqual(undefined);
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("valid execution [default, long]", () => {
|
||||
@@ -120,6 +125,7 @@ describe("cli args parser", () => {
|
||||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(false);
|
||||
expect(args.auth).toEqual(undefined);
|
||||
expect(args.gitClient).toEqual(undefined);
|
||||
expect(args.gitUser).toEqual(undefined);
|
||||
expect(args.gitEmail).toEqual(undefined);
|
||||
expect(args.folder).toEqual(undefined);
|
||||
@@ -137,6 +143,7 @@ describe("cli args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual(undefined);
|
||||
expect(args.strategyOption).toEqual(undefined);
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("with config file [default, long]", () => {
|
||||
@@ -148,6 +155,7 @@ describe("cli args parser", () => {
|
||||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(false);
|
||||
expect(args.auth).toEqual(undefined);
|
||||
expect(args.gitClient).toEqual(undefined);
|
||||
expect(args.gitUser).toEqual(undefined);
|
||||
expect(args.gitEmail).toEqual(undefined);
|
||||
expect(args.folder).toEqual(undefined);
|
||||
@@ -165,6 +173,7 @@ describe("cli args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual(undefined);
|
||||
expect(args.strategyOption).toEqual(undefined);
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("valid execution [override, short]", () => {
|
||||
@@ -185,6 +194,7 @@ describe("cli args parser", () => {
|
||||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(true);
|
||||
expect(args.auth).toEqual("bearer-token");
|
||||
expect(args.gitClient).toEqual(undefined);
|
||||
expect(args.gitUser).toEqual("Me");
|
||||
expect(args.gitEmail).toEqual("me@email.com");
|
||||
expect(args.folder).toEqual(undefined);
|
||||
@@ -202,6 +212,7 @@ describe("cli args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual(undefined);
|
||||
expect(args.strategyOption).toEqual(undefined);
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("valid execution [override, long]", () => {
|
||||
@@ -213,6 +224,8 @@ describe("cli args parser", () => {
|
||||
"target",
|
||||
"--pull-request",
|
||||
"https://localhost/whatever/pulls/1",
|
||||
"--git-client",
|
||||
"codeberg",
|
||||
"--git-user",
|
||||
"Me",
|
||||
"--git-email",
|
||||
@@ -238,6 +251,7 @@ describe("cli args parser", () => {
|
||||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(true);
|
||||
expect(args.auth).toEqual("bearer-token");
|
||||
expect(args.gitClient).toEqual("codeberg");
|
||||
expect(args.gitUser).toEqual("Me");
|
||||
expect(args.gitEmail).toEqual("me@email.com");
|
||||
expect(args.folder).toEqual(undefined);
|
||||
@@ -255,6 +269,7 @@ describe("cli args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual(undefined);
|
||||
expect(args.strategyOption).toEqual(undefined);
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("override using config file", () => {
|
||||
@@ -266,6 +281,7 @@ describe("cli args parser", () => {
|
||||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(true);
|
||||
expect(args.auth).toEqual("your-git-service-auth-token");
|
||||
expect(args.gitClient).toEqual("codeberg");
|
||||
expect(args.gitUser).toEqual("YourGitUser");
|
||||
expect(args.gitEmail).toEqual("your-email@example.com");
|
||||
expect(args.folder).toEqual("/path/to/local/folder");
|
||||
@@ -283,6 +299,7 @@ describe("cli args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual(undefined);
|
||||
expect(args.strategyOption).toEqual(undefined);
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("ignore custom option when config file is set", () => {
|
||||
@@ -296,6 +313,8 @@ describe("cli args parser", () => {
|
||||
"target",
|
||||
"--pull-request",
|
||||
"https://localhost/whatever/pulls/1",
|
||||
"--git-client",
|
||||
"github",
|
||||
"--git-user",
|
||||
"Me",
|
||||
"--git-email",
|
||||
@@ -321,6 +340,7 @@ describe("cli args parser", () => {
|
||||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(true);
|
||||
expect(args.auth).toEqual("your-git-service-auth-token");
|
||||
expect(args.gitClient).toEqual("codeberg");
|
||||
expect(args.gitUser).toEqual("YourGitUser");
|
||||
expect(args.gitEmail).toEqual("your-email@example.com");
|
||||
expect(args.folder).toEqual("/path/to/local/folder");
|
||||
@@ -338,6 +358,7 @@ describe("cli args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual(undefined);
|
||||
expect(args.strategyOption).toEqual(undefined);
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("override squash to false", () => {
|
||||
@@ -352,6 +373,7 @@ describe("cli args parser", () => {
|
||||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(false);
|
||||
expect(args.auth).toEqual(undefined);
|
||||
expect(args.gitClient).toEqual(undefined);
|
||||
expect(args.gitUser).toEqual(undefined);
|
||||
expect(args.gitEmail).toEqual(undefined);
|
||||
expect(args.folder).toEqual(undefined);
|
||||
@@ -369,7 +391,7 @@ describe("cli args parser", () => {
|
||||
expect(args.squash).toEqual(false);
|
||||
});
|
||||
|
||||
test("override cherry pick strategies", () => {
|
||||
test("override cherry pick strategies and options", () => {
|
||||
addProcessArgs([
|
||||
"--target-branch",
|
||||
"target",
|
||||
@@ -379,11 +401,14 @@ describe("cli args parser", () => {
|
||||
"ort",
|
||||
"--strategy-option",
|
||||
"ours",
|
||||
"--cherry-pick-options",
|
||||
"--allow-empty -x",
|
||||
]);
|
||||
|
||||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(false);
|
||||
expect(args.auth).toEqual(undefined);
|
||||
expect(args.gitClient).toEqual(undefined);
|
||||
expect(args.gitUser).toEqual(undefined);
|
||||
expect(args.gitEmail).toEqual(undefined);
|
||||
expect(args.folder).toEqual(undefined);
|
||||
@@ -401,6 +426,7 @@ describe("cli args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual("ort");
|
||||
expect(args.strategyOption).toEqual("ours");
|
||||
expect(args.cherryPickOptions).toEqual("--allow-empty -x");
|
||||
});
|
||||
|
||||
test("additional pr comments", () => {
|
||||
@@ -416,6 +442,7 @@ describe("cli args parser", () => {
|
||||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(false);
|
||||
expect(args.auth).toEqual(undefined);
|
||||
expect(args.gitClient).toEqual(undefined);
|
||||
expect(args.gitUser).toEqual(undefined);
|
||||
expect(args.gitEmail).toEqual(undefined);
|
||||
expect(args.folder).toEqual(undefined);
|
||||
@@ -445,6 +472,7 @@ describe("cli args parser", () => {
|
||||
const args: Args = parser.parse();
|
||||
expect(args.dryRun).toEqual(false);
|
||||
expect(args.auth).toEqual(undefined);
|
||||
expect(args.gitClient).toEqual(undefined);
|
||||
expect(args.gitUser).toEqual(undefined);
|
||||
expect(args.gitEmail).toEqual(undefined);
|
||||
expect(args.folder).toEqual(undefined);
|
||||
@@ -462,6 +490,7 @@ describe("cli args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual(undefined);
|
||||
expect(args.strategyOption).toEqual(undefined);
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("invalid execution with empty target branch", () => {
|
||||
@@ -472,7 +501,7 @@ describe("cli args parser", () => {
|
||||
"https://localhost/whatever/pulls/1"
|
||||
]);
|
||||
|
||||
expect(() => parser.parse()).toThrowError("Missing option: pull request and target branches must be provided");
|
||||
expect(() => parser.parse()).toThrowError("Missing option: target branch(es) or target regular expression must be provided");
|
||||
});
|
||||
|
||||
test("invalid execution with missing mandatory target branch", () => {
|
||||
@@ -481,15 +510,15 @@ describe("cli args parser", () => {
|
||||
"https://localhost/whatever/pulls/1"
|
||||
]);
|
||||
|
||||
expect(() => parser.parse()).toThrowError("Missing option: pull request and target branches must be provided");
|
||||
expect(() => parser.parse()).toThrowError("Missing option: target branch(es) or target regular expression must be provided");
|
||||
});
|
||||
|
||||
test("invalid execution with missin mandatory pull request", () => {
|
||||
test("invalid execution with missing mandatory pull request", () => {
|
||||
addProcessArgs([
|
||||
"-tb",
|
||||
"target",
|
||||
]);
|
||||
|
||||
expect(() => parser.parse()).toThrowError("Missing option: pull request and target branches must be provided");
|
||||
expect(() => parser.parse()).toThrowError("Missing option: pull request must be provided");
|
||||
});
|
||||
});
|
||||
@@ -72,6 +72,7 @@ describe("gha args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual(undefined);
|
||||
expect(args.strategyOption).toEqual(undefined);
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("valid execution [override]", () => {
|
||||
@@ -113,6 +114,7 @@ describe("gha args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual(undefined);
|
||||
expect(args.strategyOption).toEqual(undefined);
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("using config file", () => {
|
||||
@@ -140,6 +142,7 @@ describe("gha args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual(undefined);
|
||||
expect(args.strategyOption).toEqual(undefined);
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("ignore custom options when using config file", () => {
|
||||
@@ -182,6 +185,7 @@ describe("gha args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual(undefined);
|
||||
expect(args.strategyOption).toEqual(undefined);
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("override squash to false", () => {
|
||||
@@ -235,6 +239,7 @@ describe("gha args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual("ort");
|
||||
expect(args.strategyOption).toEqual("ours");
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("additional pr comments", () => {
|
||||
@@ -287,6 +292,7 @@ describe("gha args parser", () => {
|
||||
expect(args.squash).toEqual(true);
|
||||
expect(args.strategy).toEqual(undefined);
|
||||
expect(args.strategyOption).toEqual(undefined);
|
||||
expect(args.cherryPickOptions).toEqual(undefined);
|
||||
});
|
||||
|
||||
|
||||
@@ -296,7 +302,7 @@ describe("gha args parser", () => {
|
||||
"pull-request": "https://localhost/whatever/pulls/1"
|
||||
});
|
||||
|
||||
expect(() => parser.parse()).toThrowError("Missing option: pull request and target branches must be provided");
|
||||
expect(() => parser.parse()).toThrowError("Missing option: target branch(es) or target regular expression must be provided");
|
||||
});
|
||||
|
||||
test("invalid execution with missing mandatory target branch", () => {
|
||||
@@ -304,7 +310,7 @@ describe("gha args parser", () => {
|
||||
"pull-request": "https://localhost/whatever/pulls/1"
|
||||
});
|
||||
|
||||
expect(() => parser.parse()).toThrowError("Missing option: pull request and target branches must be provided");
|
||||
expect(() => parser.parse()).toThrowError("Missing option: target branch(es) or target regular expression must be provided");
|
||||
});
|
||||
|
||||
test("invalid execution with missin mandatory pull request", () => {
|
||||
@@ -312,6 +318,6 @@ describe("gha args parser", () => {
|
||||
"target-branch": "target,old",
|
||||
});
|
||||
|
||||
expect(() => parser.parse()).toThrowError("Missing option: pull request and target branches must be provided");
|
||||
expect(() => parser.parse()).toThrowError("Missing option: pull request must be provided");
|
||||
});
|
||||
});
|
||||
@@ -353,7 +353,78 @@ describe("github pull request config parser", () => {
|
||||
dryRun: false,
|
||||
auth: "",
|
||||
pullRequest: multipleCommitsPRUrl,
|
||||
targetBranch: "v1, v2, v3",
|
||||
targetBranch: "v4, v5, v6",
|
||||
gitUser: "GitHub",
|
||||
gitEmail: "noreply@github.com",
|
||||
reviewers: [],
|
||||
assignees: [],
|
||||
inheritReviewers: true,
|
||||
squash: false,
|
||||
};
|
||||
|
||||
const configs: Configs = await configParser.parseAndValidate(args);
|
||||
|
||||
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
|
||||
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 8632, false);
|
||||
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
|
||||
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), ["0404fb922ab75c3a8aecad5c97d9af388df04695", "11da4e38aa3e577ffde6d546f1c52e53b04d3151"]);
|
||||
|
||||
expect(configs.dryRun).toEqual(false);
|
||||
expect(configs.git).toEqual({
|
||||
user: "GitHub",
|
||||
email: "noreply@github.com"
|
||||
});
|
||||
expect(configs.auth).toEqual("");
|
||||
expect(configs.folder).toEqual(process.cwd() + "/bp");
|
||||
expect(configs.backportPullRequests.length).toEqual(3);
|
||||
expect(configs.backportPullRequests).toEqual(
|
||||
expect.arrayContaining([
|
||||
{
|
||||
owner: "owner",
|
||||
repo: "reponame",
|
||||
head: "bp-v4-0404fb9-11da4e3",
|
||||
base: "v4",
|
||||
title: "[v4] PR Title",
|
||||
body: "**Backport:** https://github.com/owner/reponame/pull/8632\r\n\r\nPlease review and merge",
|
||||
reviewers: ["gh-user", "that-s-a-user"],
|
||||
assignees: [],
|
||||
labels: [],
|
||||
comments: [],
|
||||
},
|
||||
{
|
||||
owner: "owner",
|
||||
repo: "reponame",
|
||||
head: "bp-v5-0404fb9-11da4e3",
|
||||
base: "v5",
|
||||
title: "[v5] PR Title",
|
||||
body: "**Backport:** https://github.com/owner/reponame/pull/8632\r\n\r\nPlease review and merge",
|
||||
reviewers: ["gh-user", "that-s-a-user"],
|
||||
assignees: [],
|
||||
labels: [],
|
||||
comments: [],
|
||||
},
|
||||
{
|
||||
owner: "owner",
|
||||
repo: "reponame",
|
||||
head: "bp-v6-0404fb9-11da4e3",
|
||||
base: "v6",
|
||||
title: "[v6] PR Title",
|
||||
body: "**Backport:** https://github.com/owner/reponame/pull/8632\r\n\r\nPlease review and merge",
|
||||
reviewers: ["gh-user", "that-s-a-user"],
|
||||
assignees: [],
|
||||
labels: [],
|
||||
comments: [],
|
||||
},
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
test("multiple extracted branches and multiple commits", async () => {
|
||||
const args: Args = {
|
||||
dryRun: false,
|
||||
auth: "",
|
||||
pullRequest: multipleCommitsPRUrl,
|
||||
targetBranchPattern: "^backport (?<target>([^ ]+))$",
|
||||
gitUser: "GitHub",
|
||||
gitEmail: "noreply@github.com",
|
||||
reviewers: [],
|
||||
|
||||
@@ -112,7 +112,7 @@ describe("github pull request config parser", () => {
|
||||
body: "Please review and merge",
|
||||
reviewers: ["requested-gh-user", "gh-user"],
|
||||
assignees: [],
|
||||
labels: ["original-label"],
|
||||
labels: ["backport prod"],
|
||||
targetRepo: {
|
||||
owner: "owner",
|
||||
project: "reponame",
|
||||
@@ -281,7 +281,7 @@ describe("github pull request config parser", () => {
|
||||
body: "Please review and merge",
|
||||
reviewers: ["requested-gh-user", "gh-user"],
|
||||
assignees: [],
|
||||
labels: ["original-label"],
|
||||
labels: ["backport prod"],
|
||||
targetRepo: {
|
||||
owner: "owner",
|
||||
project: "reponame",
|
||||
@@ -395,7 +395,7 @@ describe("github pull request config parser", () => {
|
||||
body: "Please review and merge",
|
||||
reviewers: ["requested-gh-user", "gh-user"],
|
||||
assignees: [],
|
||||
labels: ["original-label"],
|
||||
labels: ["backport prod"],
|
||||
targetRepo: {
|
||||
owner: "owner",
|
||||
project: "reponame",
|
||||
@@ -467,7 +467,7 @@ describe("github pull request config parser", () => {
|
||||
body: "Please review and merge",
|
||||
reviewers: ["requested-gh-user", "gh-user"],
|
||||
assignees: [],
|
||||
labels: ["original-label"],
|
||||
labels: ["backport prod"],
|
||||
targetRepo: {
|
||||
owner: "owner",
|
||||
project: "reponame",
|
||||
@@ -511,7 +511,7 @@ describe("github pull request config parser", () => {
|
||||
reviewers: [],
|
||||
assignees: ["user3", "user4"],
|
||||
inheritReviewers: false,
|
||||
labels: ["custom-label", "original-label"], // also include the one inherited
|
||||
labels: ["custom-label", "backport prod"], // also include the one inherited
|
||||
inheritLabels: true,
|
||||
};
|
||||
|
||||
@@ -541,7 +541,7 @@ describe("github pull request config parser", () => {
|
||||
body: "Please review and merge",
|
||||
reviewers: ["requested-gh-user", "gh-user"],
|
||||
assignees: [],
|
||||
labels: ["original-label"],
|
||||
labels: ["backport prod"],
|
||||
targetRepo: {
|
||||
owner: "owner",
|
||||
project: "reponame",
|
||||
@@ -566,7 +566,7 @@ describe("github pull request config parser", () => {
|
||||
body: "New Body Prefix -New Body",
|
||||
reviewers: [],
|
||||
assignees: ["user3", "user4"],
|
||||
labels: ["custom-label", "original-label"],
|
||||
labels: ["custom-label", "backport prod"],
|
||||
comments: [],
|
||||
});
|
||||
});
|
||||
@@ -604,7 +604,7 @@ describe("github pull request config parser", () => {
|
||||
body: "Please review and merge",
|
||||
reviewers: ["requested-gh-user", "gh-user"],
|
||||
assignees: [],
|
||||
labels: ["original-label"],
|
||||
labels: ["backport prod"],
|
||||
targetRepo: {
|
||||
owner: "owner",
|
||||
project: "reponame",
|
||||
@@ -666,7 +666,7 @@ describe("github pull request config parser", () => {
|
||||
body: "Please review and merge",
|
||||
reviewers: ["requested-gh-user", "gh-user"],
|
||||
assignees: [],
|
||||
labels: ["original-label"],
|
||||
labels: ["backport prod"],
|
||||
targetRepo: {
|
||||
owner: "owner",
|
||||
project: "reponame",
|
||||
@@ -691,7 +691,7 @@ describe("github pull request config parser", () => {
|
||||
body: "New Body Prefix -New Body",
|
||||
reviewers: ["user1", "user2"],
|
||||
assignees: ["user3", "user4"],
|
||||
labels: ["cherry-pick :cherries:", "original-label"],
|
||||
labels: ["cherry-pick :cherries:", "backport prod"],
|
||||
comments: [],
|
||||
});
|
||||
});
|
||||
@@ -736,7 +736,11 @@ describe("github pull request config parser", () => {
|
||||
body: "Please review and merge",
|
||||
reviewers: ["requested-gh-user", "gh-user"],
|
||||
assignees: [],
|
||||
labels: [],
|
||||
labels: [
|
||||
"backport v1",
|
||||
"backport v2",
|
||||
"backport v3",
|
||||
],
|
||||
targetRepo: {
|
||||
owner: "owner",
|
||||
project: "reponame",
|
||||
@@ -810,7 +814,104 @@ describe("github pull request config parser", () => {
|
||||
body: "Please review and merge",
|
||||
reviewers: ["requested-gh-user", "gh-user"],
|
||||
assignees: [],
|
||||
labels: ["original-label"],
|
||||
labels: ["backport prod"],
|
||||
targetRepo: {
|
||||
owner: "owner",
|
||||
project: "reponame",
|
||||
cloneUrl: "https://github.com/owner/reponame.git"
|
||||
},
|
||||
sourceRepo: {
|
||||
owner: "fork",
|
||||
project: "reponame",
|
||||
cloneUrl: "https://github.com/fork/reponame.git"
|
||||
},
|
||||
bpBranchName: undefined,
|
||||
nCommits: 2,
|
||||
commits: ["28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc"],
|
||||
});
|
||||
expect(configs.backportPullRequests.length).toEqual(1);
|
||||
expect(configs.backportPullRequests[0]).toEqual({
|
||||
owner: "owner",
|
||||
repo: "reponame",
|
||||
head: "bp-prod-28f63db",
|
||||
base: "prod",
|
||||
title: "New Title",
|
||||
body: "New Body Prefix -New Body",
|
||||
reviewers: [],
|
||||
assignees: ["user3", "user4"],
|
||||
labels: [],
|
||||
comments: ["First comment", "Second comment"],
|
||||
});
|
||||
});
|
||||
|
||||
test("no extracted target branches from pr labels due to wrong group name", async () => {
|
||||
const args: Args = {
|
||||
dryRun: false,
|
||||
auth: "",
|
||||
pullRequest: mergedPRUrl,
|
||||
targetBranchPattern: "^backport (?<wrong>([^ ]+))$",
|
||||
gitUser: "Me",
|
||||
gitEmail: "me@email.com",
|
||||
title: "New Title",
|
||||
body: "New Body",
|
||||
bodyPrefix: "New Body Prefix -",
|
||||
reviewers: [],
|
||||
assignees: ["user3", "user4"],
|
||||
inheritReviewers: false,
|
||||
labels: [],
|
||||
inheritLabels: false,
|
||||
comments: ["First comment", "Second comment"],
|
||||
};
|
||||
|
||||
await expect(() => configParser.parseAndValidate(args)).rejects.toThrow("Unable to extract target branches with regular expression");
|
||||
});
|
||||
|
||||
test("extract target branches from pr labels", async () => {
|
||||
const args: Args = {
|
||||
dryRun: false,
|
||||
auth: "",
|
||||
pullRequest: mergedPRUrl,
|
||||
targetBranchPattern: "^backport (?<target>([^ ]+))$",
|
||||
gitUser: "Me",
|
||||
gitEmail: "me@email.com",
|
||||
title: "New Title",
|
||||
body: "New Body",
|
||||
bodyPrefix: "New Body Prefix -",
|
||||
reviewers: [],
|
||||
assignees: ["user3", "user4"],
|
||||
inheritReviewers: false,
|
||||
labels: [],
|
||||
inheritLabels: false,
|
||||
comments: ["First comment", "Second comment"],
|
||||
};
|
||||
|
||||
const configs: Configs = await configParser.parseAndValidate(args);
|
||||
|
||||
expect(GitHubClient.prototype.getPullRequest).toBeCalledTimes(1);
|
||||
expect(GitHubClient.prototype.getPullRequest).toBeCalledWith("owner", "reponame", 2368, true);
|
||||
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledTimes(1);
|
||||
expect(GitHubMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
|
||||
|
||||
expect(configs.dryRun).toEqual(false);
|
||||
expect(configs.git).toEqual({
|
||||
user: "Me",
|
||||
email: "me@email.com"
|
||||
});
|
||||
expect(configs.auth).toEqual("");
|
||||
expect(configs.folder).toEqual(process.cwd() + "/bp");
|
||||
expect(configs.originalPullRequest).toEqual({
|
||||
number: 2368,
|
||||
author: "gh-user",
|
||||
url: "https://api.github.com/repos/owner/reponame/pulls/2368",
|
||||
htmlUrl: "https://github.com/owner/reponame/pull/2368",
|
||||
state: "closed",
|
||||
merged: true,
|
||||
mergedBy: "that-s-a-user",
|
||||
title: "PR Title",
|
||||
body: "Please review and merge",
|
||||
reviewers: ["requested-gh-user", "gh-user"],
|
||||
assignees: [],
|
||||
labels: ["backport prod"],
|
||||
targetRepo: {
|
||||
owner: "owner",
|
||||
project: "reponame",
|
||||
|
||||
@@ -116,7 +116,7 @@ describe("gitlab merge request config parser", () => {
|
||||
body: "This is the body",
|
||||
reviewers: ["superuser1", "superuser2"],
|
||||
assignees: ["superuser"],
|
||||
labels: ["gitlab-original-label"],
|
||||
labels: ["backport-prod"],
|
||||
targetRepo: {
|
||||
owner: "superuser",
|
||||
project: "backporting-example",
|
||||
@@ -290,7 +290,7 @@ describe("gitlab merge request config parser", () => {
|
||||
body: "This is the body",
|
||||
reviewers: ["superuser1", "superuser2"],
|
||||
assignees: ["superuser"],
|
||||
labels: ["gitlab-original-label"],
|
||||
labels: ["backport-prod"],
|
||||
targetRepo: {
|
||||
owner: "superuser",
|
||||
project: "backporting-example",
|
||||
@@ -361,7 +361,7 @@ describe("gitlab merge request config parser", () => {
|
||||
body: "This is the body",
|
||||
reviewers: ["superuser1", "superuser2"],
|
||||
assignees: ["superuser"],
|
||||
labels: ["gitlab-original-label"],
|
||||
labels: ["backport-prod"],
|
||||
targetRepo: {
|
||||
owner: "superuser",
|
||||
project: "backporting-example",
|
||||
@@ -432,7 +432,7 @@ describe("gitlab merge request config parser", () => {
|
||||
body: "This is the body",
|
||||
reviewers: ["superuser1", "superuser2"],
|
||||
assignees: ["superuser"],
|
||||
labels: ["gitlab-original-label"],
|
||||
labels: ["backport-prod"],
|
||||
targetRepo: {
|
||||
owner: "superuser",
|
||||
project: "backporting-example",
|
||||
@@ -475,7 +475,7 @@ describe("gitlab merge request config parser", () => {
|
||||
reviewers: [],
|
||||
assignees: ["user3", "user4"],
|
||||
inheritReviewers: false,
|
||||
labels: ["custom-label", "gitlab-original-label"], // also include the one inherited
|
||||
labels: ["custom-label", "backport-prod"], // also include the one inherited
|
||||
inheritLabels: true,
|
||||
};
|
||||
|
||||
@@ -505,7 +505,7 @@ describe("gitlab merge request config parser", () => {
|
||||
body: "This is the body",
|
||||
reviewers: ["superuser1", "superuser2"],
|
||||
assignees: ["superuser"],
|
||||
labels: ["gitlab-original-label"],
|
||||
labels: ["backport-prod"],
|
||||
targetRepo: {
|
||||
owner: "superuser",
|
||||
project: "backporting-example",
|
||||
@@ -529,7 +529,7 @@ describe("gitlab merge request config parser", () => {
|
||||
body: "New Body Prefix -New Body",
|
||||
reviewers: [],
|
||||
assignees: ["user3", "user4"],
|
||||
labels: ["custom-label", "gitlab-original-label"],
|
||||
labels: ["custom-label", "backport-prod"],
|
||||
comments: [],
|
||||
});
|
||||
});
|
||||
@@ -566,7 +566,7 @@ describe("gitlab merge request config parser", () => {
|
||||
body: "This is the body",
|
||||
reviewers: ["superuser1", "superuser2"],
|
||||
assignees: ["superuser"],
|
||||
labels: ["gitlab-original-label"],
|
||||
labels: ["backport-prod"],
|
||||
targetRepo: {
|
||||
owner: "superuser",
|
||||
project: "backporting-example",
|
||||
@@ -627,7 +627,7 @@ describe("gitlab merge request config parser", () => {
|
||||
body: "This is the body",
|
||||
reviewers: ["superuser1", "superuser2"],
|
||||
assignees: ["superuser"],
|
||||
labels: ["gitlab-original-label"],
|
||||
labels: ["backport-prod"],
|
||||
targetRepo: {
|
||||
owner: "superuser",
|
||||
project: "backporting-example",
|
||||
@@ -651,7 +651,7 @@ describe("gitlab merge request config parser", () => {
|
||||
body: "New Body Prefix -New Body",
|
||||
reviewers: [],
|
||||
assignees: ["user3", "user4"],
|
||||
labels: ["cherry-pick :cherries:", "gitlab-original-label"],
|
||||
labels: ["cherry-pick :cherries:", "backport-prod"],
|
||||
comments: [],
|
||||
});
|
||||
});
|
||||
@@ -770,7 +770,81 @@ describe("gitlab merge request config parser", () => {
|
||||
body: "This is the body",
|
||||
reviewers: ["superuser1", "superuser2"],
|
||||
assignees: ["superuser"],
|
||||
labels: ["gitlab-original-label"],
|
||||
labels: ["backport-prod"],
|
||||
targetRepo: {
|
||||
owner: "superuser",
|
||||
project: "backporting-example",
|
||||
cloneUrl: "https://my.gitlab.host.com/superuser/backporting-example.git"
|
||||
},
|
||||
sourceRepo: {
|
||||
owner: "superuser",
|
||||
project: "backporting-example",
|
||||
cloneUrl: "https://my.gitlab.host.com/superuser/backporting-example.git"
|
||||
},
|
||||
nCommits: 1,
|
||||
commits: ["ebb1eca696c42fd067658bd9b5267709f78ef38e"]
|
||||
});
|
||||
expect(configs.backportPullRequests.length).toEqual(1);
|
||||
expect(configs.backportPullRequests[0]).toEqual({
|
||||
owner: "superuser",
|
||||
repo: "backporting-example",
|
||||
head: "bp-prod-ebb1eca",
|
||||
base: "prod",
|
||||
title: "New Title",
|
||||
body: "New Body Prefix -New Body",
|
||||
reviewers: [],
|
||||
assignees: ["user3", "user4"],
|
||||
labels: [],
|
||||
comments: ["First comment", "Second comment"],
|
||||
});
|
||||
});
|
||||
|
||||
test("extract target branches from pr labels", async () => {
|
||||
const args: Args = {
|
||||
dryRun: false,
|
||||
auth: "",
|
||||
pullRequest: mergedPRUrl,
|
||||
targetBranchPattern: "^backport-(?<target>([^ ]+))$",
|
||||
gitUser: "Me",
|
||||
gitEmail: "me@email.com",
|
||||
title: "New Title",
|
||||
body: "New Body",
|
||||
bodyPrefix: "New Body Prefix -",
|
||||
reviewers: [],
|
||||
assignees: ["user3", "user4"],
|
||||
inheritReviewers: false,
|
||||
labels: [],
|
||||
inheritLabels: false,
|
||||
comments: ["First comment", "Second comment"],
|
||||
};
|
||||
|
||||
const configs: Configs = await configParser.parseAndValidate(args);
|
||||
|
||||
expect(GitLabClient.prototype.getPullRequest).toBeCalledTimes(1);
|
||||
expect(GitLabClient.prototype.getPullRequest).toBeCalledWith("superuser", "backporting-example", 1, true);
|
||||
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledTimes(1);
|
||||
expect(GitLabMapper.prototype.mapPullRequest).toBeCalledWith(expect.anything(), []);
|
||||
|
||||
expect(configs.dryRun).toEqual(false);
|
||||
expect(configs.git).toEqual({
|
||||
user: "Me",
|
||||
email: "me@email.com"
|
||||
});
|
||||
expect(configs.auth).toEqual("");
|
||||
expect(configs.folder).toEqual(process.cwd() + "/bp");
|
||||
expect(configs.originalPullRequest).toEqual({
|
||||
number: 1,
|
||||
author: "superuser",
|
||||
url: "https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/1",
|
||||
htmlUrl: "https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/1",
|
||||
state: "merged",
|
||||
merged: true,
|
||||
mergedBy: "superuser",
|
||||
title: "Update test.txt",
|
||||
body: "This is the body",
|
||||
reviewers: ["superuser1", "superuser2"],
|
||||
assignees: ["superuser"],
|
||||
labels: ["backport-prod"],
|
||||
targetRepo: {
|
||||
owner: "superuser",
|
||||
project: "backporting-example",
|
||||
|
||||
@@ -90,7 +90,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(0);
|
||||
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(0);
|
||||
@@ -119,7 +119,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(0);
|
||||
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(0);
|
||||
@@ -153,7 +153,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.addRemote).toBeCalledTimes(0);
|
||||
expect(GitCLIService.prototype.addRemote).toBeCalledTimes(0);
|
||||
@@ -190,7 +190,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(0);
|
||||
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(0);
|
||||
@@ -221,7 +221,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
|
||||
@@ -267,7 +267,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
|
||||
@@ -325,7 +325,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/4444/head:pr/4444");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "91748965051fae1330ad58d15cf694e103267c87", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "91748965051fae1330ad58d15cf694e103267c87", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-9174896");
|
||||
@@ -384,7 +384,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
|
||||
@@ -442,7 +442,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
|
||||
@@ -471,7 +471,7 @@ describe("cli runner", () => {
|
||||
"-pr",
|
||||
"https://github.com/owner/reponame/pull/2368",
|
||||
"--labels",
|
||||
"cherry-pick :cherries:, original-label",
|
||||
"cherry-pick :cherries:, backport prod",
|
||||
"--inherit-labels",
|
||||
]);
|
||||
|
||||
@@ -492,7 +492,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
|
||||
@@ -507,7 +507,7 @@ describe("cli runner", () => {
|
||||
body: "**Backport:** https://github.com/owner/reponame/pull/2368\r\n\r\nPlease review and merge",
|
||||
reviewers: ["gh-user", "that-s-a-user"],
|
||||
assignees: [],
|
||||
labels: ["cherry-pick :cherries:", "original-label"],
|
||||
labels: ["cherry-pick :cherries:", "backport prod"],
|
||||
comments: [],
|
||||
}
|
||||
);
|
||||
@@ -541,7 +541,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
|
||||
@@ -586,7 +586,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
|
||||
@@ -601,7 +601,7 @@ describe("cli runner", () => {
|
||||
body: "New Body Prefix - New Body",
|
||||
reviewers: [],
|
||||
assignees: ["user3", "user4"],
|
||||
labels: ["cli github cherry pick :cherries:", "original-label"],
|
||||
labels: ["cli github cherry pick :cherries:", "backport prod"],
|
||||
comments: [],
|
||||
}
|
||||
);
|
||||
@@ -634,7 +634,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
|
||||
@@ -681,8 +681,8 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(2);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "0404fb922ab75c3a8aecad5c97d9af388df04695", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "11da4e38aa3e577ffde6d546f1c52e53b04d3151", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toHaveBeenLastCalledWith(cwd, "0404fb922ab75c3a8aecad5c97d9af388df04695", undefined, undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "11da4e38aa3e577ffde6d546f1c52e53b04d3151", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-0404fb9-11da4e3");
|
||||
@@ -736,7 +736,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, truncatedBranch);
|
||||
@@ -787,8 +787,8 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(2);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "0404fb922ab75c3a8aecad5c97d9af388df04695", "ort", "find-renames");
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "11da4e38aa3e577ffde6d546f1c52e53b04d3151", "ort", "find-renames");
|
||||
expect(GitCLIService.prototype.cherryPick).toHaveBeenLastCalledWith(cwd, "0404fb922ab75c3a8aecad5c97d9af388df04695", "ort", "find-renames", undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "11da4e38aa3e577ffde6d546f1c52e53b04d3151", "ort", "find-renames", undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-0404fb9-11da4e3");
|
||||
@@ -838,7 +838,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
|
||||
@@ -891,9 +891,9 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(3);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(3);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-v1-28f63db");
|
||||
@@ -973,9 +973,9 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(3);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(3);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "custom1");
|
||||
@@ -1060,9 +1060,9 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(3);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(3);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "custom-failure-head-v1");
|
||||
@@ -1163,4 +1163,23 @@ describe("cli runner", () => {
|
||||
|
||||
// Not interested in all subsequent calls, already tested in other test cases
|
||||
});
|
||||
|
||||
test("extract target branch from label", async () => {
|
||||
addProcessArgs([
|
||||
"--target-branch-pattern",
|
||||
"^backport (?<target>([^ ]+))$",
|
||||
"-pr",
|
||||
"https://github.com/owner/reponame/pull/2368"
|
||||
]);
|
||||
|
||||
await runner.execute();
|
||||
|
||||
const cwd = process.cwd() + "/bp";
|
||||
|
||||
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
|
||||
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
|
||||
|
||||
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "prod");
|
||||
});
|
||||
});
|
||||
@@ -101,7 +101,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(0);
|
||||
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(0);
|
||||
@@ -135,7 +135,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.addRemote).toBeCalledTimes(0);
|
||||
expect(GitCLIService.prototype.addRemote).toBeCalledTimes(0);
|
||||
@@ -169,7 +169,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-9e15674");
|
||||
@@ -227,7 +227,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
|
||||
@@ -286,7 +286,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
|
||||
@@ -343,7 +343,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
|
||||
@@ -393,7 +393,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
|
||||
@@ -408,7 +408,7 @@ describe("cli runner", () => {
|
||||
body: expect.stringContaining("**Backport:** https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/1"),
|
||||
reviewers: ["superuser"],
|
||||
assignees: [],
|
||||
labels: ["cherry-pick :cherries:", "another-label", "gitlab-original-label"],
|
||||
labels: ["cherry-pick :cherries:", "another-label", "backport-prod"],
|
||||
comments: [],
|
||||
}
|
||||
);
|
||||
@@ -442,7 +442,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
|
||||
@@ -487,7 +487,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-prod-ebb1eca");
|
||||
@@ -502,7 +502,7 @@ describe("cli runner", () => {
|
||||
body: expect.stringContaining("**This is a backport:** https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/1"),
|
||||
reviewers: [],
|
||||
assignees: ["user3", "user4"],
|
||||
labels: ["cli gitlab cherry pick :cherries:", "gitlab-original-label"],
|
||||
labels: ["cli gitlab cherry pick :cherries:", "backport-prod"],
|
||||
comments: [],
|
||||
}
|
||||
);
|
||||
@@ -531,7 +531,7 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-e4dd336");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-e4dd336");
|
||||
@@ -578,8 +578,8 @@ describe("cli runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(2);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "974519f65c9e0ed65277cd71026657a09fca05e7", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "974519f65c9e0ed65277cd71026657a09fca05e7", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-e4dd336-974519f");
|
||||
|
||||
@@ -83,7 +83,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(0);
|
||||
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(0);
|
||||
@@ -112,7 +112,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
|
||||
@@ -166,7 +166,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/4444/head:pr/4444");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "91748965051fae1330ad58d15cf694e103267c87", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "91748965051fae1330ad58d15cf694e103267c87", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-9174896");
|
||||
@@ -217,7 +217,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
|
||||
@@ -269,7 +269,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
|
||||
@@ -316,7 +316,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
|
||||
@@ -331,7 +331,7 @@ describe("gha runner", () => {
|
||||
body: "**Backport:** https://github.com/owner/reponame/pull/2368\r\n\r\nPlease review and merge",
|
||||
reviewers: ["gh-user", "that-s-a-user"],
|
||||
assignees: [],
|
||||
labels: ["cherry-pick :cherries:", "another-label", "original-label"],
|
||||
labels: ["cherry-pick :cherries:", "another-label", "backport prod"],
|
||||
comments: [],
|
||||
}
|
||||
);
|
||||
@@ -363,7 +363,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
|
||||
@@ -407,7 +407,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
|
||||
@@ -422,7 +422,7 @@ describe("gha runner", () => {
|
||||
body: "New Body Prefix - New Body",
|
||||
reviewers: [],
|
||||
assignees: ["user3", "user4"],
|
||||
labels: ["gha github cherry pick :cherries:", "original-label"],
|
||||
labels: ["gha github cherry pick :cherries:", "backport prod"],
|
||||
comments: [],
|
||||
}
|
||||
);
|
||||
@@ -453,7 +453,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
|
||||
@@ -498,8 +498,8 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(2);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "0404fb922ab75c3a8aecad5c97d9af388df04695", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "11da4e38aa3e577ffde6d546f1c52e53b04d3151", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toHaveBeenLastCalledWith(cwd, "0404fb922ab75c3a8aecad5c97d9af388df04695", undefined, undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "11da4e38aa3e577ffde6d546f1c52e53b04d3151", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-0404fb9-11da4e3");
|
||||
@@ -546,7 +546,53 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", "ort", "ours");
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", "ort", "ours", undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
|
||||
|
||||
expect(GitHubClient.prototype.createPullRequest).toBeCalledTimes(1);
|
||||
expect(GitHubClient.prototype.createPullRequest).toBeCalledWith({
|
||||
owner: "owner",
|
||||
repo: "reponame",
|
||||
head: "bp-target-28f63db",
|
||||
base: "target",
|
||||
title: "[target] PR Title",
|
||||
body: "**Backport:** https://github.com/owner/reponame/pull/2368\r\n\r\nPlease review and merge",
|
||||
reviewers: ["gh-user", "that-s-a-user"],
|
||||
assignees: [],
|
||||
labels: [],
|
||||
comments: [],
|
||||
}
|
||||
);
|
||||
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(1);
|
||||
});
|
||||
|
||||
test("using github api url and additional cherry-pick options", async () => {
|
||||
spyGetInput({
|
||||
"target-branch": "target",
|
||||
"pull-request": "https://api.github.com/repos/owner/reponame/pulls/2368",
|
||||
"cherry-pick-options": "-x --allow-empty",
|
||||
});
|
||||
|
||||
await runner.execute();
|
||||
|
||||
const cwd = process.cwd() + "/bp";
|
||||
|
||||
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
|
||||
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.GITHUB, undefined, "https://api.github.com");
|
||||
|
||||
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
|
||||
|
||||
expect(GitCLIService.prototype.createLocalBranch).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-28f63db");
|
||||
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, "-x --allow-empty");
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
|
||||
@@ -592,7 +638,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-28f63db");
|
||||
@@ -642,9 +688,9 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(3);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(3);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-v1-28f63db");
|
||||
@@ -720,9 +766,9 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "pull/2368/head:pr/2368");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(3);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "28f63db774185f4ec4b57cd9aaeb12dbfb4c9ecc", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(3);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "custom-v1");
|
||||
@@ -768,4 +814,23 @@ describe("gha runner", () => {
|
||||
});
|
||||
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(3);
|
||||
});
|
||||
|
||||
test("explicitly set git client", async () => {
|
||||
spyGetInput({
|
||||
"target-branch": "target",
|
||||
"pull-request": "https://api.github.com/repos/owner/reponame/pulls/2368",
|
||||
"git-client": "codeberg",
|
||||
});
|
||||
|
||||
await runner.execute();
|
||||
|
||||
const cwd = process.cwd() + "/bp";
|
||||
|
||||
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
|
||||
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.CODEBERG, undefined, "https://api.github.com");
|
||||
|
||||
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
|
||||
});
|
||||
|
||||
});
|
||||
@@ -94,7 +94,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(0);
|
||||
expect(GitLabClient.prototype.createPullRequest).toBeCalledTimes(0);
|
||||
@@ -123,7 +123,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-9e15674");
|
||||
@@ -175,7 +175,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
|
||||
@@ -225,7 +225,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
|
||||
@@ -276,7 +276,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "9e15674ebd48e05c6e428a1fa31dbb60a778d644", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp_branch_name");
|
||||
@@ -321,7 +321,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
|
||||
@@ -336,7 +336,7 @@ describe("gha runner", () => {
|
||||
body: expect.stringContaining("**Backport:** https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/1"),
|
||||
reviewers: ["superuser"],
|
||||
assignees: [],
|
||||
labels: ["cherry-pick :cherries:", "another-label", "gitlab-original-label"],
|
||||
labels: ["cherry-pick :cherries:", "another-label", "backport-prod"],
|
||||
comments: [],
|
||||
}
|
||||
);
|
||||
@@ -365,7 +365,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-ebb1eca");
|
||||
@@ -409,7 +409,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "ebb1eca696c42fd067658bd9b5267709f78ef38e", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-prod-ebb1eca");
|
||||
@@ -424,7 +424,7 @@ describe("gha runner", () => {
|
||||
body: expect.stringContaining("**This is a backport:** https://my.gitlab.host.com/superuser/backporting-example/-/merge_requests/1"),
|
||||
reviewers: [],
|
||||
assignees: ["user3", "user4"],
|
||||
labels: ["gha gitlab cherry pick :cherries:", "gitlab-original-label"],
|
||||
labels: ["gha gitlab cherry pick :cherries:", "backport-prod"],
|
||||
comments: [],
|
||||
}
|
||||
);
|
||||
@@ -451,7 +451,7 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.createLocalBranch).toBeCalledWith(cwd, "bp-target-e4dd336");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-e4dd336");
|
||||
@@ -496,8 +496,8 @@ describe("gha runner", () => {
|
||||
expect(GitCLIService.prototype.fetch).toBeCalledWith(cwd, "merge-requests/2/head:pr/2");
|
||||
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(2);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "974519f65c9e0ed65277cd71026657a09fca05e7", undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "e4dd336a4a20f394df6665994df382fb1d193a11", undefined, undefined, undefined);
|
||||
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "974519f65c9e0ed65277cd71026657a09fca05e7", undefined, undefined, undefined);
|
||||
|
||||
expect(GitCLIService.prototype.push).toBeCalledTimes(1);
|
||||
expect(GitCLIService.prototype.push).toBeCalledWith(cwd, "bp-target-e4dd336-974519f");
|
||||
|
||||
@@ -96,8 +96,8 @@ export const MERGED_PR_FIXTURE = {
|
||||
{
|
||||
"id": 4901021057,
|
||||
"node_id": "LA_kwDOImgs2354988AAAABJB-lgQ",
|
||||
"url": "https://api.github.com/repos/owner/reponame/labels/original-label",
|
||||
"name": "original-label",
|
||||
"url": "https://api.github.com/repos/owner/reponame/labels/backport-prod",
|
||||
"name": "backport prod",
|
||||
"color": "AB975B",
|
||||
"default": false,
|
||||
"description": ""
|
||||
@@ -1431,7 +1431,33 @@ export const MULT_COMMITS_PR_FIXTURE = {
|
||||
|
||||
],
|
||||
"labels": [
|
||||
|
||||
{
|
||||
"id": 4901021057,
|
||||
"node_id": "LA_kwDOImgs2354988AAAABJB-lgQ",
|
||||
"url": "https://api.github.com/repos/owner/reponame/labels/backport-v1",
|
||||
"name": "backport v1",
|
||||
"color": "AB975B",
|
||||
"default": false,
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": 4901021057,
|
||||
"node_id": "LA_kwDOImgs2354988AAAABJB-lgQ",
|
||||
"url": "https://api.github.com/repos/owner/reponame/labels/backport-v2",
|
||||
"name": "backport v2",
|
||||
"color": "AB975B",
|
||||
"default": false,
|
||||
"description": ""
|
||||
},
|
||||
{
|
||||
"id": 4901021057,
|
||||
"node_id": "LA_kwDOImgs2354988AAAABJB-lgQ",
|
||||
"url": "https://api.github.com/repos/owner/reponame/labels/backport-v3",
|
||||
"name": "backport v3",
|
||||
"color": "AB975B",
|
||||
"default": false,
|
||||
"description": ""
|
||||
}
|
||||
],
|
||||
"milestone": null,
|
||||
"draft": false,
|
||||
|
||||
@@ -401,7 +401,7 @@ export const MERGED_SQUASHED_MR = {
|
||||
"source_project_id":76316,
|
||||
"target_project_id":76316,
|
||||
"labels":[
|
||||
"gitlab-original-label"
|
||||
"backport-prod"
|
||||
],
|
||||
"draft":false,
|
||||
"work_in_progress":false,
|
||||
|
||||
Reference in New Issue
Block a user