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
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const getTargetBranches_1 = require("./getTargetBranches");
|
|
27
|
+
const validateTargetBranches = __importStar(require("./github/v4/validateTargetBranches"));
|
|
28
|
+
const prompts = __importStar(require("./prompts"));
|
|
29
|
+
describe('getTargetBranches', () => {
|
|
30
|
+
let promptSpy;
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
jest.clearAllMocks();
|
|
33
|
+
promptSpy = jest
|
|
34
|
+
.spyOn(prompts, 'promptForTargetBranches')
|
|
35
|
+
.mockResolvedValueOnce(['branchA']);
|
|
36
|
+
});
|
|
37
|
+
describe('when `options.targetBranches` is empty', () => {
|
|
38
|
+
let branches;
|
|
39
|
+
beforeEach(async () => {
|
|
40
|
+
const options = {
|
|
41
|
+
targetBranches: [],
|
|
42
|
+
targetBranchChoices: [{ name: 'branchA' }, { name: 'branchB' }],
|
|
43
|
+
multipleBranches: false,
|
|
44
|
+
interactive: true,
|
|
45
|
+
};
|
|
46
|
+
const commits = [
|
|
47
|
+
{
|
|
48
|
+
author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
|
|
49
|
+
sourceCommit: {
|
|
50
|
+
committedDate: 'aaa',
|
|
51
|
+
message: 'hey',
|
|
52
|
+
sha: 'abcd',
|
|
53
|
+
},
|
|
54
|
+
sourcePullRequest: {
|
|
55
|
+
url: 'foo',
|
|
56
|
+
number: 1337,
|
|
57
|
+
mergeCommit: {
|
|
58
|
+
message: 'hey',
|
|
59
|
+
sha: 'abcd',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
sourceBranch: '7.x',
|
|
63
|
+
expectedTargetPullRequests: [],
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
branches = await (0, getTargetBranches_1.getTargetBranches)(options, commits);
|
|
67
|
+
});
|
|
68
|
+
it('should return branches from prompt', () => {
|
|
69
|
+
expect(branches).toEqual(['branchA']);
|
|
70
|
+
});
|
|
71
|
+
it('should call prompt with correct args', () => {
|
|
72
|
+
expect(promptSpy).toHaveBeenLastCalledWith({
|
|
73
|
+
targetBranchChoices: [{ name: 'branchA' }, { name: 'branchB' }],
|
|
74
|
+
isMultipleChoice: false,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
describe('when `options.targetBranches` is not empty', () => {
|
|
79
|
+
let branches;
|
|
80
|
+
beforeEach(async () => {
|
|
81
|
+
jest
|
|
82
|
+
.spyOn(validateTargetBranches, 'validateTargetBranches')
|
|
83
|
+
.mockResolvedValueOnce();
|
|
84
|
+
branches = await (0, getTargetBranches_1.getTargetBranches)({
|
|
85
|
+
targetBranches: ['branchA', 'branchB'],
|
|
86
|
+
targetBranchChoices: [],
|
|
87
|
+
multipleBranches: false,
|
|
88
|
+
}, []);
|
|
89
|
+
});
|
|
90
|
+
it('should return branches from `options.branches`', () => {
|
|
91
|
+
expect(branches).toEqual(['branchA', 'branchB']);
|
|
92
|
+
});
|
|
93
|
+
it('should not call prompt', () => {
|
|
94
|
+
expect(promptSpy).not.toHaveBeenCalled();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
describe('when interactive=false', () => {
|
|
98
|
+
it('should throw when there are no missing backports', async () => {
|
|
99
|
+
const commits = [];
|
|
100
|
+
await expect(() => {
|
|
101
|
+
return (0, getTargetBranches_1.getTargetBranches)({
|
|
102
|
+
expectedTargetPullRequests: [],
|
|
103
|
+
interactive: false,
|
|
104
|
+
}, commits);
|
|
105
|
+
}).rejects.toThrowError('There are no branches to backport to. Aborting.');
|
|
106
|
+
});
|
|
107
|
+
it('should return missing backports', async () => {
|
|
108
|
+
const commits = [
|
|
109
|
+
{
|
|
110
|
+
expectedTargetPullRequests: [
|
|
111
|
+
{ branch: '7.2', state: 'MERGED' },
|
|
112
|
+
{ branch: '7.1', state: 'OPEN' },
|
|
113
|
+
{ branch: '7.x', state: 'NOT_CREATED' },
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
const targetBranches = await (0, getTargetBranches_1.getTargetBranches)({ interactive: false }, commits);
|
|
118
|
+
expect(targetBranches).toEqual(['7.x']);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
describe('when `expectedTargetPullRequests` is missing a backport to 7.x', () => {
|
|
122
|
+
let targetBranchChoices;
|
|
123
|
+
beforeEach(async () => {
|
|
124
|
+
const options = {
|
|
125
|
+
interactive: true,
|
|
126
|
+
targetBranches: [],
|
|
127
|
+
multipleBranches: true,
|
|
128
|
+
targetBranchChoices: [
|
|
129
|
+
{ name: 'master' },
|
|
130
|
+
{ name: '7.x' },
|
|
131
|
+
{ name: '7.7' },
|
|
132
|
+
{ name: '7.6' },
|
|
133
|
+
{ name: '7.5' },
|
|
134
|
+
],
|
|
135
|
+
branchLabelMapping: {},
|
|
136
|
+
sourceBranch: 'master',
|
|
137
|
+
};
|
|
138
|
+
const commits = [
|
|
139
|
+
{
|
|
140
|
+
author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
|
|
141
|
+
sourceCommit: {
|
|
142
|
+
committedDate: 'bbb',
|
|
143
|
+
message: '[backport] Bump to 5.1.3 (#62286)',
|
|
144
|
+
sha: 'my-sha',
|
|
145
|
+
},
|
|
146
|
+
sourcePullRequest: {
|
|
147
|
+
url: 'foo',
|
|
148
|
+
number: 62286,
|
|
149
|
+
mergeCommit: {
|
|
150
|
+
message: '[backport] Bump to 5.1.3 (#62286)',
|
|
151
|
+
sha: 'my-sha',
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
sourceBranch: 'master',
|
|
155
|
+
expectedTargetPullRequests: [{ branch: '7.x', state: 'NOT_CREATED' }],
|
|
156
|
+
},
|
|
157
|
+
];
|
|
158
|
+
await (0, getTargetBranches_1.getTargetBranches)(options, commits);
|
|
159
|
+
targetBranchChoices = promptSpy.mock.calls[0][0].targetBranchChoices;
|
|
160
|
+
});
|
|
161
|
+
it('should list the correct branches', async () => {
|
|
162
|
+
expect(targetBranchChoices).toEqual([
|
|
163
|
+
{ checked: true, name: '7.x' },
|
|
164
|
+
{ checked: false, name: '7.7' },
|
|
165
|
+
{ checked: false, name: '7.6' },
|
|
166
|
+
{ checked: false, name: '7.5' },
|
|
167
|
+
]);
|
|
168
|
+
});
|
|
169
|
+
it('should not list the sourceBranch (master)', async () => {
|
|
170
|
+
expect(targetBranchChoices).not.toContainEqual(expect.objectContaining({ name: 'master' }));
|
|
171
|
+
});
|
|
172
|
+
it('should select 7.x', async () => {
|
|
173
|
+
expect(targetBranchChoices).toContainEqual({
|
|
174
|
+
name: '7.x',
|
|
175
|
+
checked: true,
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
describe('getTargetBranchChoices', () => {
|
|
181
|
+
const options = {
|
|
182
|
+
interactive: true,
|
|
183
|
+
targetBranchChoices: [
|
|
184
|
+
{ name: 'master', checked: true },
|
|
185
|
+
{ name: '7.x', checked: true },
|
|
186
|
+
{ name: '7.8', checked: false },
|
|
187
|
+
{ name: '7.7', checked: false },
|
|
188
|
+
],
|
|
189
|
+
branchLabelMapping: {},
|
|
190
|
+
};
|
|
191
|
+
const sourceBranch = 'master';
|
|
192
|
+
it('should not check any branches if no labels match', () => {
|
|
193
|
+
const targetBranchesFromLabels = [];
|
|
194
|
+
const branches = (0, getTargetBranches_1.getTargetBranchChoices)(options, targetBranchesFromLabels, sourceBranch);
|
|
195
|
+
expect(branches).toEqual([
|
|
196
|
+
{ checked: false, name: '7.x' },
|
|
197
|
+
{ checked: false, name: '7.8' },
|
|
198
|
+
{ checked: false, name: '7.7' },
|
|
199
|
+
]);
|
|
200
|
+
});
|
|
201
|
+
it('should pre-select branches based on labels', () => {
|
|
202
|
+
const targetBranchesFromLabels = ['7.7'];
|
|
203
|
+
const branches = (0, getTargetBranches_1.getTargetBranchChoices)(options, targetBranchesFromLabels, sourceBranch);
|
|
204
|
+
expect(branches).toEqual([
|
|
205
|
+
{ checked: false, name: '7.x' },
|
|
206
|
+
{ checked: false, name: '7.8' },
|
|
207
|
+
{ checked: true, name: '7.7' },
|
|
208
|
+
]);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ValidConfigOptions } from '../options/options';
|
|
2
|
+
import { ExpectedTargetPullRequest } from './sourceCommit/getExpectedTargetPullRequests';
|
|
3
|
+
import { Commit } from './sourceCommit/parseSourceCommit';
|
|
4
|
+
export declare function getRemoteUrl({ repoName, accessToken, gitHostname }: ValidConfigOptions, repoOwner: string): string;
|
|
5
|
+
export declare function cloneRepo({ sourcePath, targetPath }: {
|
|
6
|
+
sourcePath: string;
|
|
7
|
+
targetPath: string;
|
|
8
|
+
}, onProgress: (progress: number) => void): Promise<void>;
|
|
9
|
+
export declare function getLocalConfigFileCommitDate({ cwd }: {
|
|
10
|
+
cwd: string;
|
|
11
|
+
}): Promise<number | undefined>;
|
|
12
|
+
export declare function isLocalConfigFileUntracked({ cwd }: {
|
|
13
|
+
cwd: string;
|
|
14
|
+
}): Promise<boolean | undefined>;
|
|
15
|
+
export declare function isLocalConfigFileModified({ cwd }: {
|
|
16
|
+
cwd: string;
|
|
17
|
+
}): Promise<boolean>;
|
|
18
|
+
export declare function getRepoInfoFromGitRemotes({ cwd }: {
|
|
19
|
+
cwd: string;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
repoOwner: string;
|
|
22
|
+
repoName: string;
|
|
23
|
+
}[]>;
|
|
24
|
+
export declare function getGitProjectRootPath(dir: string): Promise<string | undefined>;
|
|
25
|
+
export declare function getIsCommitInBranch(options: ValidConfigOptions, commitSha: string): Promise<boolean>;
|
|
26
|
+
export declare function deleteRemote(options: ValidConfigOptions, remoteName: string): Promise<void>;
|
|
27
|
+
export declare function addRemote(options: ValidConfigOptions, remoteName: string): Promise<void>;
|
|
28
|
+
export declare function fetchBranch(options: ValidConfigOptions, branch: string): Promise<void>;
|
|
29
|
+
export declare function getIsMergeCommit(options: ValidConfigOptions, sha: string): Promise<boolean>;
|
|
30
|
+
export declare function getCommitsInMergeCommit(options: ValidConfigOptions, sha: string): Promise<string[]>;
|
|
31
|
+
export declare function cherrypick({ options, sha, mergedTargetPullRequest, commitAuthor, }: {
|
|
32
|
+
options: ValidConfigOptions;
|
|
33
|
+
sha: string;
|
|
34
|
+
mergedTargetPullRequest?: ExpectedTargetPullRequest;
|
|
35
|
+
commitAuthor: {
|
|
36
|
+
name: string;
|
|
37
|
+
email: string;
|
|
38
|
+
};
|
|
39
|
+
}): Promise<{
|
|
40
|
+
conflictingFiles: {
|
|
41
|
+
absolute: string;
|
|
42
|
+
relative: string;
|
|
43
|
+
}[];
|
|
44
|
+
unstagedFiles: string[];
|
|
45
|
+
needsResolving: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
export declare function commitChanges(commit: Commit, options: ValidConfigOptions): Promise<void>;
|
|
48
|
+
export declare type ConflictingFiles = Awaited<ReturnType<typeof getConflictingFiles>>;
|
|
49
|
+
export declare function getConflictingFiles(options: ValidConfigOptions): Promise<{
|
|
50
|
+
absolute: string;
|
|
51
|
+
relative: string;
|
|
52
|
+
}[]>;
|
|
53
|
+
export declare function getUnstagedFiles(options: ValidConfigOptions): Promise<string[]>;
|
|
54
|
+
export declare function getGitConfig({ dir, key, }: {
|
|
55
|
+
dir: string;
|
|
56
|
+
key: 'user.name' | 'user.email';
|
|
57
|
+
}): Promise<string | undefined>;
|
|
58
|
+
export declare function createBackportBranch({ options, targetBranch, backportBranch, }: {
|
|
59
|
+
options: ValidConfigOptions;
|
|
60
|
+
targetBranch: string;
|
|
61
|
+
backportBranch: string;
|
|
62
|
+
}): Promise<void>;
|
|
63
|
+
export declare function deleteBackportBranch({ options, backportBranch, }: {
|
|
64
|
+
options: ValidConfigOptions;
|
|
65
|
+
backportBranch: string;
|
|
66
|
+
}): Promise<void>;
|
|
67
|
+
export declare function getRepoForkOwner(options: ValidConfigOptions): string;
|
|
68
|
+
export declare function pushBackportBranch({ options, backportBranch, }: {
|
|
69
|
+
options: ValidConfigOptions;
|
|
70
|
+
backportBranch: string;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
cmdArgs: string[];
|
|
73
|
+
code: number | null;
|
|
74
|
+
stderr: string;
|
|
75
|
+
stdout: string;
|
|
76
|
+
}>;
|
|
77
|
+
export declare function getLocalSourceRepoPath(options: ValidConfigOptions): Promise<string | undefined>;
|