backport 8.3.1 → 8.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -178
- package/dist/lib/cherrypickAndCreateTargetPullRequest.js +42 -21
- package/dist/lib/child-process-promisified.js +2 -2
- package/dist/lib/git.d.ts +4 -3
- package/dist/lib/git.js +22 -29
- package/dist/lib/git.private.test.js +10 -7
- package/dist/lib/git.test.js +47 -15
- package/dist/lib/github/v4/apiRequestV4.js +14 -8
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +1 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -0
- package/dist/lib/ora.d.ts +1 -0
- package/dist/options/ConfigOptions.d.ts +1 -0
- package/dist/options/cliArgs.d.ts +1 -0
- package/dist/options/cliArgs.js +5 -0
- package/dist/options/config/config.d.ts +1 -0
- package/dist/options/config/readConfigFile.d.ts +1 -0
- package/dist/options/options.d.ts +2 -0
- package/dist/options/options.js +3 -2
- package/dist/options/options.test.js +5 -4
- package/dist/test/e2e/cli/date-filters.private.test.js +1 -0
- package/dist/test/e2e/cli/different-merge-strategies.private.test.js +122 -6
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +2 -0
- package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.js +27 -13
- package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.js +3 -2
- package/dist/{entrypoint.cli.private.test.d.ts → test/e2e/cli/gracefully-handles-corrupt-repo.private.test.d.ts} +0 -0
- package/dist/test/e2e/cli/gracefully-handles-corrupt-repo.private.test.js +52 -0
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +2 -2
- package/dist/{lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts → test/e2e/cli/repo-with-programatically-added-commits.mutation.test.d.ts} +0 -0
- package/dist/test/e2e/cli/repo-with-programatically-added-commits.mutation.test.js +114 -0
- package/dist/test/e2e/cli/runBackportViaCli.d.ts +8 -2
- package/dist/test/e2e/cli/runBackportViaCli.js +47 -17
- package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +7 -1
- package/dist/test/e2e/module/entrypoint.module.mutation.test.js +1 -1
- package/dist/test/handleUnbackportedPullRequests.private.test.js +1 -1
- package/dist/test/replaceStringAndLinebreaks.d.ts +5 -0
- package/dist/test/replaceStringAndLinebreaks.js +8 -0
- package/dist/test/sandbox.js +6 -2
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +23 -24
- package/yarn.lock +841 -950
- package/dist/entrypoint.cli.private.test.js +0 -47
- package/dist/errors/BackportError.d.ts +0 -19
- package/dist/errors/BackportError.js +0 -29
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
- package/dist/runSequentially.test.d.ts +0 -1
- package/dist/runSequentially.test.js +0 -243
- package/dist/services/BackportError.d.ts +0 -19
- package/dist/services/BackportError.js +0 -29
- package/dist/services/HandledBackportError.d.ts +0 -19
- package/dist/services/HandledBackportError.js +0 -29
- package/dist/services/HandledError.d.ts +0 -19
- package/dist/services/HandledError.js +0 -29
- package/dist/services/child-process-promisified.d.ts +0 -25
- package/dist/services/child-process-promisified.js +0 -58
- package/dist/services/env.d.ts +0 -7
- package/dist/services/env.js +0 -30
- package/dist/services/env.test.d.ts +0 -1
- package/dist/services/env.test.js +0 -21
- package/dist/services/git.d.ts +0 -77
- package/dist/services/git.integration.test.d.ts +0 -1
- package/dist/services/git.integration.test.js +0 -616
- package/dist/services/git.js +0 -439
- package/dist/services/git.private.test.d.ts +0 -1
- package/dist/services/git.private.test.js +0 -618
- package/dist/services/git.test.d.ts +0 -1
- package/dist/services/git.test.js +0 -580
- package/dist/services/github/commitFormatters.d.ts +0 -3
- package/dist/services/github/commitFormatters.js +0 -17
- package/dist/services/github/commitFormatters.test.d.ts +0 -1
- package/dist/services/github/commitFormatters.test.js +0 -11
- package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +0 -2
- package/dist/services/github/v3/addAssigneesToPullRequest.js +0 -32
- package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +0 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.test.js +0 -27
- package/dist/services/github/v3/addLabelsToPullRequest.d.ts +0 -2
- package/dist/services/github/v3/addLabelsToPullRequest.js +0 -30
- package/dist/services/github/v3/addReviewersToPullRequest.d.ts +0 -2
- package/dist/services/github/v3/addReviewersToPullRequest.js +0 -32
- package/dist/services/github/v3/createPullRequest.d.ts +0 -29
- package/dist/services/github/v3/createPullRequest.js +0 -91
- package/dist/services/github/v3/createPullRequest.test.d.ts +0 -1
- package/dist/services/github/v3/createPullRequest.test.js +0 -377
- package/dist/services/github/v3/createStatusComment.d.ts +0 -11
- package/dist/services/github/v3/createStatusComment.js +0 -131
- package/dist/services/github/v3/createStatusComment.test.d.ts +0 -1
- package/dist/services/github/v3/createStatusComment.test.js +0 -409
- package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +0 -14
- package/dist/services/github/v3/getGithubV3ErrorMessage.js +0 -16
- package/dist/services/github/v4/FetchPullRequestId.d.ts +0 -2
- package/dist/services/github/v4/FetchPullRequestId.js +0 -36
- package/dist/services/github/v4/apiRequestV4.d.ts +0 -31
- package/dist/services/github/v4/apiRequestV4.js +0 -71
- package/dist/services/github/v4/apiRequestV4.test.d.ts +0 -1
- package/dist/services/github/v4/apiRequestV4.test.js +0 -109
- package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -2
- package/dist/services/github/v4/disablePullRequestAutoMerge.js +0 -32
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -2
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +0 -50
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +0 -1
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
- package/dist/services/github/v4/fetchAuthorId.d.ts +0 -10
- package/dist/services/github/v4/fetchAuthorId.js +0 -28
- package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchAuthorId.private.test.js +0 -25
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -93
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +0 -11
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +0 -58
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +0 -136
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +0 -11
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +0 -48
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +0 -118
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +0 -29
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +0 -110
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +0 -196
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -157
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +0 -3
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +0 -61
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +0 -107
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +0 -12
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +0 -69
- package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -9
- package/dist/services/github/v4/fetchExistingPullRequest.js +0 -64
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -44
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -2
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +0 -39
- package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +0 -8
- package/dist/services/github/v4/fetchRemoteProjectConfig.js +0 -49
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +0 -49
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +0 -69
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +0 -73
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +0 -1
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -116
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +0 -16
- package/dist/services/github/v4/getOptionsFromGithub/query.js +0 -29
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +0 -29
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +0 -61
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +0 -1
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +0 -72
- package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +0 -176
- package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +0 -6
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +0 -45
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +0 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +0 -87
- package/dist/services/logger.d.ts +0 -9
- package/dist/services/logger.js +0 -74
- package/dist/services/prompt.test.d.ts +0 -1
- package/dist/services/prompt.test.js +0 -139
- package/dist/services/prompts.d.ts +0 -17
- package/dist/services/prompts.js +0 -132
- package/dist/services/remoteConfig.d.ts +0 -20
- package/dist/services/remoteConfig.js +0 -52
- package/dist/services/sequentially.d.ts +0 -1
- package/dist/services/sequentially.js +0 -10
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +0 -16
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +0 -102
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +0 -1
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +0 -467
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +0 -26
- package/dist/services/sourceCommit/getMockSourceCommit.js +0 -103
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +0 -108
- package/dist/services/sourceCommit/parseSourceCommit.js +0 -123
- package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit/parseSourceCommit.test.js +0 -226
- package/dist/services/test.d.ts +0 -1
- package/dist/services/test.js +0 -23
- package/dist/state.d.ts +0 -0
- package/dist/state.js +0 -1
- package/dist/test/ExecError.d.ts +0 -16
- package/dist/test/ExecError.js +0 -15
- package/dist/test/e2e/cli/cli.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/cli.private.test.js +0 -222
- package/dist/test/e2e/cli/date-filters.d.ts +0 -1
- package/dist/test/e2e/cli/date-filters.js +0 -43
- package/dist/test/e2e/cli/interactive-error-handling.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/interactive-error-handling.private.test.js +0 -80
- package/dist/test/e2e/cli/non-interactive-error-handling.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/non-interactive-error-handling.private.test.js +0 -198
- package/dist/test/e2e/cli.e2e.private.test.d.ts +0 -1
- package/dist/test/e2e/cli.e2e.private.test.js +0 -433
- package/dist/test/e2e/module/module.mutation.test.d.ts +0 -1
- package/dist/test/e2e/module/module.mutation.test.js +0 -369
- package/dist/test/e2e/module.e2e.mutation.test.d.ts +0 -1
- package/dist/test/e2e/module.e2e.mutation.test.js +0 -369
- package/dist/test/e2e/module.e2e.private.test.d.ts +0 -1
- package/dist/test/e2e/module.e2e.private.test.js +0 -369
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -13
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +0 -243
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +0 -320
- package/dist/ui/getCommits.d.ts +0 -2
- package/dist/ui/getCommits.js +0 -75
- package/dist/ui/getCommitsWithoutBackports.d.ts +0 -11
- package/dist/ui/getCommitsWithoutBackports.js +0 -68
- package/dist/ui/getCommitsWithoutBackports.test.d.ts +0 -1
- package/dist/ui/getCommitsWithoutBackports.test.js +0 -335
- package/dist/ui/getGitConfigAuthor.d.ts +0 -6
- package/dist/ui/getGitConfigAuthor.js +0 -15
- package/dist/ui/getTargetBranches.d.ts +0 -5
- package/dist/ui/getTargetBranches.js +0 -67
- package/dist/ui/getTargetBranches.test.d.ts +0 -1
- package/dist/ui/getTargetBranches.test.js +0 -204
- package/dist/ui/maybeSetupRepo.d.ts +0 -2
- package/dist/ui/maybeSetupRepo.js +0 -53
- package/dist/ui/maybeSetupRepo.test.d.ts +0 -1
- package/dist/ui/maybeSetupRepo.test.js +0 -238
- package/dist/ui/ora.d.ts +0 -2
- package/dist/ui/ora.js +0 -21
- package/dist/ui/setupRepo.d.ts +0 -2
- package/dist/ui/setupRepo.js +0 -56
- package/dist/ui/setupRepo.test.d.ts +0 -1
- package/dist/ui/setupRepo.test.js +0 -273
- package/dist/utils/filterMissingCommits.d.ts +0 -2
- package/dist/utils/filterMissingCommits.js +0 -7
- package/dist/utils/redact.d.ts +0 -1
- package/dist/utils/redact.js +0 -7
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const entrypoint_module_1 = require("./entrypoint.module");
|
|
4
|
-
const getDevAccessToken_1 = require("./test/private/getDevAccessToken");
|
|
5
|
-
describe('entrypoint.module', () => {
|
|
6
|
-
it('getCommits', async () => {
|
|
7
|
-
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
8
|
-
const commits = await (0, entrypoint_module_1.getCommits)({
|
|
9
|
-
accessToken: accessToken,
|
|
10
|
-
repoName: 'backport-e2e',
|
|
11
|
-
repoOwner: 'backport-org',
|
|
12
|
-
pullNumber: 2,
|
|
13
|
-
});
|
|
14
|
-
const expectedCommits = [
|
|
15
|
-
{
|
|
16
|
-
author: { email: 'sorenlouv@gmail.com', name: 'Søren Louv-Jansen' },
|
|
17
|
-
sourceCommit: {
|
|
18
|
-
committedDate: '2020-08-15T10:44:04Z',
|
|
19
|
-
message: 'Add family emoji (#2)',
|
|
20
|
-
sha: '59d6ff1ca90a4ce210c0a4f0e159214875c19d60',
|
|
21
|
-
},
|
|
22
|
-
sourcePullRequest: {
|
|
23
|
-
number: 2,
|
|
24
|
-
url: 'https://github.com/backport-org/backport-e2e/pull/2',
|
|
25
|
-
mergeCommit: {
|
|
26
|
-
message: 'Add family emoji (#2)',
|
|
27
|
-
sha: '59d6ff1ca90a4ce210c0a4f0e159214875c19d60',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
sourceBranch: 'master',
|
|
31
|
-
expectedTargetPullRequests: [
|
|
32
|
-
{
|
|
33
|
-
branch: '7.x',
|
|
34
|
-
number: 4,
|
|
35
|
-
state: 'MERGED',
|
|
36
|
-
url: 'https://github.com/backport-org/backport-e2e/pull/4',
|
|
37
|
-
mergeCommit: {
|
|
38
|
-
message: 'Add family emoji (#2) (#4)',
|
|
39
|
-
sha: 'f8b4f6ae7ffaf2732fa5e33e98b3ea772bdfff1d',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
];
|
|
45
|
-
expect(commits).toEqual(expectedCommits);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Commit } from '../lib/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 {};
|
|
@@ -1,29 +0,0 @@
|
|
|
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,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
7
|
-
const rest_1 = require("@octokit/rest");
|
|
8
|
-
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
9
|
-
const createPullRequest_1 = require("../v3/createPullRequest");
|
|
10
|
-
const disablePullRequestAutoMerge_1 = require("./disablePullRequestAutoMerge");
|
|
11
|
-
const enablePullRequestAutoMerge_1 = require("./enablePullRequestAutoMerge");
|
|
12
|
-
const fetchPullRequestAutoMergeMethod_1 = require("./fetchPullRequestAutoMergeMethod");
|
|
13
|
-
// The test repo requires auto-merge being enabled in options, as well as all merge types enabled (merge, squash, rebase)
|
|
14
|
-
// The test pull requests should be open, and not currently able to be merged (e.g. because it requires an approval),
|
|
15
|
-
// otherwise it will be merged when auto-merge is turned on
|
|
16
|
-
const TEST_REPO_OWNER = 'backport-org';
|
|
17
|
-
const TEST_REPO_NAME = 'repo-with-auto-merge-enabled';
|
|
18
|
-
// commit to create new branch from
|
|
19
|
-
// https://github.com/backport-org/repo-with-auto-merge-enabled/commit/1a88d210f90a22e2a06253c5760909833dc820e9
|
|
20
|
-
const COMMIT_SHA = '1a88d210f90a22e2a06253c5760909833dc820e9';
|
|
21
|
-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
22
|
-
async function closePr(octokit, pullNumber) {
|
|
23
|
-
await octokit.pulls.update({
|
|
24
|
-
owner: TEST_REPO_OWNER,
|
|
25
|
-
repo: TEST_REPO_NAME,
|
|
26
|
-
pull_number: pullNumber,
|
|
27
|
-
state: 'closed',
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
async function createPr(options, branchName) {
|
|
31
|
-
const prPayload = {
|
|
32
|
-
base: 'main',
|
|
33
|
-
head: branchName,
|
|
34
|
-
body: 'testing...',
|
|
35
|
-
owner: TEST_REPO_OWNER,
|
|
36
|
-
repo: TEST_REPO_NAME,
|
|
37
|
-
title: 'my pr title',
|
|
38
|
-
};
|
|
39
|
-
const { number } = await (0, createPullRequest_1.createPullRequest)({ options, prPayload });
|
|
40
|
-
return number;
|
|
41
|
-
}
|
|
42
|
-
async function deleteBranch(octokit, branchName) {
|
|
43
|
-
await octokit.git.deleteRef({
|
|
44
|
-
owner: TEST_REPO_OWNER,
|
|
45
|
-
repo: TEST_REPO_NAME,
|
|
46
|
-
ref: `heads/${branchName}`,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
async function createBranch(octokit, branchName, sha) {
|
|
50
|
-
await octokit.git.createRef({
|
|
51
|
-
owner: TEST_REPO_OWNER,
|
|
52
|
-
repo: TEST_REPO_NAME,
|
|
53
|
-
ref: `refs/heads/${branchName}`,
|
|
54
|
-
sha,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
// causes flaky test runs on CI because parallel builds are racing each other
|
|
58
|
-
// might also be an issue with Github's API being slow at updating after a mutation happens
|
|
59
|
-
// eslint-disable-next-line jest/no-disabled-tests
|
|
60
|
-
describe.skip('enablePullRequestAutoMerge', () => {
|
|
61
|
-
let pullNumber;
|
|
62
|
-
let branchName;
|
|
63
|
-
let octokit;
|
|
64
|
-
let options;
|
|
65
|
-
beforeAll(async () => {
|
|
66
|
-
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
67
|
-
const randomString = crypto_1.default.randomBytes(4).toString('hex');
|
|
68
|
-
branchName = `test-${randomString}`;
|
|
69
|
-
options = {
|
|
70
|
-
accessToken,
|
|
71
|
-
repoOwner: TEST_REPO_OWNER,
|
|
72
|
-
repoName: TEST_REPO_NAME,
|
|
73
|
-
};
|
|
74
|
-
octokit = new rest_1.Octokit({ auth: accessToken });
|
|
75
|
-
await createBranch(octokit, branchName, COMMIT_SHA);
|
|
76
|
-
pullNumber = await createPr(options, branchName);
|
|
77
|
-
});
|
|
78
|
-
// cleanup
|
|
79
|
-
afterAll(async () => {
|
|
80
|
-
await closePr(octokit, pullNumber);
|
|
81
|
-
await deleteBranch(octokit, branchName);
|
|
82
|
-
});
|
|
83
|
-
// reset auto-merge state between runs
|
|
84
|
-
afterEach(async () => {
|
|
85
|
-
await (0, disablePullRequestAutoMerge_1.disablePullRequestAutoMerge)(options, pullNumber);
|
|
86
|
-
});
|
|
87
|
-
it('should initially have auto-merge disabled', async () => {
|
|
88
|
-
const autoMergeMethod = await (0, fetchPullRequestAutoMergeMethod_1.fetchPullRequestAutoMergeMethod)(options, pullNumber);
|
|
89
|
-
expect(autoMergeMethod).toBe(undefined);
|
|
90
|
-
});
|
|
91
|
-
it('should enable auto-merge via merge', async () => {
|
|
92
|
-
await (0, enablePullRequestAutoMerge_1.enablePullRequestAutoMerge)({ ...options, autoMergeMethod: 'merge' }, pullNumber);
|
|
93
|
-
// ensure Github API reflects the change before querying
|
|
94
|
-
await sleep(100);
|
|
95
|
-
const autoMergeMethod = await (0, fetchPullRequestAutoMergeMethod_1.fetchPullRequestAutoMergeMethod)(options, pullNumber);
|
|
96
|
-
expect(autoMergeMethod).toBe('MERGE');
|
|
97
|
-
});
|
|
98
|
-
it('should not enable auto-merge via rebase because it is disallowed', async () => {
|
|
99
|
-
await (0, enablePullRequestAutoMerge_1.enablePullRequestAutoMerge)({ ...options, autoMergeMethod: 'rebase' }, pullNumber);
|
|
100
|
-
// ensure Github API reflects the change before querying
|
|
101
|
-
await sleep(100);
|
|
102
|
-
const autoMergeMethod = await (0, fetchPullRequestAutoMergeMethod_1.fetchPullRequestAutoMergeMethod)(options, pullNumber);
|
|
103
|
-
expect(autoMergeMethod).toBe(undefined);
|
|
104
|
-
});
|
|
105
|
-
it('should enable auto-merge via squash', async () => {
|
|
106
|
-
await (0, enablePullRequestAutoMerge_1.enablePullRequestAutoMerge)({ ...options, autoMergeMethod: 'squash' }, pullNumber);
|
|
107
|
-
// ensure Github API reflects the change before querying
|
|
108
|
-
await sleep(100);
|
|
109
|
-
const autoMergeMethod = await (0, fetchPullRequestAutoMergeMethod_1.fetchPullRequestAutoMergeMethod)(options, pullNumber);
|
|
110
|
-
expect(autoMergeMethod).toBe('SQUASH');
|
|
111
|
-
});
|
|
112
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const os_1 = __importDefault(require("os"));
|
|
26
|
-
const lodash_1 = require("lodash");
|
|
27
|
-
const nock_1 = __importDefault(require("nock"));
|
|
28
|
-
const runSequentially_1 = require("./runSequentially");
|
|
29
|
-
const childProcess = __importStar(require("./services/child-process-promisified"));
|
|
30
|
-
const nockHelpers_1 = require("./test/nockHelpers");
|
|
31
|
-
jest.mock('./services/child-process-promisified', () => {
|
|
32
|
-
return {
|
|
33
|
-
exec: jest.fn(async (cmd) => {
|
|
34
|
-
throw new Error(`Mock required for exec with cmd: "${cmd}"`);
|
|
35
|
-
}),
|
|
36
|
-
execAsCallback: jest.fn((...args) => {
|
|
37
|
-
(0, lodash_1.last)(args)();
|
|
38
|
-
return {
|
|
39
|
-
stderr: {
|
|
40
|
-
on: () => null,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}),
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
|
-
describe('runSequentially', () => {
|
|
47
|
-
let rpcExecMock;
|
|
48
|
-
let rpcExecOriginalMock;
|
|
49
|
-
let res;
|
|
50
|
-
let createPullRequestCalls;
|
|
51
|
-
afterEach(() => {
|
|
52
|
-
jest.clearAllMocks();
|
|
53
|
-
nock_1.default.cleanAll();
|
|
54
|
-
});
|
|
55
|
-
beforeEach(async () => {
|
|
56
|
-
jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
|
|
57
|
-
const options = {
|
|
58
|
-
accessToken: 'myAccessToken',
|
|
59
|
-
assignees: [],
|
|
60
|
-
authenticatedUsername: 'sqren_authenticated',
|
|
61
|
-
author: 'sqren',
|
|
62
|
-
autoAssign: false,
|
|
63
|
-
autoFixConflicts: undefined,
|
|
64
|
-
autoMerge: false,
|
|
65
|
-
autoMergeMethod: 'merge',
|
|
66
|
-
backportBinary: 'node scripts/backport',
|
|
67
|
-
branchLabelMapping: undefined,
|
|
68
|
-
cherrypickRef: true,
|
|
69
|
-
ci: false,
|
|
70
|
-
commitPaths: [],
|
|
71
|
-
cwd: '/path/to/source/repo',
|
|
72
|
-
dateSince: null,
|
|
73
|
-
dateUntil: null,
|
|
74
|
-
details: false,
|
|
75
|
-
editor: 'code',
|
|
76
|
-
fork: true,
|
|
77
|
-
gitHostname: 'github.com',
|
|
78
|
-
githubApiBaseUrlV3: 'https://api.github.com',
|
|
79
|
-
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
80
|
-
mainline: undefined,
|
|
81
|
-
maxNumber: 10,
|
|
82
|
-
multipleBranches: false,
|
|
83
|
-
multipleCommits: false,
|
|
84
|
-
noVerify: true,
|
|
85
|
-
prFilter: undefined,
|
|
86
|
-
publishStatusComment: true,
|
|
87
|
-
pullNumber: undefined,
|
|
88
|
-
repoName: 'kibana',
|
|
89
|
-
repoOwner: 'elastic',
|
|
90
|
-
resetAuthor: false,
|
|
91
|
-
reviewers: [],
|
|
92
|
-
sha: undefined,
|
|
93
|
-
skipRemoteConfig: undefined,
|
|
94
|
-
sourceBranch: 'my-source-branch-from-options',
|
|
95
|
-
sourcePRLabels: [],
|
|
96
|
-
targetBranches: [],
|
|
97
|
-
targetBranchChoices: [
|
|
98
|
-
{ name: '6.x' },
|
|
99
|
-
{ name: '6.0' },
|
|
100
|
-
{ name: '5.6' },
|
|
101
|
-
{ name: '5.5' },
|
|
102
|
-
{ name: '5.4' },
|
|
103
|
-
],
|
|
104
|
-
targetPRLabels: [],
|
|
105
|
-
verbose: false,
|
|
106
|
-
};
|
|
107
|
-
rpcExecMock = jest
|
|
108
|
-
.spyOn(childProcess, 'exec')
|
|
109
|
-
.mockResolvedValue({ stdout: '', stderr: '' });
|
|
110
|
-
rpcExecOriginalMock = jest.spyOn(childProcess, 'execAsCallback');
|
|
111
|
-
const scope = (0, nock_1.default)('https://api.github.com')
|
|
112
|
-
.post('/repos/elastic/kibana/pulls')
|
|
113
|
-
.reply(200, {
|
|
114
|
-
number: 1337,
|
|
115
|
-
html_url: 'myHtmlUrl',
|
|
116
|
-
});
|
|
117
|
-
createPullRequestCalls = (0, nockHelpers_1.listenForCallsToNockScope)(scope);
|
|
118
|
-
const commits = [
|
|
119
|
-
{
|
|
120
|
-
sourceCommit: {
|
|
121
|
-
committedDate: '1',
|
|
122
|
-
message: 'My commit message',
|
|
123
|
-
sha: 'abcd',
|
|
124
|
-
},
|
|
125
|
-
sourcePullRequest: {
|
|
126
|
-
url: 'foo',
|
|
127
|
-
number: 55,
|
|
128
|
-
mergeCommit: {
|
|
129
|
-
message: 'My commit message',
|
|
130
|
-
sha: 'abcd',
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
sourceBranch: 'master',
|
|
134
|
-
expectedTargetPullRequests: [],
|
|
135
|
-
},
|
|
136
|
-
];
|
|
137
|
-
const targetBranches = ['7.x'];
|
|
138
|
-
res = await (0, runSequentially_1.runSequentially)({ options, commits, targetBranches });
|
|
139
|
-
scope.done();
|
|
140
|
-
});
|
|
141
|
-
it('returns pull request', () => {
|
|
142
|
-
expect(res).toEqual([
|
|
143
|
-
{
|
|
144
|
-
didUpdate: false,
|
|
145
|
-
pullRequestNumber: 1337,
|
|
146
|
-
pullRequestUrl: 'myHtmlUrl',
|
|
147
|
-
status: 'success',
|
|
148
|
-
targetBranch: '7.x',
|
|
149
|
-
},
|
|
150
|
-
]);
|
|
151
|
-
});
|
|
152
|
-
it('creates pull request', () => {
|
|
153
|
-
expect(createPullRequestCalls).toMatchInlineSnapshot(`
|
|
154
|
-
Array [
|
|
155
|
-
Object {
|
|
156
|
-
"base": "7.x",
|
|
157
|
-
"body": "# Backport
|
|
158
|
-
|
|
159
|
-
This will backport the following commits from \`master\` to \`7.x\`:
|
|
160
|
-
- [My commit message](foo)
|
|
161
|
-
|
|
162
|
-
<!--- Backport version: 1.2.3-mocked -->
|
|
163
|
-
|
|
164
|
-
### Questions ?
|
|
165
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
166
|
-
"head": "sqren_authenticated:backport/7.x/pr-55",
|
|
167
|
-
"title": "[7.x] My commit message",
|
|
168
|
-
},
|
|
169
|
-
]
|
|
170
|
-
`);
|
|
171
|
-
});
|
|
172
|
-
it('should run commands in correct folders', () => {
|
|
173
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
174
|
-
expect(rpcExecMock.mock.calls.map(([cmd, { cwd }]) => ({ cmd, cwd }))).toEqual([
|
|
175
|
-
{
|
|
176
|
-
cmd: 'git rev-parse --show-toplevel',
|
|
177
|
-
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
cmd: 'git remote --verbose',
|
|
181
|
-
cwd: '/path/to/source/repo',
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
cmd: 'git remote rm origin',
|
|
185
|
-
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
cmd: 'git remote rm sqren_authenticated',
|
|
189
|
-
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
cmd: 'git remote add sqren_authenticated https://x-access-token:myAccessToken@github.com/sqren_authenticated/kibana.git',
|
|
193
|
-
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
cmd: 'git remote rm elastic',
|
|
197
|
-
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
cmd: 'git remote add elastic https://x-access-token:myAccessToken@github.com/elastic/kibana.git',
|
|
201
|
-
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
cmd: 'git reset --hard && git clean -d --force && git fetch elastic 7.x && git checkout -B backport/7.x/pr-55 elastic/7.x --no-track',
|
|
205
|
-
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
cmd: 'git fetch elastic master:master --force',
|
|
209
|
-
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
cmd: 'git rev-list -1 --merges abcd~1..abcd',
|
|
213
|
-
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
cmd: 'git cherry-pick -x abcd',
|
|
217
|
-
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
cmd: 'git push sqren_authenticated backport/7.x/pr-55:backport/7.x/pr-55 --force',
|
|
221
|
-
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
cmd: 'git reset --hard && git checkout my-source-branch-from-options && git branch -D backport/7.x/pr-55',
|
|
225
|
-
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
226
|
-
},
|
|
227
|
-
]);
|
|
228
|
-
});
|
|
229
|
-
it('git clone should be called with correct args', () => {
|
|
230
|
-
expect(rpcExecOriginalMock).toHaveBeenCalledTimes(1);
|
|
231
|
-
expect(rpcExecOriginalMock.mock.calls).toMatchInlineSnapshot(`
|
|
232
|
-
Array [
|
|
233
|
-
Array [
|
|
234
|
-
"git clone https://x-access-token:myAccessToken@github.com/elastic/kibana.git /myHomeDir/.backport/repositories/elastic/kibana --progress",
|
|
235
|
-
Object {
|
|
236
|
-
"maxBuffer": 104857600,
|
|
237
|
-
},
|
|
238
|
-
[Function],
|
|
239
|
-
],
|
|
240
|
-
]
|
|
241
|
-
`);
|
|
242
|
-
});
|
|
243
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,29 +0,0 @@
|
|
|
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,19 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,29 +0,0 @@
|
|
|
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,19 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,29 +0,0 @@
|
|
|
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,25 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import childProcess from 'child_process';
|
|
3
|
-
export declare function exec(cmd: string, options: childProcess.ExecOptions & {
|
|
4
|
-
cwd: string;
|
|
5
|
-
}): Promise<{
|
|
6
|
-
stdout: string;
|
|
7
|
-
stderr: string;
|
|
8
|
-
}>;
|
|
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
|
-
}
|