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/dist/runSequentially.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runSequentially = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
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");
|
|
7
8
|
async function runSequentially({ options, commits, targetBranches, gitConfigAuthor, }) {
|
|
8
9
|
logger_1.logger.verbose('Backport options', options);
|
|
9
10
|
const results = [];
|
|
@@ -25,14 +26,28 @@ async function runSequentially({ options, commits, targetBranches, gitConfigAuth
|
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
catch (e) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
const isHandledError = e instanceof BackportError_1.BackportError;
|
|
30
|
+
if (isHandledError) {
|
|
31
|
+
results.push({
|
|
32
|
+
targetBranch,
|
|
33
|
+
status: 'handled-error',
|
|
34
|
+
error: e,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
else if (e instanceof Error) {
|
|
38
|
+
results.push({
|
|
39
|
+
targetBranch,
|
|
40
|
+
status: 'unhandled-error',
|
|
41
|
+
error: e,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
(0, logger_1.consoleLog)(isHandledError
|
|
48
|
+
? e.message
|
|
49
|
+
: 'An error occurred while backporting commit. Please see the logs for details');
|
|
50
|
+
logger_1.logger.error('runSequentially failed', e);
|
|
36
51
|
}
|
|
37
52
|
});
|
|
38
53
|
// 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 {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BackportError = void 0;
|
|
4
|
+
function getMessage(errorContext) {
|
|
5
|
+
switch (errorContext.code) {
|
|
6
|
+
case 'merge-conflict-exception':
|
|
7
|
+
return `Commit could not be cherrypicked due to conflicts in: ${errorContext.conflictingFiles.join(',')}`;
|
|
8
|
+
case 'no-branches-exception':
|
|
9
|
+
return 'There are no branches to backport to. Aborting.';
|
|
10
|
+
case 'abort-exception':
|
|
11
|
+
return 'Aborted';
|
|
12
|
+
case 'message-only-exception':
|
|
13
|
+
return errorContext.message;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class BackportError extends Error {
|
|
17
|
+
constructor(errorContextOrString) {
|
|
18
|
+
const errorContext = typeof errorContextOrString === 'string'
|
|
19
|
+
? { code: 'message-only-exception', message: errorContextOrString }
|
|
20
|
+
: errorContextOrString;
|
|
21
|
+
const message = getMessage(errorContext);
|
|
22
|
+
super(message);
|
|
23
|
+
Error.captureStackTrace(this, BackportError);
|
|
24
|
+
this.name = 'BackportError';
|
|
25
|
+
this.message = message;
|
|
26
|
+
this.errorContext = errorContext;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.BackportError = BackportError;
|
|
@@ -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 {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BackportError = void 0;
|
|
4
|
+
function getMessage(errorContext) {
|
|
5
|
+
switch (errorContext.code) {
|
|
6
|
+
case 'merge-conflict-exception':
|
|
7
|
+
return `Commit could not be cherrypicked due to conflicts in: ${errorContext.conflictingFiles.join(',')}`;
|
|
8
|
+
case 'no-branches-exception':
|
|
9
|
+
return 'There are no branches to backport to. Aborting.';
|
|
10
|
+
case 'abort-exception':
|
|
11
|
+
return 'Aborted';
|
|
12
|
+
case 'message-only-exception':
|
|
13
|
+
return errorContext.message;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class BackportError extends Error {
|
|
17
|
+
constructor(errorContextOrString) {
|
|
18
|
+
const errorContext = typeof errorContextOrString === 'string'
|
|
19
|
+
? { code: 'message-only-exception', message: errorContextOrString }
|
|
20
|
+
: errorContextOrString;
|
|
21
|
+
const message = getMessage(errorContext);
|
|
22
|
+
super(message);
|
|
23
|
+
Error.captureStackTrace(this, BackportError);
|
|
24
|
+
this.name = 'BackportError';
|
|
25
|
+
this.message = message;
|
|
26
|
+
this.errorContext = errorContext;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.BackportError = BackportError;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { Commit } from './sourceCommit/parseSourceCommit';
|
|
2
2
|
declare type ErrorContext = {
|
|
3
3
|
code: 'merge-conflict-exception';
|
|
4
|
+
conflictingFiles: string[];
|
|
4
5
|
commitsWithoutBackports: {
|
|
5
6
|
formatted: string;
|
|
6
7
|
commit: Commit;
|
|
7
8
|
}[];
|
|
9
|
+
} | {
|
|
10
|
+
code: 'message-only-exception';
|
|
11
|
+
message: string;
|
|
8
12
|
} | {
|
|
9
13
|
code: 'no-branches-exception' | 'abort-exception';
|
|
10
14
|
};
|
|
11
|
-
export declare class
|
|
12
|
-
errorContext
|
|
13
|
-
constructor(
|
|
15
|
+
export declare class BackportError extends Error {
|
|
16
|
+
errorContext: ErrorContext;
|
|
17
|
+
constructor(errorContextOrString: ErrorContext | string);
|
|
14
18
|
}
|
|
15
19
|
export {};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.BackportError = void 0;
|
|
4
4
|
function getMessage(errorContext) {
|
|
5
|
-
if (typeof errorContext === 'string') {
|
|
6
|
-
return errorContext;
|
|
7
|
-
}
|
|
8
5
|
switch (errorContext.code) {
|
|
9
6
|
case 'merge-conflict-exception':
|
|
10
|
-
return `Commit could not be cherrypicked due to conflicts`;
|
|
7
|
+
return `Commit could not be cherrypicked due to conflicts in: ${errorContext.conflictingFiles.join(',')}`;
|
|
11
8
|
case 'no-branches-exception':
|
|
12
9
|
return 'There are no branches to backport to. Aborting.';
|
|
13
10
|
case 'abort-exception':
|
|
14
11
|
return 'Aborted';
|
|
12
|
+
case 'message-only-exception':
|
|
13
|
+
return errorContext.message;
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
|
-
class
|
|
18
|
-
constructor(
|
|
16
|
+
class BackportError extends Error {
|
|
17
|
+
constructor(errorContextOrString) {
|
|
18
|
+
const errorContext = typeof errorContextOrString === 'string'
|
|
19
|
+
? { code: 'message-only-exception', message: errorContextOrString }
|
|
20
|
+
: errorContextOrString;
|
|
19
21
|
const message = getMessage(errorContext);
|
|
20
22
|
super(message);
|
|
21
|
-
Error.captureStackTrace(this,
|
|
22
|
-
this.name = '
|
|
23
|
+
Error.captureStackTrace(this, BackportError);
|
|
24
|
+
this.name = 'BackportError';
|
|
23
25
|
this.message = message;
|
|
24
|
-
|
|
25
|
-
this.errorContext = errorContext;
|
|
26
|
-
}
|
|
26
|
+
this.errorContext = errorContext;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
exports.
|
|
29
|
+
exports.BackportError = BackportError;
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
3
|
-
export declare function exec(cmd: string, options:
|
|
2
|
+
import childProcess from 'child_process';
|
|
3
|
+
export declare function exec(cmd: string, options: childProcess.ExecOptions & {
|
|
4
4
|
cwd: string;
|
|
5
5
|
}): Promise<{
|
|
6
6
|
stdout: string;
|
|
7
7
|
stderr: string;
|
|
8
8
|
}>;
|
|
9
|
-
export declare
|
|
9
|
+
export declare function spawnPromise(cmd: string, cmdArgs: string[], cwd: string): Promise<{
|
|
10
|
+
cmdArgs: string[];
|
|
11
|
+
code: number | null;
|
|
12
|
+
stderr: string;
|
|
13
|
+
stdout: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const spawnOriginal: typeof childProcess.spawn;
|
|
16
|
+
export declare type SpawnErrorContext = {
|
|
17
|
+
cmdArgs: string[];
|
|
18
|
+
code: number;
|
|
19
|
+
stderr: string;
|
|
20
|
+
stdout: string;
|
|
21
|
+
};
|
|
22
|
+
export declare class SpawnError extends Error {
|
|
23
|
+
context: SpawnErrorContext;
|
|
24
|
+
constructor(context: SpawnErrorContext);
|
|
25
|
+
}
|
|
@@ -3,27 +3,56 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.SpawnError = exports.spawnOriginal = exports.spawnPromise = exports.exec = void 0;
|
|
7
7
|
const child_process_1 = __importDefault(require("child_process"));
|
|
8
8
|
const util_1 = require("util");
|
|
9
9
|
const logger_1 = require("./logger");
|
|
10
|
+
const execPromisified = (0, util_1.promisify)(child_process_1.default.exec);
|
|
10
11
|
async function exec(cmd, options) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const res = await execPromisified(cmd, {
|
|
13
|
+
maxBuffer: 100 * 1024 * 1024,
|
|
14
|
+
...options,
|
|
15
|
+
});
|
|
16
|
+
return res;
|
|
17
|
+
}
|
|
18
|
+
exports.exec = exec;
|
|
19
|
+
async function spawnPromise(cmd, cmdArgs, cwd) {
|
|
20
|
+
return new Promise(function (resolve, reject) {
|
|
21
|
+
const subprocess = child_process_1.default.spawn(cmd, cmdArgs, { cwd });
|
|
22
|
+
let stderr = '';
|
|
23
|
+
let stdout = '';
|
|
24
|
+
subprocess.stdout.on('data', (data) => {
|
|
25
|
+
stdout += data;
|
|
16
26
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
subprocess.stderr.on('data', (data) => {
|
|
28
|
+
stderr += data;
|
|
29
|
+
});
|
|
30
|
+
subprocess.on('close', (code) => {
|
|
31
|
+
if (code === 0 || code === null) {
|
|
32
|
+
logger_1.logger.verbose(`spawn success "${cmdArgs}"`);
|
|
33
|
+
resolve({ cmdArgs, code, stderr, stdout });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const err = new SpawnError({ cmdArgs, code, stderr, stdout });
|
|
37
|
+
logger_1.logger.info('spawn error', err);
|
|
38
|
+
reject(err);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
subprocess.on('error', (err) => {
|
|
42
|
+
reject(err);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.spawnPromise = spawnPromise;
|
|
47
|
+
exports.spawnOriginal = child_process_1.default.spawn;
|
|
48
|
+
class SpawnError extends Error {
|
|
49
|
+
constructor(context) {
|
|
50
|
+
const message = `Code: ${context.code}; Args: ${JSON.stringify(context.cmdArgs)}; ${context.stderr.trim()}`;
|
|
51
|
+
super(message);
|
|
52
|
+
Error.captureStackTrace(this, SpawnError);
|
|
53
|
+
this.name = 'SpawnError';
|
|
54
|
+
this.message = message;
|
|
55
|
+
this.context = context;
|
|
23
56
|
}
|
|
24
57
|
}
|
|
25
|
-
exports.
|
|
26
|
-
const execAsCallback = (...args) => {
|
|
27
|
-
return child_process_1.default.exec(...args);
|
|
28
|
-
};
|
|
29
|
-
exports.execAsCallback = execAsCallback;
|
|
58
|
+
exports.SpawnError = SpawnError;
|
package/dist/services/git.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare function isLocalConfigFileUntracked({ cwd }: {
|
|
|
14
14
|
}): Promise<boolean | undefined>;
|
|
15
15
|
export declare function isLocalConfigFileModified({ cwd }: {
|
|
16
16
|
cwd: string;
|
|
17
|
-
}): Promise<boolean
|
|
17
|
+
}): Promise<boolean>;
|
|
18
18
|
export declare function getRepoInfoFromGitRemotes({ cwd }: {
|
|
19
19
|
cwd: string;
|
|
20
20
|
}): Promise<{
|
|
@@ -59,10 +59,7 @@ export declare function createBackportBranch({ options, targetBranch, backportBr
|
|
|
59
59
|
options: ValidConfigOptions;
|
|
60
60
|
targetBranch: string;
|
|
61
61
|
backportBranch: string;
|
|
62
|
-
}): Promise<
|
|
63
|
-
stdout: string;
|
|
64
|
-
stderr: string;
|
|
65
|
-
}>;
|
|
62
|
+
}): Promise<void>;
|
|
66
63
|
export declare function deleteBackportBranch({ options, backportBranch, }: {
|
|
67
64
|
options: ValidConfigOptions;
|
|
68
65
|
backportBranch: string;
|
|
@@ -72,7 +69,9 @@ export declare function pushBackportBranch({ options, backportBranch, }: {
|
|
|
72
69
|
options: ValidConfigOptions;
|
|
73
70
|
backportBranch: string;
|
|
74
71
|
}): Promise<{
|
|
75
|
-
|
|
72
|
+
cmdArgs: string[];
|
|
73
|
+
code: number | null;
|
|
76
74
|
stderr: string;
|
|
75
|
+
stdout: string;
|
|
77
76
|
}>;
|
|
78
|
-
export declare function
|
|
77
|
+
export declare function getLocalSourceRepoPath(options: ValidConfigOptions): Promise<string | undefined>;
|