backport 7.4.0 → 8.2.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 +15 -16
- package/dist/backportRun.d.ts +12 -6
- package/dist/backportRun.js +64 -62
- package/dist/entrypoint.cli.js +4 -8
- package/dist/entrypoint.module.d.ts +13 -6
- package/dist/entrypoint.module.js +14 -20
- package/dist/entrypoint.module.private.test.js +47 -346
- 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 +11 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.js +242 -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 +60 -0
- package/dist/lib/env.d.ts +9 -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 +210 -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 +138 -0
- package/dist/lib/github/v3/createStatusComment.test.d.ts +1 -0
- package/dist/lib/github/v3/createStatusComment.test.js +566 -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/github/v4/validateTargetBranches.d.ts +14 -0
- package/dist/lib/github/v4/validateTargetBranches.js +46 -0
- package/dist/lib/github/v4/validateTargetBranches.private.test.d.ts +1 -0
- package/dist/lib/github/v4/validateTargetBranches.private.test.js +51 -0
- package/dist/lib/logger.d.ts +11 -0
- package/dist/lib/logger.js +80 -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 +4 -2
- package/dist/options/cliArgs.d.ts +14 -6
- package/dist/options/cliArgs.js +50 -22
- package/dist/options/cliArgs.test.js +128 -4
- package/dist/options/config/config.d.ts +5 -4
- package/dist/options/config/config.js +3 -5
- 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/readConfigFile.d.ts +5 -3
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +41 -5
- package/dist/options/options.js +24 -24
- package/dist/options/options.test.js +117 -55
- package/dist/runSequentially.d.ts +14 -9
- package/dist/runSequentially.js +27 -12
- 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 +2 -2
- package/dist/services/HandledError.js +7 -7
- 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 -123
- 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 -124
- 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 +16 -17
- package/dist/services/github/v3/createStatusComment.test.js +20 -9
- package/dist/services/github/v4/apiRequestV4.js +2 -2
- package/dist/services/github/v4/apiRequestV4.test.js +2 -2
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +2 -4
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +4 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +5 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +5 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +4 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +5 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +3 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +2 -2
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +5 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +5 -5
- package/dist/services/logger.js +5 -1
- 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 +27 -25
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +53 -75
- package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.js +80 -0
- package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.js +199 -0
- package/dist/test/e2e/cli/interactive-error-handling.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/interactive-error-handling.private.test.js +80 -0
- package/dist/test/e2e/cli/non-interactive-error-handling.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/non-interactive-error-handling.private.test.js +198 -0
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +28 -29
- 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.js +28 -21
- package/dist/test/handleUnbackportedPullRequests.private.test.js +11 -8
- package/dist/test/sandbox.js +5 -1
- package/dist/test/setupFiles/automatic-mocks.js +6 -2
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +4 -4
- 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 +19 -19
- package/yarn.lock +472 -701
package/dist/options/options.js
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOptions = void 0;
|
|
3
|
+
exports.getOptions = exports.defaultConfigOptions = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
|
-
const
|
|
6
|
-
const env_1 = require("../
|
|
7
|
-
const getOptionsFromGithub_1 = require("../
|
|
8
|
-
const getRepoOwnerAndNameFromGitRemotes_1 = require("../
|
|
9
|
-
const
|
|
10
|
-
const
|
|
5
|
+
const BackportError_1 = require("../lib/BackportError");
|
|
6
|
+
const env_1 = require("../lib/env");
|
|
7
|
+
const getOptionsFromGithub_1 = require("../lib/github/v4/getOptionsFromGithub/getOptionsFromGithub");
|
|
8
|
+
const getRepoOwnerAndNameFromGitRemotes_1 = require("../lib/github/v4/getRepoOwnerAndNameFromGitRemotes");
|
|
9
|
+
const validateTargetBranches_1 = require("../lib/github/v4/validateTargetBranches");
|
|
10
|
+
const logger_1 = require("../lib/logger");
|
|
11
11
|
const config_1 = require("./config/config");
|
|
12
12
|
const PROJECT_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson';
|
|
13
13
|
const GLOBAL_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson';
|
|
14
|
-
|
|
14
|
+
exports.defaultConfigOptions = {
|
|
15
15
|
assignees: [],
|
|
16
16
|
autoAssign: false,
|
|
17
17
|
autoMerge: false,
|
|
18
18
|
autoMergeMethod: 'merge',
|
|
19
19
|
backportBinary: 'backport',
|
|
20
20
|
cherrypickRef: true,
|
|
21
|
-
ci: false,
|
|
22
21
|
commitPaths: [],
|
|
23
22
|
cwd: process.cwd(),
|
|
24
23
|
dateSince: null,
|
|
@@ -26,11 +25,14 @@ const defaultConfigOptions = {
|
|
|
26
25
|
details: false,
|
|
27
26
|
fork: true,
|
|
28
27
|
gitHostname: 'github.com',
|
|
28
|
+
interactive: true,
|
|
29
29
|
maxNumber: 10,
|
|
30
30
|
multipleBranches: true,
|
|
31
31
|
multipleCommits: false,
|
|
32
32
|
noVerify: true,
|
|
33
|
-
|
|
33
|
+
publishStatusCommentOnAbort: false,
|
|
34
|
+
publishStatusCommentOnSuccess: true,
|
|
35
|
+
publishStatusCommentOnFailure: false,
|
|
34
36
|
resetAuthor: false,
|
|
35
37
|
reviewers: [],
|
|
36
38
|
sourcePRLabels: [],
|
|
@@ -38,12 +40,10 @@ const defaultConfigOptions = {
|
|
|
38
40
|
targetBranches: [],
|
|
39
41
|
targetPRLabels: [],
|
|
40
42
|
};
|
|
41
|
-
async function getOptions(
|
|
42
|
-
const optionsFromCliArgs = (0, cliArgs_1.getOptionsFromCliArgs)(processArgs);
|
|
43
|
+
async function getOptions({ optionsFromCliArgs, optionsFromModule, }) {
|
|
43
44
|
const optionsFromConfigFiles = await (0, config_1.getOptionsFromConfigFiles)({
|
|
44
45
|
optionsFromCliArgs,
|
|
45
46
|
optionsFromModule,
|
|
46
|
-
defaultConfigOptions,
|
|
47
47
|
});
|
|
48
48
|
// combined options from cli and config files
|
|
49
49
|
const combined = getMergedOptionsFromConfigAndCli({
|
|
@@ -66,7 +66,7 @@ async function getOptions(processArgs, optionsFromModule) {
|
|
|
66
66
|
// default fork owner
|
|
67
67
|
repoForkOwner: optionsFromGithub.authenticatedUsername,
|
|
68
68
|
// default values have lowest precedence
|
|
69
|
-
...defaultConfigOptions,
|
|
69
|
+
...exports.defaultConfigOptions,
|
|
70
70
|
// local config options override default options
|
|
71
71
|
...optionsFromConfigFiles,
|
|
72
72
|
// remote config options override local config options
|
|
@@ -79,21 +79,21 @@ async function getOptions(processArgs, optionsFromModule) {
|
|
|
79
79
|
repoOwner,
|
|
80
80
|
};
|
|
81
81
|
throwForRequiredOptions(options);
|
|
82
|
+
if (options.targetBranches.length > 0) {
|
|
83
|
+
await (0, validateTargetBranches_1.validateTargetBranches)(options);
|
|
84
|
+
}
|
|
82
85
|
return options;
|
|
83
86
|
}
|
|
84
87
|
exports.getOptions = getOptions;
|
|
85
88
|
async function getRequiredOptions(combined) {
|
|
86
|
-
const { accessToken, repoName, repoOwner } = combined;
|
|
89
|
+
const { accessToken, repoName, repoOwner, globalConfigFile } = combined;
|
|
87
90
|
if (accessToken && repoName && repoOwner) {
|
|
88
91
|
return { accessToken, repoName, repoOwner };
|
|
89
92
|
}
|
|
90
93
|
// require access token
|
|
91
94
|
if (!accessToken) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
96
|
-
throw new HandledError_1.HandledError(`Please update your config file: "${globalConfigPath}".\nIt must contain a valid "accessToken".\n\nRead more: ${GLOBAL_CONFIG_DOCS_LINK}`);
|
|
95
|
+
const globalConfigPath = (0, env_1.getGlobalConfigPath)(globalConfigFile);
|
|
96
|
+
throw new BackportError_1.BackportError(`Please update your config file: "${globalConfigPath}".\nIt must contain a valid "accessToken".\n\nRead more: ${GLOBAL_CONFIG_DOCS_LINK}`);
|
|
97
97
|
}
|
|
98
98
|
// attempt to retrieve repo-owner and repo-name from git remote
|
|
99
99
|
const gitRemote = await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
|
|
@@ -102,7 +102,7 @@ async function getRequiredOptions(combined) {
|
|
|
102
102
|
accessToken,
|
|
103
103
|
});
|
|
104
104
|
if (!gitRemote.repoName || !gitRemote.repoOwner) {
|
|
105
|
-
throw new
|
|
105
|
+
throw new BackportError_1.BackportError(`Please specify a repository: "--repo elastic/kibana".\n\nRead more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
106
106
|
}
|
|
107
107
|
return {
|
|
108
108
|
accessToken,
|
|
@@ -116,7 +116,7 @@ function throwForRequiredOptions(options) {
|
|
|
116
116
|
(0, lodash_1.isEmpty)(options.targetBranchChoices) &&
|
|
117
117
|
// this is primarily necessary on CI where `targetBranches` and `targetBranchChoices` and not given
|
|
118
118
|
(0, lodash_1.isEmpty)(options.branchLabelMapping)) {
|
|
119
|
-
throw new
|
|
119
|
+
throw new BackportError_1.BackportError(`Please specify a target branch: "--branch 6.1".\n\nRead more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
120
120
|
}
|
|
121
121
|
const optionKeys = [
|
|
122
122
|
'accessToken',
|
|
@@ -145,13 +145,13 @@ function throwForRequiredOptions(options) {
|
|
|
145
145
|
optionKeys.forEach((optionName) => {
|
|
146
146
|
const option = options[optionName];
|
|
147
147
|
if (option === '') {
|
|
148
|
-
throw new
|
|
148
|
+
throw new BackportError_1.BackportError(`"${optionName}" cannot be empty!`);
|
|
149
149
|
}
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
152
|
function getMergedOptionsFromConfigAndCli({ optionsFromConfigFiles, optionsFromCliArgs, }) {
|
|
153
153
|
return {
|
|
154
|
-
...defaultConfigOptions,
|
|
154
|
+
...exports.defaultConfigOptions,
|
|
155
155
|
...optionsFromConfigFiles,
|
|
156
156
|
...optionsFromCliArgs,
|
|
157
157
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -25,8 +29,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
29
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
26
30
|
const os_1 = __importDefault(require("os"));
|
|
27
31
|
const nock_1 = __importDefault(require("nock"));
|
|
28
|
-
const git = __importStar(require("../
|
|
29
|
-
const logger = __importStar(require("../
|
|
32
|
+
const git = __importStar(require("../lib/git"));
|
|
33
|
+
const logger = __importStar(require("../lib/logger"));
|
|
30
34
|
const mockConfigFiles_1 = require("../test/mockConfigFiles");
|
|
31
35
|
const nockHelpers_1 = require("../test/nockHelpers");
|
|
32
36
|
const options_1 = require("./options");
|
|
@@ -60,29 +64,23 @@ describe('getOptions', () => {
|
|
|
60
64
|
projectConfig: defaultConfigs.projectConfig,
|
|
61
65
|
globalConfig: { accessToken: undefined },
|
|
62
66
|
});
|
|
63
|
-
await expect(() => (0, options_1.getOptions)(
|
|
64
|
-
|
|
67
|
+
await expect(() => (0, options_1.getOptions)({
|
|
68
|
+
optionsFromCliArgs: {},
|
|
69
|
+
optionsFromModule: {},
|
|
70
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
65
71
|
"Please update your config file: \\"/myHomeDir/.backport/config.json\\".
|
|
66
72
|
It must contain a valid \\"accessToken\\".
|
|
67
73
|
|
|
68
74
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
|
|
69
75
|
`);
|
|
70
76
|
});
|
|
71
|
-
it('when accessToken is missing with --ci', async () => {
|
|
72
|
-
(0, mockConfigFiles_1.mockConfigFiles)({
|
|
73
|
-
projectConfig: defaultConfigs.projectConfig,
|
|
74
|
-
globalConfig: { accessToken: undefined },
|
|
75
|
-
});
|
|
76
|
-
await expect(() => (0, options_1.getOptions)([], { ci: true })).rejects.toThrowErrorMatchingInlineSnapshot(`"Access token missing. It must be explicitly supplied when using \\"--ci\\" option. Example: --access-token very-secret"`);
|
|
77
|
-
});
|
|
78
77
|
it('when `targetBranches`, `targetBranchChoices` and `branchLabelMapping` are all empty', async () => {
|
|
79
78
|
mockProjectConfig({
|
|
80
79
|
targetBranches: undefined,
|
|
81
80
|
targetBranchChoices: undefined,
|
|
82
81
|
branchLabelMapping: undefined,
|
|
83
82
|
});
|
|
84
|
-
await expect(() => (0, options_1.getOptions)(
|
|
85
|
-
.toThrowErrorMatchingInlineSnapshot(`
|
|
83
|
+
await expect(() => (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
86
84
|
"Please specify a target branch: \\"--branch 6.1\\".
|
|
87
85
|
|
|
88
86
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
@@ -90,14 +88,22 @@ describe('getOptions', () => {
|
|
|
90
88
|
});
|
|
91
89
|
describe('whe option is an empty string', () => {
|
|
92
90
|
it('throws for "username"', async () => {
|
|
93
|
-
await expect(() => (0, options_1.getOptions)(
|
|
91
|
+
await expect(() => (0, options_1.getOptions)({
|
|
92
|
+
optionsFromCliArgs: {},
|
|
93
|
+
optionsFromModule: { repoForkOwner: '', author: 'sqren' },
|
|
94
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"repoForkOwner\\" cannot be empty!"`);
|
|
94
95
|
});
|
|
95
96
|
it('throws for "author"', async () => {
|
|
96
|
-
await expect(() => (0, options_1.getOptions)(
|
|
97
|
+
await expect(() => (0, options_1.getOptions)({
|
|
98
|
+
optionsFromCliArgs: {},
|
|
99
|
+
optionsFromModule: { author: '' },
|
|
100
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"author\\" cannot be empty!"`);
|
|
97
101
|
});
|
|
98
102
|
it('throws for "accessToken"', async () => {
|
|
99
|
-
await expect(() => (0, options_1.getOptions)(
|
|
100
|
-
|
|
103
|
+
await expect(() => (0, options_1.getOptions)({
|
|
104
|
+
optionsFromCliArgs: {},
|
|
105
|
+
optionsFromModule: { accessToken: '' },
|
|
106
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
101
107
|
"Please update your config file: \\"/myHomeDir/.backport/config.json\\".
|
|
102
108
|
It must contain a valid \\"accessToken\\".
|
|
103
109
|
|
|
@@ -111,8 +117,7 @@ describe('getOptions', () => {
|
|
|
111
117
|
});
|
|
112
118
|
it('should throw if there are no remotes', async () => {
|
|
113
119
|
jest.spyOn(git, 'getRepoInfoFromGitRemotes').mockResolvedValue([]);
|
|
114
|
-
await expect(() => (0, options_1.getOptions)(
|
|
115
|
-
.toThrowErrorMatchingInlineSnapshot(`
|
|
120
|
+
await expect(() => (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
116
121
|
"Please specify a repository: \\"--repo elastic/kibana\\".
|
|
117
122
|
|
|
118
123
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
@@ -127,7 +132,10 @@ describe('getOptions', () => {
|
|
|
127
132
|
jest
|
|
128
133
|
.spyOn(git, 'getRepoInfoFromGitRemotes')
|
|
129
134
|
.mockResolvedValue([{ repoName: 'kibana', repoOwner: 'sqren' }]);
|
|
130
|
-
const options = await (0, options_1.getOptions)(
|
|
135
|
+
const options = await (0, options_1.getOptions)({
|
|
136
|
+
optionsFromCliArgs: {},
|
|
137
|
+
optionsFromModule: {},
|
|
138
|
+
});
|
|
131
139
|
expect(options.repoName).toBe('kibana');
|
|
132
140
|
expect(options.repoOwner).toBe('elastic');
|
|
133
141
|
});
|
|
@@ -135,7 +143,10 @@ describe('getOptions', () => {
|
|
|
135
143
|
});
|
|
136
144
|
it('reads options from remote config', async () => {
|
|
137
145
|
mockGithubConfigOptions({ hasRemoteConfig: true });
|
|
138
|
-
const options = await (0, options_1.getOptions)(
|
|
146
|
+
const options = await (0, options_1.getOptions)({
|
|
147
|
+
optionsFromCliArgs: {},
|
|
148
|
+
optionsFromModule: {},
|
|
149
|
+
});
|
|
139
150
|
expect(options.branchLabelMapping).toEqual({
|
|
140
151
|
'^v8.2.0$': 'option-from-remote',
|
|
141
152
|
});
|
|
@@ -143,17 +154,20 @@ describe('getOptions', () => {
|
|
|
143
154
|
});
|
|
144
155
|
it('should ensure that "backport" branch does not exist', async () => {
|
|
145
156
|
mockGithubConfigOptions({ hasBackportBranch: true });
|
|
146
|
-
await expect((0, options_1.getOptions)(
|
|
157
|
+
await expect((0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
147
158
|
});
|
|
148
159
|
it('should merge config options and module options', async () => {
|
|
149
160
|
mockGithubConfigOptions({});
|
|
150
161
|
const myFn = async () => true;
|
|
151
|
-
const options = await (0, options_1.getOptions)(
|
|
162
|
+
const options = await (0, options_1.getOptions)({
|
|
163
|
+
optionsFromCliArgs: {},
|
|
164
|
+
optionsFromModule: { autoFixConflicts: myFn },
|
|
165
|
+
});
|
|
152
166
|
expect(options.autoFixConflicts).toBe(myFn);
|
|
153
167
|
});
|
|
154
168
|
it('should call setAccessToken', async () => {
|
|
155
169
|
mockGithubConfigOptions({});
|
|
156
|
-
await (0, options_1.getOptions)(
|
|
170
|
+
await (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} });
|
|
157
171
|
expect(logger.setAccessToken).toHaveBeenCalledTimes(1);
|
|
158
172
|
});
|
|
159
173
|
it('should return options', async () => {
|
|
@@ -161,7 +175,10 @@ describe('getOptions', () => {
|
|
|
161
175
|
viewerLogin: 'john.diller',
|
|
162
176
|
defaultBranchRef: 'default-branch-from-github',
|
|
163
177
|
});
|
|
164
|
-
const options = await (0, options_1.getOptions)(
|
|
178
|
+
const options = await (0, options_1.getOptions)({
|
|
179
|
+
optionsFromCliArgs: {},
|
|
180
|
+
optionsFromModule: {},
|
|
181
|
+
});
|
|
165
182
|
expect(options).toEqual({
|
|
166
183
|
accessToken: 'abc',
|
|
167
184
|
assignees: [],
|
|
@@ -172,7 +189,6 @@ describe('getOptions', () => {
|
|
|
172
189
|
autoMergeMethod: 'merge',
|
|
173
190
|
backportBinary: 'backport',
|
|
174
191
|
cherrypickRef: true,
|
|
175
|
-
ci: false,
|
|
176
192
|
commitPaths: [],
|
|
177
193
|
cwd: expect.any(String),
|
|
178
194
|
dateSince: null,
|
|
@@ -182,11 +198,14 @@ describe('getOptions', () => {
|
|
|
182
198
|
fork: true,
|
|
183
199
|
gitHostname: 'github.com',
|
|
184
200
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
201
|
+
interactive: true,
|
|
185
202
|
maxNumber: 10,
|
|
186
203
|
multipleBranches: true,
|
|
187
204
|
multipleCommits: false,
|
|
188
205
|
noVerify: true,
|
|
189
|
-
|
|
206
|
+
publishStatusCommentOnAbort: false,
|
|
207
|
+
publishStatusCommentOnSuccess: true,
|
|
208
|
+
publishStatusCommentOnFailure: false,
|
|
190
209
|
repoForkOwner: 'john.diller',
|
|
191
210
|
repoName: 'kibana',
|
|
192
211
|
repoOwner: 'elastic',
|
|
@@ -204,11 +223,17 @@ describe('getOptions', () => {
|
|
|
204
223
|
mockGithubConfigOptions({ defaultBranchRef: 'some-default-branch' });
|
|
205
224
|
});
|
|
206
225
|
it('uses the `defaultBranchRef` as default', async () => {
|
|
207
|
-
const options = await (0, options_1.getOptions)(
|
|
226
|
+
const options = await (0, options_1.getOptions)({
|
|
227
|
+
optionsFromCliArgs: {},
|
|
228
|
+
optionsFromModule: {},
|
|
229
|
+
});
|
|
208
230
|
expect(options.sourceBranch).toBe('some-default-branch');
|
|
209
231
|
});
|
|
210
232
|
it('uses the sourceBranch given via cli instead of `defaultBranchRef`', async () => {
|
|
211
|
-
const options = await (0, options_1.getOptions)(
|
|
233
|
+
const options = await (0, options_1.getOptions)({
|
|
234
|
+
optionsFromCliArgs: { sourceBranch: 'cli-source-branch' },
|
|
235
|
+
optionsFromModule: {},
|
|
236
|
+
});
|
|
212
237
|
expect(options.sourceBranch).toBe('cli-source-branch');
|
|
213
238
|
});
|
|
214
239
|
});
|
|
@@ -217,16 +242,25 @@ describe('getOptions', () => {
|
|
|
217
242
|
mockGithubConfigOptions({});
|
|
218
243
|
});
|
|
219
244
|
it('is enabled by default', async () => {
|
|
220
|
-
const { fork } = await (0, options_1.getOptions)(
|
|
245
|
+
const { fork } = await (0, options_1.getOptions)({
|
|
246
|
+
optionsFromCliArgs: {},
|
|
247
|
+
optionsFromModule: {},
|
|
248
|
+
});
|
|
221
249
|
expect(fork).toBe(true);
|
|
222
250
|
});
|
|
223
|
-
it('can be disabled via
|
|
224
|
-
const { fork } = await (0, options_1.getOptions)(
|
|
251
|
+
it('can be disabled via cli', async () => {
|
|
252
|
+
const { fork } = await (0, options_1.getOptions)({
|
|
253
|
+
optionsFromCliArgs: { fork: false },
|
|
254
|
+
optionsFromModule: {},
|
|
255
|
+
});
|
|
225
256
|
expect(fork).toBe(false);
|
|
226
257
|
});
|
|
227
258
|
it('can be disabled via config file', async () => {
|
|
228
259
|
mockProjectConfig({ fork: false });
|
|
229
|
-
const { fork } = await (0, options_1.getOptions)(
|
|
260
|
+
const { fork } = await (0, options_1.getOptions)({
|
|
261
|
+
optionsFromCliArgs: {},
|
|
262
|
+
optionsFromModule: {},
|
|
263
|
+
});
|
|
230
264
|
expect(fork).toBe(false);
|
|
231
265
|
});
|
|
232
266
|
});
|
|
@@ -234,13 +268,19 @@ describe('getOptions', () => {
|
|
|
234
268
|
beforeEach(() => {
|
|
235
269
|
mockGithubConfigOptions({});
|
|
236
270
|
});
|
|
237
|
-
it('can be set via
|
|
238
|
-
const { reviewers } = await (0, options_1.getOptions)(
|
|
271
|
+
it('can be set via cli', async () => {
|
|
272
|
+
const { reviewers } = await (0, options_1.getOptions)({
|
|
273
|
+
optionsFromCliArgs: { reviewers: ['peter'] },
|
|
274
|
+
optionsFromModule: {},
|
|
275
|
+
});
|
|
239
276
|
expect(reviewers).toEqual(['peter']);
|
|
240
277
|
});
|
|
241
278
|
it('can be set via config file', async () => {
|
|
242
279
|
mockProjectConfig({ reviewers: ['john'] });
|
|
243
|
-
const { reviewers } = await (0, options_1.getOptions)(
|
|
280
|
+
const { reviewers } = await (0, options_1.getOptions)({
|
|
281
|
+
optionsFromCliArgs: {},
|
|
282
|
+
optionsFromModule: {},
|
|
283
|
+
});
|
|
244
284
|
expect(reviewers).toEqual(['john']);
|
|
245
285
|
});
|
|
246
286
|
});
|
|
@@ -249,15 +289,24 @@ describe('getOptions', () => {
|
|
|
249
289
|
mockGithubConfigOptions({});
|
|
250
290
|
});
|
|
251
291
|
it('is not enabled by default', async () => {
|
|
252
|
-
const { mainline } = await (0, options_1.getOptions)(
|
|
292
|
+
const { mainline } = await (0, options_1.getOptions)({
|
|
293
|
+
optionsFromCliArgs: {},
|
|
294
|
+
optionsFromModule: {},
|
|
295
|
+
});
|
|
253
296
|
expect(mainline).toBe(undefined);
|
|
254
297
|
});
|
|
255
298
|
it('can be set via `--mainline` flag', async () => {
|
|
256
|
-
const { mainline } = await (0, options_1.getOptions)(
|
|
299
|
+
const { mainline } = await (0, options_1.getOptions)({
|
|
300
|
+
optionsFromCliArgs: { mainline: 1 },
|
|
301
|
+
optionsFromModule: {},
|
|
302
|
+
});
|
|
257
303
|
expect(mainline).toBe(1);
|
|
258
304
|
});
|
|
259
305
|
it('accepts numeric values', async () => {
|
|
260
|
-
const { mainline } = await (0, options_1.getOptions)(
|
|
306
|
+
const { mainline } = await (0, options_1.getOptions)({
|
|
307
|
+
optionsFromCliArgs: { mainline: 2 },
|
|
308
|
+
optionsFromModule: {},
|
|
309
|
+
});
|
|
261
310
|
expect(mainline).toBe(2);
|
|
262
311
|
});
|
|
263
312
|
});
|
|
@@ -266,25 +315,33 @@ describe('getOptions', () => {
|
|
|
266
315
|
mockGithubConfigOptions({ viewerLogin: 'billy.bob' });
|
|
267
316
|
});
|
|
268
317
|
it('defaults to authenticated user', async () => {
|
|
269
|
-
const { author } = await (0, options_1.getOptions)(
|
|
318
|
+
const { author } = await (0, options_1.getOptions)({
|
|
319
|
+
optionsFromCliArgs: {},
|
|
320
|
+
optionsFromModule: {},
|
|
321
|
+
});
|
|
270
322
|
expect(author).toBe('billy.bob');
|
|
271
323
|
});
|
|
272
324
|
it('can be overridden via `--author` flag', async () => {
|
|
273
|
-
const { author } = await (0, options_1.getOptions)(
|
|
325
|
+
const { author } = await (0, options_1.getOptions)({
|
|
326
|
+
optionsFromCliArgs: { author: 'john.doe' },
|
|
327
|
+
optionsFromModule: {},
|
|
328
|
+
});
|
|
274
329
|
expect(author).toBe('john.doe');
|
|
275
330
|
});
|
|
276
|
-
it('can be reset via `--all` flag', async () => {
|
|
277
|
-
const { author } = await (0, options_1.getOptions)(['--all'], {});
|
|
278
|
-
expect(author).toBe(null);
|
|
279
|
-
});
|
|
280
331
|
it('can be reset via config file (similar to `--all` flag)', async () => {
|
|
281
332
|
mockProjectConfig({ author: null });
|
|
282
|
-
const { author } = await (0, options_1.getOptions)(
|
|
333
|
+
const { author } = await (0, options_1.getOptions)({
|
|
334
|
+
optionsFromCliArgs: {},
|
|
335
|
+
optionsFromModule: {},
|
|
336
|
+
});
|
|
283
337
|
expect(author).toBe(null);
|
|
284
338
|
});
|
|
285
339
|
it('can be overridden via config file', async () => {
|
|
286
340
|
mockProjectConfig({ author: 'jane.doe' });
|
|
287
|
-
const { author } = await (0, options_1.getOptions)(
|
|
341
|
+
const { author } = await (0, options_1.getOptions)({
|
|
342
|
+
optionsFromCliArgs: {},
|
|
343
|
+
optionsFromModule: {},
|
|
344
|
+
});
|
|
288
345
|
expect(author).toBe('jane.doe');
|
|
289
346
|
});
|
|
290
347
|
});
|
|
@@ -293,21 +350,26 @@ describe('getOptions', () => {
|
|
|
293
350
|
mockGithubConfigOptions({});
|
|
294
351
|
});
|
|
295
352
|
it('should default to true', async () => {
|
|
296
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(
|
|
353
|
+
const { cherrypickRef } = await (0, options_1.getOptions)({
|
|
354
|
+
optionsFromCliArgs: {},
|
|
355
|
+
optionsFromModule: {},
|
|
356
|
+
});
|
|
297
357
|
expect(cherrypickRef).toBe(true);
|
|
298
358
|
});
|
|
299
|
-
it('should negate with `noCherrypickRef` cli arg', async () => {
|
|
300
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(['--no-cherrypick-ref'], {});
|
|
301
|
-
expect(cherrypickRef).toBe(false);
|
|
302
|
-
});
|
|
303
359
|
it('should be settable via config file', async () => {
|
|
304
360
|
mockProjectConfig({ cherrypickRef: false });
|
|
305
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(
|
|
361
|
+
const { cherrypickRef } = await (0, options_1.getOptions)({
|
|
362
|
+
optionsFromCliArgs: {},
|
|
363
|
+
optionsFromModule: {},
|
|
364
|
+
});
|
|
306
365
|
expect(cherrypickRef).toBe(false);
|
|
307
366
|
});
|
|
308
367
|
it('cli args overwrites config', async () => {
|
|
309
368
|
mockProjectConfig({ cherrypickRef: false });
|
|
310
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(
|
|
369
|
+
const { cherrypickRef } = await (0, options_1.getOptions)({
|
|
370
|
+
optionsFromCliArgs: { cherrypickRef: true },
|
|
371
|
+
optionsFromModule: {},
|
|
372
|
+
});
|
|
311
373
|
expect(cherrypickRef).toBe(true);
|
|
312
374
|
});
|
|
313
375
|
});
|
|
@@ -1,21 +1,26 @@
|
|
|
1
|
+
import { BackportError } from './lib/BackportError';
|
|
2
|
+
import { Commit } from './lib/sourceCommit/parseSourceCommit';
|
|
1
3
|
import { ValidConfigOptions } from './options/options';
|
|
2
|
-
|
|
3
|
-
import { Commit } from './services/sourceCommit/parseSourceCommit';
|
|
4
|
-
import { GitConfigAuthor } from './ui/getGitConfigAuthor';
|
|
5
|
-
export declare type Result = {
|
|
4
|
+
export declare type SuccessResult = {
|
|
6
5
|
status: 'success';
|
|
7
6
|
didUpdate: boolean;
|
|
8
7
|
targetBranch: string;
|
|
9
8
|
pullRequestUrl: string;
|
|
10
9
|
pullRequestNumber: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
10
|
+
};
|
|
11
|
+
export declare type HandledErrorResult = {
|
|
12
|
+
status: 'handled-error';
|
|
13
|
+
targetBranch: string;
|
|
14
|
+
error: BackportError;
|
|
15
|
+
};
|
|
16
|
+
export declare type UnhandledErrorResult = {
|
|
17
|
+
status: 'unhandled-error';
|
|
13
18
|
targetBranch: string;
|
|
14
|
-
error:
|
|
19
|
+
error: Error;
|
|
15
20
|
};
|
|
16
|
-
export declare
|
|
21
|
+
export declare type Result = SuccessResult | HandledErrorResult | UnhandledErrorResult;
|
|
22
|
+
export declare function runSequentially({ options, commits, targetBranches, }: {
|
|
17
23
|
options: ValidConfigOptions;
|
|
18
24
|
commits: Commit[];
|
|
19
25
|
targetBranches: string[];
|
|
20
|
-
gitConfigAuthor?: GitConfigAuthor;
|
|
21
26
|
}): Promise<Result[]>;
|
package/dist/runSequentially.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runSequentially = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
4
|
+
const BackportError_1 = require("./lib/BackportError");
|
|
5
|
+
const cherrypickAndCreateTargetPullRequest_1 = require("./lib/cherrypickAndCreateTargetPullRequest");
|
|
6
|
+
const logger_1 = require("./lib/logger");
|
|
7
|
+
const sequentially_1 = require("./lib/sequentially");
|
|
8
|
+
async function runSequentially({ options, commits, targetBranches, }) {
|
|
8
9
|
logger_1.logger.verbose('Backport options', options);
|
|
9
10
|
const results = [];
|
|
10
11
|
await (0, sequentially_1.sequentially)(targetBranches, async (targetBranch) => {
|
|
@@ -14,7 +15,6 @@ async function runSequentially({ options, commits, targetBranches, gitConfigAuth
|
|
|
14
15
|
options,
|
|
15
16
|
commits,
|
|
16
17
|
targetBranch,
|
|
17
|
-
gitConfigAuthor: gitConfigAuthor,
|
|
18
18
|
});
|
|
19
19
|
results.push({
|
|
20
20
|
targetBranch,
|
|
@@ -25,13 +25,28 @@ async function runSequentially({ options, commits, targetBranches, gitConfigAuth
|
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
catch (e) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
const isHandledError = e instanceof BackportError_1.BackportError;
|
|
29
|
+
if (isHandledError) {
|
|
30
|
+
results.push({
|
|
31
|
+
targetBranch,
|
|
32
|
+
status: 'handled-error',
|
|
33
|
+
error: e,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
else if (e instanceof Error) {
|
|
37
|
+
results.push({
|
|
38
|
+
targetBranch,
|
|
39
|
+
status: 'unhandled-error',
|
|
40
|
+
error: e,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
(0, logger_1.consoleLog)(isHandledError
|
|
47
|
+
? e.message
|
|
48
|
+
: 'An unhandled error occurred while backporting commit. Please see the logs for details');
|
|
49
|
+
logger_1.logger.error('runSequentially failed', e);
|
|
35
50
|
}
|
|
36
51
|
});
|
|
37
52
|
// return the results for consumers to programatically read
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.postinstall = void 0;
|
|
4
|
+
const env_1 = require("../lib/env");
|
|
5
|
+
const logger_1 = require("../lib/logger");
|
|
4
6
|
const globalConfig_1 = require("../options/config/globalConfig");
|
|
5
|
-
const env_1 = require("../services/env");
|
|
6
|
-
const logger_1 = require("../services/logger");
|
|
7
7
|
async function postinstall() {
|
|
8
8
|
try {
|
|
9
|
-
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
9
|
+
const globalConfigPath = (0, env_1.getGlobalConfigPath)(undefined);
|
|
10
10
|
const didCreate = await (0, globalConfig_1.createGlobalConfigAndFolderIfNotExist)(globalConfigPath);
|
|
11
11
|
if (didCreate) {
|
|
12
12
|
(0, logger_1.consoleLog)(`Global config successfully created in ${globalConfigPath}`);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
catch (e) {
|
|
16
|
+
// @ts-expect-error
|
|
16
17
|
(0, logger_1.consoleLog)(`Global config could not be created:\n${e.stack}`);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -23,8 +27,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
27
|
};
|
|
24
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
29
|
const os_1 = __importDefault(require("os"));
|
|
30
|
+
const logger = __importStar(require("../lib/logger"));
|
|
26
31
|
const globalConfig = __importStar(require("../options/config/globalConfig"));
|
|
27
|
-
const logger = __importStar(require("../services/logger"));
|
|
28
32
|
const postinstall_1 = require("./postinstall");
|
|
29
33
|
describe('postinstall', () => {
|
|
30
34
|
beforeEach(() => {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Commit } from './sourceCommit/parseSourceCommit';
|
|
2
|
+
declare type ErrorContext = {
|
|
3
|
+
code: 'merge-conflict-exception';
|
|
4
|
+
conflictingFiles: string[];
|
|
5
|
+
commitsWithoutBackports: {
|
|
6
|
+
formatted: string;
|
|
7
|
+
commit: Commit;
|
|
8
|
+
}[];
|
|
9
|
+
} | {
|
|
10
|
+
code: 'message-only-exception';
|
|
11
|
+
message: string;
|
|
12
|
+
} | {
|
|
13
|
+
code: 'no-branches-exception' | 'abort-exception';
|
|
14
|
+
};
|
|
15
|
+
export declare class BackportError extends Error {
|
|
16
|
+
errorContext: ErrorContext;
|
|
17
|
+
constructor(errorContextOrString: ErrorContext | string);
|
|
18
|
+
}
|
|
19
|
+
export {};
|