backport 7.3.6 → 8.1.0
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 +16 -21
- package/dist/backportRun.d.ts +18 -6
- package/dist/backportRun.js +70 -50
- package/dist/entrypoint.cli.js +4 -8
- package/dist/entrypoint.module.d.ts +13 -6
- package/dist/entrypoint.module.js +17 -19
- package/dist/entrypoint.module.private.test.js +129 -330
- package/dist/errors/BackportError.d.ts +19 -0
- package/dist/errors/BackportError.js +29 -0
- package/dist/lib/BackportError.d.ts +19 -0
- package/dist/lib/BackportError.js +29 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.d.ts +13 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.js +238 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.test.js +321 -0
- package/dist/lib/child-process-promisified.d.ts +25 -0
- package/dist/lib/child-process-promisified.js +58 -0
- package/dist/lib/env.d.ts +7 -0
- package/dist/lib/env.js +33 -0
- package/dist/lib/env.test.d.ts +1 -0
- package/dist/lib/env.test.js +26 -0
- package/dist/lib/getCommits.d.ts +2 -0
- package/dist/lib/getCommits.js +75 -0
- package/dist/lib/getCommitsWithoutBackports.d.ts +11 -0
- package/dist/lib/getCommitsWithoutBackports.js +68 -0
- package/dist/lib/getCommitsWithoutBackports.test.d.ts +1 -0
- package/dist/lib/getCommitsWithoutBackports.test.js +335 -0
- package/dist/lib/getGitConfigAuthor.d.ts +6 -0
- package/dist/lib/getGitConfigAuthor.js +15 -0
- package/dist/lib/getTargetBranches.d.ts +5 -0
- package/dist/lib/getTargetBranches.js +67 -0
- package/dist/lib/getTargetBranches.test.d.ts +1 -0
- package/dist/lib/getTargetBranches.test.js +206 -0
- package/dist/lib/git.d.ts +77 -0
- package/dist/lib/git.js +439 -0
- package/dist/lib/git.private.test.d.ts +1 -0
- package/dist/lib/git.private.test.js +618 -0
- package/dist/lib/git.test.d.ts +1 -0
- package/dist/lib/git.test.js +580 -0
- package/dist/lib/github/commitFormatters.d.ts +3 -0
- package/dist/lib/github/commitFormatters.js +17 -0
- package/dist/lib/github/commitFormatters.test.d.ts +1 -0
- package/dist/lib/github/commitFormatters.test.js +11 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.js +32 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.test.d.ts +1 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.test.js +27 -0
- package/dist/lib/github/v3/addLabelsToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addLabelsToPullRequest.js +30 -0
- package/dist/lib/github/v3/addReviewersToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addReviewersToPullRequest.js +32 -0
- package/dist/lib/github/v3/createPullRequest.d.ts +29 -0
- package/dist/lib/github/v3/createPullRequest.js +91 -0
- package/dist/lib/github/v3/createPullRequest.test.d.ts +1 -0
- package/dist/lib/github/v3/createPullRequest.test.js +377 -0
- package/dist/lib/github/v3/createStatusComment.d.ts +11 -0
- package/dist/lib/github/v3/createStatusComment.js +136 -0
- package/dist/lib/github/v3/createStatusComment.test.d.ts +1 -0
- package/dist/lib/github/v3/createStatusComment.test.js +461 -0
- package/dist/lib/github/v3/getGithubV3ErrorMessage.d.ts +14 -0
- package/dist/lib/github/v3/getGithubV3ErrorMessage.js +16 -0
- package/dist/lib/github/v4/FetchPullRequestId.d.ts +2 -0
- package/dist/lib/github/v4/FetchPullRequestId.js +36 -0
- package/dist/lib/github/v4/apiRequestV4.d.ts +31 -0
- package/dist/lib/github/v4/apiRequestV4.js +71 -0
- package/dist/lib/github/v4/apiRequestV4.test.d.ts +1 -0
- package/dist/lib/github/v4/apiRequestV4.test.js +109 -0
- package/dist/lib/github/v4/disablePullRequestAutoMerge.d.ts +2 -0
- package/dist/lib/github/v4/disablePullRequestAutoMerge.js +32 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.d.ts +2 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.js +50 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.js +112 -0
- package/dist/lib/github/v4/fetchAuthorId.d.ts +10 -0
- package/dist/lib/github/v4/fetchAuthorId.js +28 -0
- package/dist/lib/github/v4/fetchAuthorId.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchAuthorId.private.test.js +25 -0
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +93 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +11 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.js +58 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +136 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.d.ts +11 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.js +48 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.js +118 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +29 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.js +110 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +196 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +157 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +107 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +12 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +69 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.d.ts +9 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.js +64 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.private.test.js +44 -0
- package/dist/lib/github/v4/fetchPullRequestAutoMergeMethod.d.ts +2 -0
- package/dist/lib/github/v4/fetchPullRequestAutoMergeMethod.js +39 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.d.ts +8 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.js +49 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.private.test.js +49 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +72 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +78 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +116 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.d.ts +16 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.js +29 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.js +61 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +1 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +72 -0
- package/dist/lib/github/v4/mocks/commitsByAuthorMock.d.ts +2 -0
- package/dist/lib/github/v4/mocks/commitsByAuthorMock.js +176 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.d.ts +7 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.js +45 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.test.d.ts +1 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.test.js +87 -0
- package/dist/lib/logger.d.ts +9 -0
- package/dist/lib/logger.js +74 -0
- package/dist/lib/ora.d.ts +2 -0
- package/dist/lib/ora.js +21 -0
- package/dist/lib/prompt.test.d.ts +1 -0
- package/dist/lib/prompt.test.js +139 -0
- package/dist/lib/prompts.d.ts +17 -0
- package/dist/lib/prompts.js +132 -0
- package/dist/lib/remoteConfig.d.ts +20 -0
- package/dist/lib/remoteConfig.js +52 -0
- package/dist/lib/sequentially.d.ts +1 -0
- package/dist/lib/sequentially.js +10 -0
- package/dist/lib/setupRepo.d.ts +2 -0
- package/dist/lib/setupRepo.js +56 -0
- package/dist/lib/setupRepo.test.d.ts +1 -0
- package/dist/lib/setupRepo.test.js +278 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.d.ts +16 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.js +102 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.js +467 -0
- package/dist/lib/sourceCommit/getMockSourceCommit.d.ts +26 -0
- package/dist/lib/sourceCommit/getMockSourceCommit.js +103 -0
- package/dist/lib/sourceCommit/parseSourceCommit.d.ts +108 -0
- package/dist/lib/sourceCommit/parseSourceCommit.js +123 -0
- package/dist/lib/sourceCommit/parseSourceCommit.test.d.ts +1 -0
- package/dist/lib/sourceCommit/parseSourceCommit.test.js +226 -0
- package/dist/options/ConfigOptions.d.ts +6 -4
- package/dist/options/cliArgs.d.ts +16 -9
- package/dist/options/cliArgs.js +54 -28
- package/dist/options/cliArgs.test.js +128 -4
- package/dist/options/config/config.d.ts +7 -6
- package/dist/options/config/config.js +5 -7
- package/dist/options/config/config.test.js +0 -1
- package/dist/options/config/globalConfig.d.ts +5 -3
- package/dist/options/config/globalConfig.js +17 -14
- package/dist/options/config/projectConfig.d.ts +2 -2
- package/dist/options/config/projectConfig.js +3 -3
- package/dist/options/config/projectConfig.test.js +19 -7
- package/dist/options/config/readConfigFile.d.ts +9 -7
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +44 -9
- package/dist/options/options.js +22 -27
- package/dist/options/options.test.js +119 -58
- package/dist/runSequentially.d.ts +14 -7
- package/dist/runSequentially.js +26 -11
- package/dist/scripts/postinstall.js +4 -3
- package/dist/scripts/postinstall.test.js +6 -2
- package/dist/services/BackportError.d.ts +19 -0
- package/dist/services/BackportError.js +29 -0
- package/dist/services/HandledBackportError.d.ts +19 -0
- package/dist/services/HandledBackportError.js +29 -0
- package/dist/services/HandledError.d.ts +7 -3
- package/dist/services/HandledError.js +13 -13
- package/dist/services/child-process-promisified.d.ts +19 -3
- package/dist/services/child-process-promisified.js +46 -17
- package/dist/services/git.d.ts +6 -7
- package/dist/services/git.integration.test.js +381 -65
- package/dist/services/git.js +189 -127
- package/dist/services/git.private.test.d.ts +1 -0
- package/dist/services/git.private.test.js +618 -0
- package/dist/services/git.test.js +167 -158
- package/dist/services/github/v3/addAssigneesToPullRequest.js +1 -1
- package/dist/services/github/v3/addLabelsToPullRequest.js +1 -1
- package/dist/services/github/v3/addReviewersToPullRequest.js +2 -1
- package/dist/services/github/v3/createPullRequest.js +4 -2
- package/dist/services/github/v3/createStatusComment.js +17 -17
- package/dist/services/github/v3/createStatusComment.test.js +22 -9
- package/dist/services/github/v4/apiRequestV4.js +8 -11
- package/dist/services/github/v4/apiRequestV4.test.js +2 -2
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +2 -4
- package/dist/services/github/v4/fetchAuthorId.private.test.js +3 -6
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +5 -6
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +4 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +10 -9
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +10 -9
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +4 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +9 -8
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +3 -6
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +3 -2
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +3 -6
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +4 -7
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +2 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +2 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +6 -7
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +9 -8
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +5 -5
- package/dist/services/logger.d.ts +1 -4
- package/dist/services/logger.js +14 -19
- package/dist/services/test.d.ts +1 -0
- package/dist/services/test.js +23 -0
- package/dist/state.d.ts +0 -0
- package/dist/state.js +1 -0
- package/dist/test/e2e/cli/commit-author.private.test.js +4 -4
- package/dist/test/e2e/cli/different-merge-strategies.private.test.js +26 -24
- package/dist/test/e2e/cli/entrypoint.cli.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +450 -0
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +27 -28
- package/dist/test/e2e/cli/runBackportViaCli.d.ts +6 -2
- package/dist/test/e2e/cli/runBackportViaCli.js +44 -23
- package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +22 -14
- package/dist/test/e2e/module/entrypoint.module.mutation.test.d.ts +1 -0
- package/dist/test/e2e/module/entrypoint.module.mutation.test.js +376 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.js +12 -10
- package/dist/test/sandbox.js +5 -1
- package/dist/test/setupFiles/automatic-mocks.js +17 -13
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +11 -7
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +7 -159
- package/dist/ui/getCommits.js +2 -2
- package/dist/ui/getCommitsWithoutBackports.test.js +5 -1
- package/dist/ui/getGitConfigAuthor.js +1 -1
- package/dist/ui/getTargetBranches.js +3 -3
- package/dist/ui/getTargetBranches.test.js +5 -1
- package/dist/ui/ora.d.ts +1 -8
- package/dist/ui/setupRepo.js +3 -3
- package/dist/ui/setupRepo.test.js +98 -61
- package/dist/utils/isErrnoError.d.ts +2 -0
- package/dist/utils/isErrnoError.js +7 -0
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +17 -17
- package/yarn.lock +461 -695
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
## 🎉 New! The Backport Tool as a Github Action 🎉
|
|
10
10
|
|
|
11
|
-
A [Github Action](https://github.com/
|
|
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
|
|
|
13
13
|
# Backport CLI tool
|
|
14
14
|
|
|
@@ -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](https://github.com/sqren/backport/blob/
|
|
36
|
+
After installation you should add an access token to the [global config](https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson) in `~/.backport/config.json`. See the [documentation](https://github.com/sqren/backport/blob/main/docs/configuration.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](https://github.com/sqren/backport/blob/
|
|
44
|
+
Add a [project config](https://github.com/sqren/backport/blob/main/docs/configuration.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/master/docs/config
|
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
Add personal access token to [global config](https://github.com/sqren/backport/blob/
|
|
63
|
+
Add personal access token to [global config](https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson):
|
|
64
64
|
|
|
65
65
|
```js
|
|
66
66
|
// ~/.backport/config.json
|
|
@@ -79,7 +79,7 @@ _This will start an interactive prompt. You can use your keyboards arrow keys to
|
|
|
79
79
|
|
|
80
80
|
### Config options
|
|
81
81
|
|
|
82
|
-
See [configuration.md](https://github.com/sqren/backport/blob/
|
|
82
|
+
See [configuration.md](https://github.com/sqren/backport/blob/main/docs/configuration.md)
|
|
83
83
|
|
|
84
84
|
### CLI options
|
|
85
85
|
|
|
@@ -91,13 +91,13 @@ See [configuration.md](https://github.com/sqren/backport/blob/master/docs/config
|
|
|
91
91
|
| --author | | Filter commits by Github username. Opposite of `--all` | _Current user_ |
|
|
92
92
|
| --auto-assign | | Assign current user to the target PR | false |
|
|
93
93
|
| --branch | -b | Target branch to backport to | |
|
|
94
|
-
| --ci | | Disable interactive prompts | false |
|
|
95
94
|
| --config-file | | Custom path to project config file (.backportrc.json) | |
|
|
96
95
|
| --dir | | Clone repository into custom directory | ~/.backport/repositories/ |
|
|
97
96
|
| --dry-run | | Perform backport without pushing to Github | false |
|
|
98
97
|
| --editor | | Editor (eg. `code`) to open and resolve conflicts | nano |
|
|
99
98
|
| --fork | | Create backports in fork repo | true |
|
|
100
99
|
| --git-hostname | | Hostname for Git | github.com |
|
|
100
|
+
| --interactive | | Enable interactive prompts | true |
|
|
101
101
|
| --mainline | | Parent id of merge commit | 1 |
|
|
102
102
|
| --max-number | --number, -n | Number of commits to choose from | 10 |
|
|
103
103
|
| --multiple | | Multi-select for commits and branches | false |
|
|
@@ -124,7 +124,7 @@ See [configuration.md](https://github.com/sqren/backport/blob/master/docs/config
|
|
|
124
124
|
| --help | | Show help | |
|
|
125
125
|
| -v, --version | | Show version number | |
|
|
126
126
|
|
|
127
|
-
The CLI options will override the [configuration options](https://github.com/sqren/backport/blob/
|
|
127
|
+
The CLI options will override the [configuration options](https://github.com/sqren/backport/blob/main/docs/configuration.md).
|
|
128
128
|
|
|
129
129
|
## Backport Module API
|
|
130
130
|
|
|
@@ -153,8 +153,8 @@ Filter commits by pull request number
|
|
|
153
153
|
`sha` _string_<br/>
|
|
154
154
|
Filter commits by commit sha
|
|
155
155
|
|
|
156
|
-
`
|
|
157
|
-
|
|
156
|
+
`interactive` _boolean_<br/>
|
|
157
|
+
Enable interactive prompts
|
|
158
158
|
|
|
159
159
|
#### Example
|
|
160
160
|
|
|
@@ -162,14 +162,13 @@ Enabling this will disable the interactive prompts
|
|
|
162
162
|
import { backportRun } from 'backport';
|
|
163
163
|
|
|
164
164
|
const result = await backportRun({
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
autoMergeMethod: 'squash',
|
|
165
|
+
options: {
|
|
166
|
+
accessToken: 'very secret',
|
|
167
|
+
repoName: 'kibana',
|
|
168
|
+
repoOwner: 'elastic',
|
|
169
|
+
pullNumber: 121633,
|
|
170
|
+
interactive: false,
|
|
171
|
+
},
|
|
173
172
|
});
|
|
174
173
|
|
|
175
174
|
console.log(result);
|
|
@@ -244,10 +243,6 @@ console.log(commits);
|
|
|
244
243
|
*/
|
|
245
244
|
```
|
|
246
245
|
|
|
247
|
-
## The Backport Tool as a Github Action
|
|
248
|
-
|
|
249
|
-
A [Github Action](https://github.com/elastic/kibana-github-actions/tree/main/backport) around The Backport Tool for automatically creating backports when pull requests are merged.
|
|
250
|
-
|
|
251
246
|
## What is backporting?
|
|
252
247
|
|
|
253
248
|
> 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.
|
package/dist/backportRun.d.ts
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
1
|
+
import { BackportError } from './lib/BackportError';
|
|
2
|
+
import { Commit } from './lib/sourceCommit/parseSourceCommit';
|
|
1
3
|
import { ConfigFileOptions } from './options/ConfigOptions';
|
|
2
4
|
import { Result } from './runSequentially';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
export declare type BackportAbortResponse = {
|
|
6
|
+
status: 'aborted';
|
|
7
|
+
commits: Commit[];
|
|
8
|
+
error: BackportError;
|
|
9
|
+
errorMessage: string;
|
|
10
|
+
};
|
|
11
|
+
export declare type BackportSuccessResponse = {
|
|
6
12
|
status: 'success';
|
|
7
13
|
commits: Commit[];
|
|
8
14
|
results: Result[];
|
|
9
|
-
}
|
|
15
|
+
};
|
|
16
|
+
export declare type BackportFailureResponse = {
|
|
10
17
|
status: 'failure';
|
|
11
18
|
commits: Commit[];
|
|
12
|
-
error: Error |
|
|
19
|
+
error: Error | BackportError;
|
|
13
20
|
errorMessage: string;
|
|
14
21
|
};
|
|
15
|
-
export declare
|
|
22
|
+
export declare type BackportResponse = BackportSuccessResponse | BackportFailureResponse | BackportAbortResponse;
|
|
23
|
+
export declare function backportRun({ processArgs, optionsFromModule, exitCodeOnFailure, }: {
|
|
24
|
+
processArgs: string[];
|
|
25
|
+
optionsFromModule?: ConfigFileOptions;
|
|
26
|
+
exitCodeOnFailure: boolean;
|
|
27
|
+
}): Promise<BackportResponse>;
|
package/dist/backportRun.js
CHANGED
|
@@ -5,47 +5,56 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.backportRun = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const
|
|
8
|
+
const BackportError_1 = require("./lib/BackportError");
|
|
9
|
+
const env_1 = require("./lib/env");
|
|
10
|
+
const getCommits_1 = require("./lib/getCommits");
|
|
11
|
+
const getGitConfigAuthor_1 = require("./lib/getGitConfigAuthor");
|
|
12
|
+
const getTargetBranches_1 = require("./lib/getTargetBranches");
|
|
13
|
+
const createStatusComment_1 = require("./lib/github/v3/createStatusComment");
|
|
14
|
+
const apiRequestV4_1 = require("./lib/github/v4/apiRequestV4");
|
|
15
|
+
const logger_1 = require("./lib/logger");
|
|
16
|
+
const ora_1 = require("./lib/ora");
|
|
17
|
+
const setupRepo_1 = require("./lib/setupRepo");
|
|
18
|
+
const cliArgs_1 = require("./options/cliArgs");
|
|
9
19
|
const options_1 = require("./options/options");
|
|
10
20
|
const runSequentially_1 = require("./runSequentially");
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
spinner.start('Initializing...');
|
|
21
|
+
async function backportRun({ processArgs, optionsFromModule = {}, exitCodeOnFailure, }) {
|
|
22
|
+
const { interactive, logFilePath } = (0, cliArgs_1.getEarlyArguments)(processArgs, optionsFromModule);
|
|
23
|
+
const logger = (0, logger_1.initLogger)({ interactive, logFilePath });
|
|
24
|
+
let optionsFromCliArgs;
|
|
25
|
+
try {
|
|
26
|
+
optionsFromCliArgs = (0, cliArgs_1.getOptionsFromCliArgs)(processArgs);
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
if (e instanceof Error) {
|
|
30
|
+
(0, logger_1.consoleLog)(e.message);
|
|
31
|
+
(0, logger_1.consoleLog)(`Run "backport --help" to see all options`);
|
|
32
|
+
return {
|
|
33
|
+
status: 'failure',
|
|
34
|
+
error: e,
|
|
35
|
+
errorMessage: e.message,
|
|
36
|
+
commits: [],
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
throw e;
|
|
31
40
|
}
|
|
32
41
|
let options = null;
|
|
33
42
|
let commits = [];
|
|
43
|
+
const spinner = (0, ora_1.ora)(interactive).start('Initializing...');
|
|
34
44
|
try {
|
|
35
|
-
options = await (0, options_1.getOptions)(
|
|
36
|
-
|
|
45
|
+
options = await (0, options_1.getOptions)({
|
|
46
|
+
optionsFromCliArgs,
|
|
47
|
+
optionsFromModule,
|
|
48
|
+
});
|
|
49
|
+
logger.info('Backporting options', options);
|
|
37
50
|
spinner.stop();
|
|
38
51
|
commits = await (0, getCommits_1.getCommits)(options);
|
|
39
|
-
|
|
52
|
+
logger.info('Commits', commits);
|
|
40
53
|
if (options.ls) {
|
|
41
|
-
return {
|
|
42
|
-
status: 'success',
|
|
43
|
-
commits,
|
|
44
|
-
results: [],
|
|
45
|
-
};
|
|
54
|
+
return { status: 'success', commits, results: [] };
|
|
46
55
|
}
|
|
47
56
|
const targetBranches = await (0, getTargetBranches_1.getTargetBranches)(options, commits);
|
|
48
|
-
|
|
57
|
+
logger.info('Target branches', targetBranches);
|
|
49
58
|
const [gitConfigAuthor] = await Promise.all([
|
|
50
59
|
(0, getGitConfigAuthor_1.getGitConfigAuthor)(options),
|
|
51
60
|
(0, setupRepo_1.setupRepo)(options),
|
|
@@ -56,43 +65,54 @@ async function backportRun(processArgs, optionsFromModule = {}) {
|
|
|
56
65
|
targetBranches,
|
|
57
66
|
gitConfigAuthor,
|
|
58
67
|
});
|
|
59
|
-
|
|
68
|
+
logger.info('Results', results);
|
|
60
69
|
const backportResponse = {
|
|
61
70
|
status: 'success',
|
|
62
71
|
commits,
|
|
63
72
|
results,
|
|
64
73
|
};
|
|
65
|
-
await (0, createStatusComment_1.createStatusComment)({
|
|
66
|
-
options,
|
|
67
|
-
backportResponse,
|
|
68
|
-
});
|
|
74
|
+
await (0, createStatusComment_1.createStatusComment)({ options, backportResponse });
|
|
69
75
|
return backportResponse;
|
|
70
76
|
}
|
|
71
77
|
catch (e) {
|
|
72
78
|
spinner.stop();
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
let backportResponse;
|
|
80
|
+
if (e instanceof BackportError_1.BackportError &&
|
|
81
|
+
e.errorContext.code === 'no-branches-exception') {
|
|
82
|
+
backportResponse = {
|
|
83
|
+
status: 'aborted',
|
|
84
|
+
commits,
|
|
85
|
+
error: e,
|
|
86
|
+
errorMessage: e.message,
|
|
87
|
+
};
|
|
88
|
+
// this will catch both BackportError and Error
|
|
89
|
+
}
|
|
90
|
+
else if (e instanceof Error) {
|
|
91
|
+
backportResponse = {
|
|
92
|
+
status: 'failure',
|
|
93
|
+
commits,
|
|
94
|
+
error: e,
|
|
95
|
+
errorMessage: e.message,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
throw e;
|
|
100
|
+
}
|
|
79
101
|
if (options) {
|
|
80
|
-
await (0, createStatusComment_1.createStatusComment)({
|
|
81
|
-
options,
|
|
82
|
-
backportResponse,
|
|
83
|
-
});
|
|
102
|
+
await (0, createStatusComment_1.createStatusComment)({ options, backportResponse });
|
|
84
103
|
}
|
|
85
|
-
|
|
86
|
-
|
|
104
|
+
outputError({ e, logFilePath });
|
|
105
|
+
// only change exit code for failures while in cli mode
|
|
106
|
+
if (exitCodeOnFailure && backportResponse.status === 'failure') {
|
|
107
|
+
process.exitCode = 1;
|
|
87
108
|
}
|
|
88
|
-
|
|
89
|
-
process.exitCode = 1;
|
|
109
|
+
logger.error('Unhandled exception', e);
|
|
90
110
|
return backportResponse;
|
|
91
111
|
}
|
|
92
112
|
}
|
|
93
113
|
exports.backportRun = backportRun;
|
|
94
114
|
function outputError({ e, logFilePath, }) {
|
|
95
|
-
if (e instanceof
|
|
115
|
+
if (e instanceof BackportError_1.BackportError || e instanceof apiRequestV4_1.GithubV4Exception) {
|
|
96
116
|
(0, logger_1.consoleLog)(e.message);
|
|
97
117
|
return;
|
|
98
118
|
}
|
package/dist/entrypoint.cli.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const yargs_parser_1 = __importDefault(require("yargs-parser"));
|
|
7
3
|
const backportRun_1 = require("./backportRun");
|
|
4
|
+
const cliArgs_1 = require("./options/cliArgs");
|
|
8
5
|
const processArgs = process.argv.slice(2);
|
|
9
6
|
// this is the entrypoint when running from command line
|
|
10
|
-
(0, backportRun_1.backportRun)(processArgs).then((backportResponse) => {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
if (ci || ls) {
|
|
7
|
+
(0, backportRun_1.backportRun)({ processArgs, exitCodeOnFailure: true }).then((backportResponse) => {
|
|
8
|
+
const { interactive, ls } = (0, cliArgs_1.getEarlyArguments)(processArgs);
|
|
9
|
+
if (!interactive || ls) {
|
|
14
10
|
// eslint-disable-next-line no-console
|
|
15
11
|
console.log(JSON.stringify(backportResponse));
|
|
16
12
|
}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
+
import { BackportResponse } from './backportRun';
|
|
2
|
+
import type { Commit } from './lib/sourceCommit/parseSourceCommit';
|
|
1
3
|
import { ConfigFileOptions } from './options/ConfigOptions';
|
|
2
4
|
import { ValidConfigOptions } from './options/options';
|
|
3
|
-
|
|
4
|
-
export { BackportResponse } from './backportRun';
|
|
5
|
-
export {
|
|
6
|
-
export { Commit };
|
|
7
|
-
export {
|
|
5
|
+
export type { HandledErrorResult, SuccessResult, UnhandledErrorResult, } from './runSequentially';
|
|
6
|
+
export type { BackportAbortResponse, BackportFailureResponse, BackportResponse, BackportSuccessResponse, } from './backportRun';
|
|
7
|
+
export { BackportError } from './lib/BackportError';
|
|
8
|
+
export type { Commit } from './lib/sourceCommit/parseSourceCommit';
|
|
9
|
+
export type { ConfigFileOptions } from './options/ConfigOptions';
|
|
10
|
+
export { fetchRemoteProjectConfig as getRemoteProjectConfig } from './lib/github/v4/fetchRemoteProjectConfig';
|
|
8
11
|
export { getGlobalConfig as getLocalGlobalConfig } from './options/config/globalConfig';
|
|
9
|
-
export declare function backportRun(options
|
|
12
|
+
export declare function backportRun({ options, processArgs, exitCodeOnFailure, }: {
|
|
13
|
+
options: ConfigFileOptions;
|
|
14
|
+
processArgs?: string[];
|
|
15
|
+
exitCodeOnFailure?: boolean;
|
|
16
|
+
}): Promise<BackportResponse>;
|
|
10
17
|
export declare function getCommits(options: {
|
|
11
18
|
accessToken: string;
|
|
12
19
|
repoName: string;
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCommits = exports.backportRun = exports.getLocalGlobalConfig = exports.getRemoteProjectConfig = void 0;
|
|
3
|
+
exports.getCommits = exports.backportRun = exports.getLocalGlobalConfig = exports.getRemoteProjectConfig = exports.BackportError = void 0;
|
|
4
4
|
const backportRun_1 = require("./backportRun");
|
|
5
|
-
const fetchCommitByPullNumber_1 = require("./
|
|
6
|
-
const fetchCommitBySha_1 = require("./
|
|
7
|
-
const fetchCommitsByAuthor_1 = require("./
|
|
8
|
-
const fetchPullRequestsBySearchQuery_1 = require("./
|
|
9
|
-
const getOptionsFromGithub_1 = require("./
|
|
10
|
-
const logger_1 = require("./
|
|
5
|
+
const fetchCommitByPullNumber_1 = require("./lib/github/v4/fetchCommits/fetchCommitByPullNumber");
|
|
6
|
+
const fetchCommitBySha_1 = require("./lib/github/v4/fetchCommits/fetchCommitBySha");
|
|
7
|
+
const fetchCommitsByAuthor_1 = require("./lib/github/v4/fetchCommits/fetchCommitsByAuthor");
|
|
8
|
+
const fetchPullRequestsBySearchQuery_1 = require("./lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery");
|
|
9
|
+
const getOptionsFromGithub_1 = require("./lib/github/v4/getOptionsFromGithub/getOptionsFromGithub");
|
|
10
|
+
const logger_1 = require("./lib/logger");
|
|
11
11
|
const excludeUndefined_1 = require("./utils/excludeUndefined");
|
|
12
|
-
var
|
|
12
|
+
var BackportError_1 = require("./lib/BackportError");
|
|
13
|
+
Object.defineProperty(exports, "BackportError", { enumerable: true, get: function () { return BackportError_1.BackportError; } });
|
|
14
|
+
var fetchRemoteProjectConfig_1 = require("./lib/github/v4/fetchRemoteProjectConfig");
|
|
13
15
|
Object.defineProperty(exports, "getRemoteProjectConfig", { enumerable: true, get: function () { return fetchRemoteProjectConfig_1.fetchRemoteProjectConfig; } });
|
|
14
16
|
var globalConfig_1 = require("./options/config/globalConfig");
|
|
15
17
|
Object.defineProperty(exports, "getLocalGlobalConfig", { enumerable: true, get: function () { return globalConfig_1.getGlobalConfig; } });
|
|
16
|
-
function backportRun(options,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// backportRun(options, args)
|
|
23
|
-
//
|
|
24
|
-
processArgs = []) {
|
|
25
|
-
return (0, backportRun_1.backportRun)(processArgs, (0, excludeUndefined_1.excludeUndefined)(options));
|
|
18
|
+
function backportRun({ options, processArgs = [], exitCodeOnFailure = true, }) {
|
|
19
|
+
return (0, backportRun_1.backportRun)({
|
|
20
|
+
optionsFromModule: (0, excludeUndefined_1.excludeUndefined)(options),
|
|
21
|
+
processArgs,
|
|
22
|
+
exitCodeOnFailure,
|
|
23
|
+
});
|
|
26
24
|
}
|
|
27
25
|
exports.backportRun = backportRun;
|
|
28
26
|
async function getCommits(options) {
|
|
29
|
-
(0, logger_1.initLogger)({
|
|
27
|
+
(0, logger_1.initLogger)({ interactive: false, accessToken: options.accessToken });
|
|
30
28
|
const optionsFromGithub = await (0, getOptionsFromGithub_1.getOptionsFromGithub)(options);
|
|
31
29
|
if (options.pullNumber) {
|
|
32
30
|
return [
|