backport 8.3.1 → 8.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -178
- package/dist/lib/cherrypickAndCreateTargetPullRequest.js +42 -21
- package/dist/lib/child-process-promisified.js +2 -2
- package/dist/lib/git.d.ts +4 -3
- package/dist/lib/git.js +22 -29
- package/dist/lib/git.private.test.js +10 -7
- package/dist/lib/git.test.js +47 -15
- package/dist/lib/github/v4/apiRequestV4.js +14 -8
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +1 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -0
- package/dist/lib/ora.d.ts +1 -0
- package/dist/options/ConfigOptions.d.ts +1 -0
- package/dist/options/cliArgs.d.ts +1 -0
- package/dist/options/cliArgs.js +5 -0
- package/dist/options/config/config.d.ts +1 -0
- package/dist/options/config/readConfigFile.d.ts +1 -0
- package/dist/options/options.d.ts +2 -0
- package/dist/options/options.js +3 -2
- package/dist/options/options.test.js +5 -4
- package/dist/test/e2e/cli/date-filters.private.test.js +1 -0
- package/dist/test/e2e/cli/different-merge-strategies.private.test.js +122 -6
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +2 -0
- package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.js +27 -13
- package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.js +3 -2
- package/dist/{entrypoint.cli.private.test.d.ts → test/e2e/cli/gracefully-handles-corrupt-repo.private.test.d.ts} +0 -0
- package/dist/test/e2e/cli/gracefully-handles-corrupt-repo.private.test.js +52 -0
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +2 -2
- package/dist/{lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts → test/e2e/cli/repo-with-programatically-added-commits.mutation.test.d.ts} +0 -0
- package/dist/test/e2e/cli/repo-with-programatically-added-commits.mutation.test.js +114 -0
- package/dist/test/e2e/cli/runBackportViaCli.d.ts +8 -2
- package/dist/test/e2e/cli/runBackportViaCli.js +47 -17
- package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +7 -1
- package/dist/test/e2e/module/entrypoint.module.mutation.test.js +1 -1
- package/dist/test/handleUnbackportedPullRequests.private.test.js +1 -1
- package/dist/test/replaceStringAndLinebreaks.d.ts +5 -0
- package/dist/test/replaceStringAndLinebreaks.js +8 -0
- package/dist/test/sandbox.js +6 -2
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +23 -24
- package/yarn.lock +841 -950
- package/dist/entrypoint.cli.private.test.js +0 -47
- package/dist/errors/BackportError.d.ts +0 -19
- package/dist/errors/BackportError.js +0 -29
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
- package/dist/runSequentially.test.d.ts +0 -1
- package/dist/runSequentially.test.js +0 -243
- package/dist/services/BackportError.d.ts +0 -19
- package/dist/services/BackportError.js +0 -29
- package/dist/services/HandledBackportError.d.ts +0 -19
- package/dist/services/HandledBackportError.js +0 -29
- package/dist/services/HandledError.d.ts +0 -19
- package/dist/services/HandledError.js +0 -29
- package/dist/services/child-process-promisified.d.ts +0 -25
- package/dist/services/child-process-promisified.js +0 -58
- package/dist/services/env.d.ts +0 -7
- package/dist/services/env.js +0 -30
- package/dist/services/env.test.d.ts +0 -1
- package/dist/services/env.test.js +0 -21
- package/dist/services/git.d.ts +0 -77
- package/dist/services/git.integration.test.d.ts +0 -1
- package/dist/services/git.integration.test.js +0 -616
- package/dist/services/git.js +0 -439
- package/dist/services/git.private.test.d.ts +0 -1
- package/dist/services/git.private.test.js +0 -618
- package/dist/services/git.test.d.ts +0 -1
- package/dist/services/git.test.js +0 -580
- package/dist/services/github/commitFormatters.d.ts +0 -3
- package/dist/services/github/commitFormatters.js +0 -17
- package/dist/services/github/commitFormatters.test.d.ts +0 -1
- package/dist/services/github/commitFormatters.test.js +0 -11
- package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +0 -2
- package/dist/services/github/v3/addAssigneesToPullRequest.js +0 -32
- package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +0 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.test.js +0 -27
- package/dist/services/github/v3/addLabelsToPullRequest.d.ts +0 -2
- package/dist/services/github/v3/addLabelsToPullRequest.js +0 -30
- package/dist/services/github/v3/addReviewersToPullRequest.d.ts +0 -2
- package/dist/services/github/v3/addReviewersToPullRequest.js +0 -32
- package/dist/services/github/v3/createPullRequest.d.ts +0 -29
- package/dist/services/github/v3/createPullRequest.js +0 -91
- package/dist/services/github/v3/createPullRequest.test.d.ts +0 -1
- package/dist/services/github/v3/createPullRequest.test.js +0 -377
- package/dist/services/github/v3/createStatusComment.d.ts +0 -11
- package/dist/services/github/v3/createStatusComment.js +0 -131
- package/dist/services/github/v3/createStatusComment.test.d.ts +0 -1
- package/dist/services/github/v3/createStatusComment.test.js +0 -409
- package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +0 -14
- package/dist/services/github/v3/getGithubV3ErrorMessage.js +0 -16
- package/dist/services/github/v4/FetchPullRequestId.d.ts +0 -2
- package/dist/services/github/v4/FetchPullRequestId.js +0 -36
- package/dist/services/github/v4/apiRequestV4.d.ts +0 -31
- package/dist/services/github/v4/apiRequestV4.js +0 -71
- package/dist/services/github/v4/apiRequestV4.test.d.ts +0 -1
- package/dist/services/github/v4/apiRequestV4.test.js +0 -109
- package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -2
- package/dist/services/github/v4/disablePullRequestAutoMerge.js +0 -32
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -2
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +0 -50
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +0 -1
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
- package/dist/services/github/v4/fetchAuthorId.d.ts +0 -10
- package/dist/services/github/v4/fetchAuthorId.js +0 -28
- package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchAuthorId.private.test.js +0 -25
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -93
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +0 -11
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +0 -58
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +0 -136
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +0 -11
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +0 -48
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +0 -118
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +0 -29
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +0 -110
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +0 -196
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -157
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +0 -3
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +0 -61
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +0 -107
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +0 -12
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +0 -69
- package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -9
- package/dist/services/github/v4/fetchExistingPullRequest.js +0 -64
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -44
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -2
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +0 -39
- package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +0 -8
- package/dist/services/github/v4/fetchRemoteProjectConfig.js +0 -49
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +0 -49
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +0 -69
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +0 -73
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +0 -1
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -116
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +0 -16
- package/dist/services/github/v4/getOptionsFromGithub/query.js +0 -29
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +0 -29
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +0 -61
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +0 -1
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +0 -72
- package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +0 -176
- package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +0 -6
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +0 -45
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +0 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +0 -87
- package/dist/services/logger.d.ts +0 -9
- package/dist/services/logger.js +0 -74
- package/dist/services/prompt.test.d.ts +0 -1
- package/dist/services/prompt.test.js +0 -139
- package/dist/services/prompts.d.ts +0 -17
- package/dist/services/prompts.js +0 -132
- package/dist/services/remoteConfig.d.ts +0 -20
- package/dist/services/remoteConfig.js +0 -52
- package/dist/services/sequentially.d.ts +0 -1
- package/dist/services/sequentially.js +0 -10
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +0 -16
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +0 -102
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +0 -1
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +0 -467
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +0 -26
- package/dist/services/sourceCommit/getMockSourceCommit.js +0 -103
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +0 -108
- package/dist/services/sourceCommit/parseSourceCommit.js +0 -123
- package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit/parseSourceCommit.test.js +0 -226
- package/dist/services/test.d.ts +0 -1
- package/dist/services/test.js +0 -23
- package/dist/state.d.ts +0 -0
- package/dist/state.js +0 -1
- package/dist/test/ExecError.d.ts +0 -16
- package/dist/test/ExecError.js +0 -15
- package/dist/test/e2e/cli/cli.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/cli.private.test.js +0 -222
- package/dist/test/e2e/cli/date-filters.d.ts +0 -1
- package/dist/test/e2e/cli/date-filters.js +0 -43
- package/dist/test/e2e/cli/interactive-error-handling.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/interactive-error-handling.private.test.js +0 -80
- package/dist/test/e2e/cli/non-interactive-error-handling.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/non-interactive-error-handling.private.test.js +0 -198
- package/dist/test/e2e/cli.e2e.private.test.d.ts +0 -1
- package/dist/test/e2e/cli.e2e.private.test.js +0 -433
- package/dist/test/e2e/module/module.mutation.test.d.ts +0 -1
- package/dist/test/e2e/module/module.mutation.test.js +0 -369
- package/dist/test/e2e/module.e2e.mutation.test.d.ts +0 -1
- package/dist/test/e2e/module.e2e.mutation.test.js +0 -369
- package/dist/test/e2e/module.e2e.private.test.d.ts +0 -1
- package/dist/test/e2e/module.e2e.private.test.js +0 -369
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -13
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +0 -243
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +0 -320
- package/dist/ui/getCommits.d.ts +0 -2
- package/dist/ui/getCommits.js +0 -75
- package/dist/ui/getCommitsWithoutBackports.d.ts +0 -11
- package/dist/ui/getCommitsWithoutBackports.js +0 -68
- package/dist/ui/getCommitsWithoutBackports.test.d.ts +0 -1
- package/dist/ui/getCommitsWithoutBackports.test.js +0 -335
- package/dist/ui/getGitConfigAuthor.d.ts +0 -6
- package/dist/ui/getGitConfigAuthor.js +0 -15
- package/dist/ui/getTargetBranches.d.ts +0 -5
- package/dist/ui/getTargetBranches.js +0 -67
- package/dist/ui/getTargetBranches.test.d.ts +0 -1
- package/dist/ui/getTargetBranches.test.js +0 -204
- package/dist/ui/maybeSetupRepo.d.ts +0 -2
- package/dist/ui/maybeSetupRepo.js +0 -53
- package/dist/ui/maybeSetupRepo.test.d.ts +0 -1
- package/dist/ui/maybeSetupRepo.test.js +0 -238
- package/dist/ui/ora.d.ts +0 -2
- package/dist/ui/ora.js +0 -21
- package/dist/ui/setupRepo.d.ts +0 -2
- package/dist/ui/setupRepo.js +0 -56
- package/dist/ui/setupRepo.test.d.ts +0 -1
- package/dist/ui/setupRepo.test.js +0 -273
- package/dist/utils/filterMissingCommits.d.ts +0 -2
- package/dist/utils/filterMissingCommits.js +0 -7
- package/dist/utils/redact.d.ts +0 -1
- package/dist/utils/redact.js +0 -7
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<br>
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
|
-
## 🎉 New
|
|
9
|
+
## 🎉 New: The Backport Tool as a Github Action 🎉
|
|
10
10
|
|
|
11
11
|
A [Github Action](https://github.com/sqren/backport-github-action) around The Backport Tool now exists. It makes it a breeze to get automatic backports when pull requests are merged.
|
|
12
12
|
|
|
@@ -33,7 +33,7 @@ The remaining documentation focuses on the Backport CLI tool (not the Github Act
|
|
|
33
33
|
npm install -g backport
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
After installation you should add an access token to the [global config](
|
|
36
|
+
After installation you should add an access token to the [global config](/docs/config-file-options.md#global-config-backportconfigjson) in `~/.backport/config.json`. See the [documentation](/docs/config-file-options.md#accesstoken-required) for how the access token is generated.
|
|
37
37
|
|
|
38
38
|
## Quick start
|
|
39
39
|
|
|
@@ -41,7 +41,7 @@ After installation you should add an access token to the [global config](https:/
|
|
|
41
41
|
npm install backport
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
Add a [project config](
|
|
44
|
+
Add a [project config](/docs/config-file-options.md#project-config-backportrcjson) to the root of your repository:
|
|
45
45
|
|
|
46
46
|
```js
|
|
47
47
|
// .backportrc.json
|
|
@@ -60,7 +60,7 @@ Add a [project config](https://github.com/sqren/backport/blob/main/docs/configur
|
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
Add personal access token to [global config](
|
|
63
|
+
Add personal access token to [global config](/docs/config-file-options.md#global-config-backportconfigjson):
|
|
64
64
|
|
|
65
65
|
```js
|
|
66
66
|
// ~/.backport/config.json
|
|
@@ -77,185 +77,24 @@ npx backport
|
|
|
77
77
|
|
|
78
78
|
_This will start an interactive prompt. You can use your keyboards arrow keys to choose options, `<space>` to select checkboxes and `<enter>` to proceed._
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
### CLI options
|
|
85
|
-
|
|
86
|
-
| Option | Shorthand notation | Description | Default |
|
|
87
|
-
| ------------------- | ------------------ | -------------------------------------------------------------------------- | ------------------------- |
|
|
88
|
-
| --access-token | | Github access token | |
|
|
89
|
-
| --all | -a | Show commits from any author. Opposite of `--author` | false |
|
|
90
|
-
| --assignee | --assign | Assign users to the target PR | |
|
|
91
|
-
| --author | | Filter commits by Github username. Opposite of `--all` | _Current user_ |
|
|
92
|
-
| --auto-assign | | Assign current user to the target PR | false |
|
|
93
|
-
| --branch | -b | Target branch to backport to | |
|
|
94
|
-
| --config-file | | Custom path to project config file (.backportrc.json) | |
|
|
95
|
-
| --dir | | Clone repository into custom directory | ~/.backport/repositories/ |
|
|
96
|
-
| --dry-run | | Perform backport without pushing to Github | false |
|
|
97
|
-
| --editor | | Editor (eg. `code`) to open and resolve conflicts | nano |
|
|
98
|
-
| --fork | | Create backports in fork repo | true |
|
|
99
|
-
| --git-hostname | | Hostname for Git | github.com |
|
|
100
|
-
| --interactive | | Enable interactive prompts | true |
|
|
101
|
-
| --mainline | | Parent id of merge commit | 1 |
|
|
102
|
-
| --max-number | --number, -n | Number of commits to choose from | 10 |
|
|
103
|
-
| --multiple | | Multi-select for commits and branches | false |
|
|
104
|
-
| --multiple-branches | | Multi-select for branches | true |
|
|
105
|
-
| --multiple-commits | | Multi-select for commits | false |
|
|
106
|
-
| --no-cherrypick-ref | | Do not append "(cherry picked from commit...)". [Git Docs][1] | false |
|
|
107
|
-
| --no-status-comment | | Do not publish a status comment to Github with the results of the backport | false |
|
|
108
|
-
| --no-verify | | Bypass the pre-commit and commit-msg hooks | false |
|
|
109
|
-
| --path | -p | Filter commits by path | |
|
|
110
|
-
| --pr-description | --description | Description for pull request | |
|
|
111
|
-
| --pr-filter | | Find PRs using [Github's search syntax][2] | |
|
|
112
|
-
| --pr-title | --title | Title of pull request | |
|
|
113
|
-
| --pull-number | --pr | Backport pull request by number | |
|
|
114
|
-
| --repo-fork-owner | | The owner of the fork where the backport branch is pushed. | _Current user_ |
|
|
115
|
-
| --repo-name | | Name of repository | |
|
|
116
|
-
| --repo-owner | | Owner of repository | |
|
|
117
|
-
| --reset-author | | Set yourself as commit author | |
|
|
118
|
-
| --reviewer | | Add reviewer to the target PR | |
|
|
119
|
-
| --sha | | Sha of commit to backport | |
|
|
120
|
-
| --source-branch | | Specify a non-default branch to backport from | |
|
|
121
|
-
| --source-pr-label | | Labels added to the source PR | |
|
|
122
|
-
| --target-branch | -b | Target branch(es) to backport to | |
|
|
123
|
-
| --target-pr-label | --label, -l | Labels added to the target PR | |
|
|
124
|
-
| --help | | Show help | |
|
|
125
|
-
| -v, --version | | Show version number | |
|
|
126
|
-
|
|
127
|
-
The CLI options will override the [configuration options](https://github.com/sqren/backport/blob/main/docs/configuration.md).
|
|
128
|
-
|
|
129
|
-
## Backport Module API
|
|
130
|
-
|
|
131
|
-
`backport` can be imported as a Node module and interacted with programatically. This can be useful when creating automation around the Backport tool. See for example the [Backport Github Action](https://github.com/sqren/backport-github-action)
|
|
132
|
-
|
|
133
|
-
### `backportRun`
|
|
134
|
-
|
|
135
|
-
Backport a commit programatically. Commits can be selected via `pullNumber` or `sha`.
|
|
136
|
-
|
|
137
|
-
#### Arguments:
|
|
138
|
-
|
|
139
|
-
All of the options listed on [configuration.md](https://github.com/sqren/backport/blob/main/docs/configuration.md) are valid. The most common options are:
|
|
140
|
-
|
|
141
|
-
`accessToken` _string_ **(Required)**<br/>
|
|
142
|
-
Github access token to authenticate the request
|
|
143
|
-
|
|
144
|
-
`repoName` _string_ **(Required)**<br/>
|
|
145
|
-
Name of repository
|
|
146
|
-
|
|
147
|
-
`repoOwner` _string_ **(Required)**<br/>
|
|
148
|
-
Owner of repository (organisation or username)
|
|
149
|
-
|
|
150
|
-
`pullNumber` _number_<br/>
|
|
151
|
-
Filter commits by pull request number
|
|
152
|
-
|
|
153
|
-
`sha` _string_<br/>
|
|
154
|
-
Filter commits by commit sha
|
|
155
|
-
|
|
156
|
-
`interactive` _boolean_<br/>
|
|
157
|
-
Enable interactive prompts
|
|
158
|
-
|
|
159
|
-
#### Example
|
|
160
|
-
|
|
161
|
-
```ts
|
|
162
|
-
import { backportRun } from 'backport';
|
|
163
|
-
|
|
164
|
-
const result = await backportRun({
|
|
165
|
-
options: {
|
|
166
|
-
accessToken: 'very secret',
|
|
167
|
-
repoName: 'kibana',
|
|
168
|
-
repoOwner: 'elastic',
|
|
169
|
-
pullNumber: 121633,
|
|
170
|
-
interactive: false,
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
console.log(result);
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### `getCommits`
|
|
178
|
-
|
|
179
|
-
Retrieve information about commits and whether they are backported
|
|
180
|
-
|
|
181
|
-
#### Arguments:
|
|
182
|
-
|
|
183
|
-
`accessToken` _string_ **(Required)**<br/>
|
|
184
|
-
Github access token to authenticate the request
|
|
185
|
-
|
|
186
|
-
`repoName` _string_ **(Required)**<br/>
|
|
187
|
-
Name of repository
|
|
188
|
-
|
|
189
|
-
`repoOwner` _string_ **(Required)**<br/>
|
|
190
|
-
Owner of repository (organisation or username)
|
|
191
|
-
|
|
192
|
-
`author` _string_<br/>
|
|
193
|
-
Filter commits by Github user
|
|
194
|
-
|
|
195
|
-
`pullNumber` _number_<br/>
|
|
196
|
-
Filter commits by pull request number
|
|
197
|
-
|
|
198
|
-
`sha` _string_<br/>
|
|
199
|
-
Filter commits by commit sha
|
|
200
|
-
|
|
201
|
-
`sourceBranch` _string_<br/>
|
|
202
|
-
The branch to display commits from. Defaults to the default branch (normally "main" or "master")
|
|
203
|
-
|
|
204
|
-
#### Example
|
|
205
|
-
|
|
206
|
-
```ts
|
|
207
|
-
import { getCommits } from 'backport';
|
|
208
|
-
|
|
209
|
-
const commits = await getCommits({
|
|
210
|
-
accessToken: 'abc',
|
|
211
|
-
repoName: 'kibana',
|
|
212
|
-
repoOwner: 'elastic',
|
|
213
|
-
pullNumber: 121633,
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
console.log(commits);
|
|
217
|
-
|
|
218
|
-
/*
|
|
219
|
-
[{
|
|
220
|
-
soureCommit: {
|
|
221
|
-
committedDate: '2021-12-20T14:20:16Z',
|
|
222
|
-
sha: 'd421ddcf6157150596581c7885afa3690cec6339',
|
|
223
|
-
message: '[APM] Add note about synthtrace to APM docs (#121633)',
|
|
224
|
-
},
|
|
225
|
-
sourcePullRequest: {
|
|
226
|
-
number: 121633,
|
|
227
|
-
url: 'https://github.com/elastic/kibana/pull/121633'
|
|
228
|
-
mergeCommit: {
|
|
229
|
-
sha: 'd421ddcf6157150596581c7885afa3690cec6339',
|
|
230
|
-
message: '[APM] Add note about synthtrace to APM docs (#121633)',
|
|
231
|
-
}
|
|
232
|
-
},
|
|
233
|
-
sourceBranch: 'main',
|
|
234
|
-
expectedTargetPullRequests: [
|
|
235
|
-
{
|
|
236
|
-
url: 'https://github.com/elastic/kibana/pull/121643',
|
|
237
|
-
number: 121643,
|
|
238
|
-
branch: '8.0',
|
|
239
|
-
state: 'MERGED'
|
|
240
|
-
}
|
|
241
|
-
]
|
|
242
|
-
}]
|
|
243
|
-
*/
|
|
244
|
-
```
|
|
80
|
+
## Documentation
|
|
81
|
+
- [Config file options](/docs/config-file-options.md)
|
|
82
|
+
- [CLI options](/docs/cli-options.md)
|
|
83
|
+
- [Module API](/docs/api.md)
|
|
245
84
|
|
|
246
|
-
|
|
85
|
+
### What is backporting?
|
|
247
86
|
|
|
248
87
|
> Backporting is the action of taking parts from a newer version of a software system [..] and porting them to an older version of the same software. It forms part of the maintenance step in a software development process, and it is commonly used for fixing security issues in older versions of the software and also for providing new features to older versions.
|
|
249
88
|
|
|
250
89
|
Source: [https://en.wikipedia.org/wiki/Backporting](https://en.wikipedia.org/wiki/Backporting)
|
|
251
90
|
|
|
252
|
-
|
|
91
|
+
### Who is this tool for?
|
|
253
92
|
|
|
254
93
|
This tools is for anybody who is working on a codebase where they have to maintain multiple versions. If you manually cherry-pick commits from master and apply them to one or more branches, this tool might save you a lot of time.
|
|
255
94
|
|
|
256
95
|
`backport` is a CLI tool that will let you backport commit(s) interactively and then cherry-pick and create pull requests automatically. `backport` will perform all git operations in a temporary folder (`~/.backport/repositories/`) separate from your working directory, thereby never interfering with any unstages changes your might have.
|
|
257
96
|
|
|
258
|
-
|
|
97
|
+
### Features:
|
|
259
98
|
|
|
260
99
|
- interactively backport one or more commits to one or more branches with an intuitive UI
|
|
261
100
|
- ability to see which commits have been backported and to which branches
|
|
@@ -272,9 +111,3 @@ This tools is for anybody who is working on a codebase where they have to mainta
|
|
|
272
111
|
## Contributing
|
|
273
112
|
|
|
274
113
|
See [CONTRIBUTING.md](https://github.com/sqren/backport/blob/master/CONTRIBUTING.md)
|
|
275
|
-
|
|
276
|
-
[1]: https://git-scm.com/docs/git-cherry-pick#Documentation/git-cherry-pick.txt--x
|
|
277
|
-
[2]: https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax
|
|
278
|
-
|
|
279
|
-
[](https://www.npmjs.com/package/backport)
|
|
280
|
-
[](https://coveralls.io/github/sqren/backport?branch=master)
|
|
@@ -18,19 +18,33 @@ const addLabelsToPullRequest_1 = require("./github/v3/addLabelsToPullRequest");
|
|
|
18
18
|
const addReviewersToPullRequest_1 = require("./github/v3/addReviewersToPullRequest");
|
|
19
19
|
const createPullRequest_1 = require("./github/v3/createPullRequest");
|
|
20
20
|
const enablePullRequestAutoMerge_1 = require("./github/v4/enablePullRequestAutoMerge");
|
|
21
|
+
const fetchCommitBySha_1 = require("./github/v4/fetchCommits/fetchCommitBySha");
|
|
21
22
|
const logger_1 = require("./logger");
|
|
22
23
|
const ora_1 = require("./ora");
|
|
23
24
|
const prompts_1 = require("./prompts");
|
|
24
25
|
const sequentially_1 = require("./sequentially");
|
|
26
|
+
function getSourceBranchFromCommits(commits) {
|
|
27
|
+
// sourceBranch should be the same for all commits, so picking `sourceBranch` from the first commit should be fine 🤞
|
|
28
|
+
// this is specifically needed when backporting a PR like `backport --pr 123` and the source PR was merged to a non-default (aka non-master) branch.
|
|
29
|
+
const { sourceBranch } = commits[0];
|
|
30
|
+
return sourceBranch;
|
|
31
|
+
}
|
|
25
32
|
async function cherrypickAndCreateTargetPullRequest({ options, commits, targetBranch, }) {
|
|
26
33
|
const backportBranch = getBackportBranchName(targetBranch, commits);
|
|
27
34
|
const repoForkOwner = (0, git_1.getRepoForkOwner)(options);
|
|
28
35
|
(0, logger_1.consoleLog)(`\n${chalk_1.default.bold(`Backporting to ${targetBranch}:`)}`);
|
|
36
|
+
const sourceBranch = getSourceBranchFromCommits(commits);
|
|
29
37
|
const [gitConfigAuthor] = await Promise.all([
|
|
30
38
|
(0, getGitConfigAuthor_1.getGitConfigAuthor)(options),
|
|
31
|
-
(0, git_1.createBackportBranch)({
|
|
39
|
+
(0, git_1.createBackportBranch)({
|
|
40
|
+
options,
|
|
41
|
+
sourceBranch,
|
|
42
|
+
targetBranch,
|
|
43
|
+
backportBranch,
|
|
44
|
+
}),
|
|
32
45
|
]);
|
|
33
|
-
|
|
46
|
+
const commitsFlattened = (0, lodash_1.flatten)(await Promise.all(commits.map((c) => getMergeCommits(options, c))));
|
|
47
|
+
await (0, sequentially_1.sequentially)(commitsFlattened, (commit) => waitForCherrypick(options, commit, targetBranch, gitConfigAuthor));
|
|
34
48
|
if (options.dryRun) {
|
|
35
49
|
(0, ora_1.ora)(options.interactive).succeed('Dry run complete');
|
|
36
50
|
return { url: 'https://localhost/dry-run', didUpdate: false, number: 1337 };
|
|
@@ -78,6 +92,17 @@ async function cherrypickAndCreateTargetPullRequest({ options, commits, targetBr
|
|
|
78
92
|
return targetPullRequest;
|
|
79
93
|
}
|
|
80
94
|
exports.cherrypickAndCreateTargetPullRequest = cherrypickAndCreateTargetPullRequest;
|
|
95
|
+
async function getMergeCommits(options, commit) {
|
|
96
|
+
const { sha } = commit.sourceCommit;
|
|
97
|
+
if (!options.mainline) {
|
|
98
|
+
const isMergeCommit = await (0, git_1.getIsMergeCommit)(options, sha);
|
|
99
|
+
if (isMergeCommit) {
|
|
100
|
+
const shas = await (0, git_1.getShasInMergeCommit)(options, sha);
|
|
101
|
+
return Promise.all(shas.reverse().map((sha) => (0, fetchCommitBySha_1.fetchCommitBySha)({ ...options, sha })));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return [commit];
|
|
105
|
+
}
|
|
81
106
|
/*
|
|
82
107
|
* Returns the name of the backport branch without remote name
|
|
83
108
|
*
|
|
@@ -97,18 +122,26 @@ function getBackportBranchName(targetBranch, commits) {
|
|
|
97
122
|
}
|
|
98
123
|
async function waitForCherrypick(options, commit, targetBranch, gitConfigAuthor) {
|
|
99
124
|
const spinnerText = `Cherry-picking: ${chalk_1.default.greenBright((0, commitFormatters_1.getFirstLine)(commit.sourceCommit.message))}`;
|
|
100
|
-
const mergedTargetPullRequest = commit.expectedTargetPullRequests.find((pr) => pr.state === 'MERGED' && pr.branch === targetBranch);
|
|
101
125
|
const cherrypickSpinner = (0, ora_1.ora)(options.interactive, spinnerText).start();
|
|
126
|
+
await cherrypickAndHandleConflicts(options, commit, targetBranch, cherrypickSpinner, gitConfigAuthor);
|
|
127
|
+
// Conflicts should be resolved and files staged at this point
|
|
128
|
+
try {
|
|
129
|
+
// Run `git commit`
|
|
130
|
+
await (0, git_1.commitChanges)(commit, options);
|
|
131
|
+
cherrypickSpinner.succeed();
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
cherrypickSpinner.fail();
|
|
135
|
+
throw e;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async function cherrypickAndHandleConflicts(options, commit, targetBranch, cherrypickSpinner, gitConfigAuthor) {
|
|
139
|
+
const mergedTargetPullRequest = commit.expectedTargetPullRequests.find((pr) => pr.state === 'MERGED' && pr.branch === targetBranch);
|
|
140
|
+
const commitAuthor = getCommitAuthor({ options, gitConfigAuthor, commit });
|
|
102
141
|
let conflictingFiles;
|
|
103
142
|
let unstagedFiles;
|
|
104
143
|
let needsResolving;
|
|
105
|
-
const commitAuthor = getCommitAuthor({
|
|
106
|
-
options,
|
|
107
|
-
gitConfigAuthor,
|
|
108
|
-
commit,
|
|
109
|
-
});
|
|
110
144
|
try {
|
|
111
|
-
await (0, git_1.fetchBranch)(options, commit.sourceBranch);
|
|
112
145
|
({ conflictingFiles, unstagedFiles, needsResolving } = await (0, git_1.cherrypick)({
|
|
113
146
|
options,
|
|
114
147
|
sha: commit.sourceCommit.sha,
|
|
@@ -117,7 +150,6 @@ async function waitForCherrypick(options, commit, targetBranch, gitConfigAuthor)
|
|
|
117
150
|
}));
|
|
118
151
|
// no conflicts encountered
|
|
119
152
|
if (!needsResolving) {
|
|
120
|
-
cherrypickSpinner.succeed();
|
|
121
153
|
return;
|
|
122
154
|
}
|
|
123
155
|
// cherrypick failed due to conflicts
|
|
@@ -179,17 +211,6 @@ async function waitForCherrypick(options, commit, targetBranch, gitConfigAuthor)
|
|
|
179
211
|
conflictingFiles: conflictingFiles.map((f) => f.absolute),
|
|
180
212
|
unstagedFiles,
|
|
181
213
|
});
|
|
182
|
-
// Conflicts should be resolved and files staged at this point
|
|
183
|
-
const stagingSpinner = (0, ora_1.ora)(options.interactive, `Finalizing cherrypick`).start();
|
|
184
|
-
try {
|
|
185
|
-
// Run `git commit`
|
|
186
|
-
await (0, git_1.commitChanges)(commit, options);
|
|
187
|
-
stagingSpinner.succeed();
|
|
188
|
-
}
|
|
189
|
-
catch (e) {
|
|
190
|
-
stagingSpinner.fail();
|
|
191
|
-
throw e;
|
|
192
|
-
}
|
|
193
214
|
}
|
|
194
215
|
async function listConflictingAndUnstagedFiles({ retries, options, conflictingFiles, unstagedFiles, }) {
|
|
195
216
|
const hasUnstagedFiles = !(0, lodash_1.isEmpty)((0, lodash_1.difference)(unstagedFiles, conflictingFiles));
|
|
@@ -17,6 +17,8 @@ async function exec(cmd, options) {
|
|
|
17
17
|
}
|
|
18
18
|
exports.exec = exec;
|
|
19
19
|
async function spawnPromise(cmd, cmdArgs, cwd) {
|
|
20
|
+
const fullCmd = `${cmd} ${cmdArgs.join(' ')}`;
|
|
21
|
+
logger_1.logger.info(`Running command: "${fullCmd}"`);
|
|
20
22
|
return new Promise(function (resolve, reject) {
|
|
21
23
|
const subprocess = child_process_1.default.spawn(cmd, cmdArgs, { cwd });
|
|
22
24
|
let stderr = '';
|
|
@@ -28,8 +30,6 @@ async function spawnPromise(cmd, cmdArgs, cwd) {
|
|
|
28
30
|
stderr += data;
|
|
29
31
|
});
|
|
30
32
|
subprocess.on('close', (code) => {
|
|
31
|
-
const fullCmd = `${cmd} ${cmdArgs.join(' ')}`;
|
|
32
|
-
logger_1.logger.info(`Running command: "${fullCmd}"`);
|
|
33
33
|
if (code === 0 || code === null) {
|
|
34
34
|
resolve({ cmdArgs, code, stderr, stdout });
|
|
35
35
|
}
|
package/dist/lib/git.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare function deleteRemote(options: ValidConfigOptions, remoteName: st
|
|
|
27
27
|
export declare function addRemote(options: ValidConfigOptions, remoteName: string): Promise<void>;
|
|
28
28
|
export declare function fetchBranch(options: ValidConfigOptions, branch: string): Promise<void>;
|
|
29
29
|
export declare function getIsMergeCommit(options: ValidConfigOptions, sha: string): Promise<boolean>;
|
|
30
|
-
export declare function
|
|
30
|
+
export declare function getShasInMergeCommit(options: ValidConfigOptions, sha: string): Promise<string[]>;
|
|
31
31
|
export declare function cherrypick({ options, sha, mergedTargetPullRequest, commitAuthor, }: {
|
|
32
32
|
options: ValidConfigOptions;
|
|
33
33
|
sha: string;
|
|
@@ -55,10 +55,11 @@ export declare function getGitConfig({ dir, key, }: {
|
|
|
55
55
|
dir: string;
|
|
56
56
|
key: 'user.name' | 'user.email';
|
|
57
57
|
}): Promise<string | undefined>;
|
|
58
|
-
export declare function createBackportBranch({ options,
|
|
58
|
+
export declare function createBackportBranch({ options, sourceBranch, backportBranch, targetBranch, }: {
|
|
59
59
|
options: ValidConfigOptions;
|
|
60
|
-
|
|
60
|
+
sourceBranch: string;
|
|
61
61
|
backportBranch: string;
|
|
62
|
+
targetBranch: string;
|
|
62
63
|
}): Promise<void>;
|
|
63
64
|
export declare function deleteBackportBranch({ options, backportBranch, }: {
|
|
64
65
|
options: ValidConfigOptions;
|
package/dist/lib/git.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLocalSourceRepoPath = exports.pushBackportBranch = exports.getRepoForkOwner = exports.deleteBackportBranch = exports.createBackportBranch = exports.getGitConfig = exports.getUnstagedFiles = exports.getConflictingFiles = exports.commitChanges = exports.cherrypick = exports.
|
|
3
|
+
exports.getLocalSourceRepoPath = exports.pushBackportBranch = exports.getRepoForkOwner = exports.deleteBackportBranch = exports.createBackportBranch = exports.getGitConfig = exports.getUnstagedFiles = exports.getConflictingFiles = exports.commitChanges = exports.cherrypick = exports.getShasInMergeCommit = exports.getIsMergeCommit = exports.fetchBranch = exports.addRemote = exports.deleteRemote = exports.getIsCommitInBranch = exports.getGitProjectRootPath = exports.getRepoInfoFromGitRemotes = exports.isLocalConfigFileModified = exports.isLocalConfigFileUntracked = exports.getLocalConfigFileCommitDate = exports.cloneRepo = exports.getRemoteUrl = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const lodash_1 = require("lodash");
|
|
6
6
|
const ora_1 = require("../lib/ora");
|
|
@@ -180,7 +180,7 @@ async function getIsMergeCommit(options, sha) {
|
|
|
180
180
|
return res.stdout !== '';
|
|
181
181
|
}
|
|
182
182
|
exports.getIsMergeCommit = getIsMergeCommit;
|
|
183
|
-
async function
|
|
183
|
+
async function getShasInMergeCommit(options, sha) {
|
|
184
184
|
try {
|
|
185
185
|
const cwd = (0, env_1.getRepoPath)(options);
|
|
186
186
|
const res = await (0, child_process_promisified_1.spawnPromise)('git', ['--no-pager', 'log', `${sha}^1..${sha}^2`, '--pretty=format:%H'], cwd);
|
|
@@ -195,30 +195,8 @@ async function getCommitsInMergeCommit(options, sha) {
|
|
|
195
195
|
throw e;
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
|
-
exports.
|
|
199
|
-
async function getShaOrRange(options, sha) {
|
|
200
|
-
if (!options.mainline) {
|
|
201
|
-
try {
|
|
202
|
-
const isMergeCommit = await getIsMergeCommit(options, sha);
|
|
203
|
-
if (isMergeCommit) {
|
|
204
|
-
const shas = await getCommitsInMergeCommit(options, sha);
|
|
205
|
-
return `${(0, lodash_1.last)(shas)}^..${(0, lodash_1.first)(shas)}`;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
catch (e) {
|
|
209
|
-
const isSpawnError = e instanceof child_process_promisified_1.SpawnError;
|
|
210
|
-
// swallow error if it's a 128 exit code
|
|
211
|
-
// exit 128 happens when the cherrypicked commit is empty which is handled below
|
|
212
|
-
// (128 also applies to many other types of errors)
|
|
213
|
-
if (!isSpawnError || e.context.code !== 128) {
|
|
214
|
-
throw e;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return sha;
|
|
219
|
-
}
|
|
198
|
+
exports.getShasInMergeCommit = getShasInMergeCommit;
|
|
220
199
|
async function cherrypick({ options, sha, mergedTargetPullRequest, commitAuthor, }) {
|
|
221
|
-
const shaOrRange = await getShaOrRange(options, sha);
|
|
222
200
|
const cmdArgs = [
|
|
223
201
|
'-c',
|
|
224
202
|
`user.name="${commitAuthor.name}"`,
|
|
@@ -229,7 +207,8 @@ async function cherrypick({ options, sha, mergedTargetPullRequest, commitAuthor,
|
|
|
229
207
|
? ['--mainline', `${options.mainline}`]
|
|
230
208
|
: []),
|
|
231
209
|
...(options.cherrypickRef === false ? [] : ['-x']),
|
|
232
|
-
|
|
210
|
+
...(options.signoff ? ['--signoff'] : []),
|
|
211
|
+
sha,
|
|
233
212
|
];
|
|
234
213
|
try {
|
|
235
214
|
const cwd = (0, env_1.getRepoPath)(options);
|
|
@@ -359,13 +338,18 @@ exports.getGitConfig = getGitConfig;
|
|
|
359
338
|
// How the commit flows:
|
|
360
339
|
// ${sourceBranch} -> ${backportBranch} -> ${targetBranch}
|
|
361
340
|
// master -> backport/7.x/pr-1234 -> 7.x
|
|
362
|
-
async function createBackportBranch({ options,
|
|
341
|
+
async function createBackportBranch({ options, sourceBranch, backportBranch, targetBranch, }) {
|
|
363
342
|
const spinner = (0, ora_1.ora)(options.interactive, 'Pulling latest changes').start();
|
|
364
343
|
try {
|
|
365
344
|
const cwd = (0, env_1.getRepoPath)(options);
|
|
366
345
|
await (0, child_process_promisified_1.spawnPromise)('git', ['reset', '--hard'], cwd);
|
|
367
346
|
await (0, child_process_promisified_1.spawnPromise)('git', ['clean', '-d', '--force'], cwd);
|
|
368
|
-
|
|
347
|
+
// create tmp branch. This can be necessary when fetching to the currently selected branch
|
|
348
|
+
const tmpBranchName = '__backport_tool_tmp';
|
|
349
|
+
await (0, child_process_promisified_1.spawnPromise)('git', ['checkout', '-B', tmpBranchName], cwd);
|
|
350
|
+
// fetch target branch
|
|
351
|
+
await fetchBranch(options, targetBranch);
|
|
352
|
+
// checkout backport branch and point it to target branch
|
|
369
353
|
await (0, child_process_promisified_1.spawnPromise)('git', [
|
|
370
354
|
'checkout',
|
|
371
355
|
'-B',
|
|
@@ -373,6 +357,15 @@ async function createBackportBranch({ options, targetBranch, backportBranch, })
|
|
|
373
357
|
`${options.repoOwner}/${targetBranch}`,
|
|
374
358
|
'--no-track',
|
|
375
359
|
], cwd);
|
|
360
|
+
// delete tmp branch (if it still exists)
|
|
361
|
+
try {
|
|
362
|
+
await (0, child_process_promisified_1.spawnPromise)('git', ['branch', '-D', tmpBranchName], cwd);
|
|
363
|
+
}
|
|
364
|
+
catch (e) {
|
|
365
|
+
//
|
|
366
|
+
}
|
|
367
|
+
// fetch commits for source branch
|
|
368
|
+
await fetchBranch(options, sourceBranch);
|
|
376
369
|
spinner.succeed();
|
|
377
370
|
}
|
|
378
371
|
catch (e) {
|
|
@@ -420,7 +413,7 @@ async function pushBackportBranch({ options, backportBranch, }) {
|
|
|
420
413
|
spinner.fail();
|
|
421
414
|
if (e instanceof child_process_promisified_1.SpawnError &&
|
|
422
415
|
e.context.stderr.toLowerCase().includes(`repository not found`)) {
|
|
423
|
-
throw new BackportError_1.BackportError(`Error pushing to https://github.com/${repoForkOwner}/${options.repoName}. Repository does not exist. Either fork the repository (https://github.com/${options.repoOwner}/${options.repoName}) or disable fork mode via "--no-fork".\nRead more about fork mode in the docs: https://github.com/sqren/backport/blob/main/docs/
|
|
416
|
+
throw new BackportError_1.BackportError(`Error pushing to https://github.com/${repoForkOwner}/${options.repoName}. Repository does not exist. Either fork the repository (https://github.com/${options.repoOwner}/${options.repoName}) or disable fork mode via "--no-fork".\nRead more about fork mode in the docs: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#fork`);
|
|
424
417
|
}
|
|
425
418
|
if (e instanceof child_process_promisified_1.SpawnError &&
|
|
426
419
|
e.context.stderr.includes(`could not read Username for`)) {
|
|
@@ -121,6 +121,7 @@ describe('git.integration', () => {
|
|
|
121
121
|
repoOwner: 'origin',
|
|
122
122
|
dir: cwd,
|
|
123
123
|
},
|
|
124
|
+
sourceBranch: 'main',
|
|
124
125
|
targetBranch: '7.x',
|
|
125
126
|
backportBranch: 'my-backport-branch',
|
|
126
127
|
});
|
|
@@ -133,6 +134,7 @@ describe('git.integration', () => {
|
|
|
133
134
|
repoOwner: 'origin',
|
|
134
135
|
dir: cwd,
|
|
135
136
|
},
|
|
137
|
+
sourceBranch: 'main',
|
|
136
138
|
targetBranch: 'foo',
|
|
137
139
|
backportBranch: 'my-backport-branch',
|
|
138
140
|
});
|
|
@@ -152,6 +154,7 @@ describe('git.integration', () => {
|
|
|
152
154
|
repoOwner: 'origin',
|
|
153
155
|
dir: cwd,
|
|
154
156
|
},
|
|
157
|
+
sourceBranch: 'main',
|
|
155
158
|
targetBranch: '7.x',
|
|
156
159
|
backportBranch: 'my-backport-branch',
|
|
157
160
|
});
|
|
@@ -169,7 +172,7 @@ describe('git.integration', () => {
|
|
|
169
172
|
});
|
|
170
173
|
}).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
171
174
|
"Error pushing to https://github.com/sqren/repo-with-conflicts. Repository does not exist. Either fork the repository (https://github.com/sqren/repo-with-conflicts) or disable fork mode via \\"--no-fork\\".
|
|
172
|
-
Read more about fork mode in the docs: https://github.com/sqren/backport/blob/main/docs/
|
|
175
|
+
Read more about fork mode in the docs: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#fork"
|
|
173
176
|
`);
|
|
174
177
|
});
|
|
175
178
|
});
|
|
@@ -535,11 +538,11 @@ describe('git.integration', () => {
|
|
|
535
538
|
expect(res).toBe(false);
|
|
536
539
|
});
|
|
537
540
|
});
|
|
538
|
-
describe('
|
|
541
|
+
describe('getShasInMergeCommit', () => {
|
|
539
542
|
it('returns a list of commit hashes - excluding the merge hash itself', async () => {
|
|
540
|
-
const
|
|
541
|
-
expect(
|
|
542
|
-
expect(
|
|
543
|
+
const shas = await (0, git_1.getShasInMergeCommit)({ dir: cwd }, MERGE_COMMIT_HASH_1);
|
|
544
|
+
expect(shas).not.toContain(MERGE_COMMIT_HASH_1);
|
|
545
|
+
expect(shas).toEqual([
|
|
543
546
|
'f9a760e0d9eb3ebcc64f8cb75ce885714b836496',
|
|
544
547
|
'7b92e29e88266004485ce0fae0260605b01df887',
|
|
545
548
|
'a1facf8c006fb815d6a6ecd1b2907e6e64f29576',
|
|
@@ -551,8 +554,8 @@ describe('git.integration', () => {
|
|
|
551
554
|
]);
|
|
552
555
|
});
|
|
553
556
|
it('returns empty for squash commits', async () => {
|
|
554
|
-
const
|
|
555
|
-
expect(
|
|
557
|
+
const shas = await (0, git_1.getShasInMergeCommit)({ dir: cwd }, SQUASH_COMMIT_HASH);
|
|
558
|
+
expect(shas).toEqual([]);
|
|
556
559
|
});
|
|
557
560
|
});
|
|
558
561
|
});
|