backport 6.1.5 → 6.3.0-beta-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 +15 -6
- package/dist/{main.d.ts → backportRun.d.ts} +3 -3
- package/dist/{main.js → backportRun.js} +21 -10
- package/dist/{entrypoint.module.private.test.d.ts → entrypoint.cli.e2e.private.test.d.ts} +0 -0
- package/dist/entrypoint.cli.e2e.private.test.js +277 -0
- package/dist/entrypoint.cli.js +3 -5
- package/dist/{options/getValidatedOptions.test.d.ts → entrypoint.cli.private.test.d.ts} +0 -0
- package/dist/{entrypoint.module.private.test.js → entrypoint.cli.private.test.js} +17 -8
- package/dist/entrypoint.module.d.ts +2 -2
- package/dist/entrypoint.module.js +4 -4
- package/dist/options/ConfigOptions.d.ts +5 -1
- package/dist/options/cliArgs.d.ts +16 -14
- package/dist/options/cliArgs.js +15 -5
- package/dist/options/cliArgs.test.js +28 -10
- package/dist/options/config/config.d.ts +10 -4
- package/dist/options/config/config.js +7 -6
- package/dist/options/config/config.test.js +11 -1
- package/dist/options/config/globalConfig.d.ts +1 -1
- package/dist/options/config/globalConfig.js +15 -9
- package/dist/options/config/globalConfig.test.js +19 -32
- package/dist/options/config/projectConfig.d.ts +3 -1
- package/dist/options/config/projectConfig.js +5 -2
- package/dist/options/config/projectConfig.test.js +41 -31
- package/dist/options/config/readConfigFile.d.ts +27 -23
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +18 -39
- package/dist/options/options.js +40 -32
- package/dist/options/options.test.js +83 -47
- package/dist/runSequentially.d.ts +0 -1
- package/dist/runSequentially.js +0 -1
- package/dist/runSequentially.test.js +39 -20
- package/dist/scripts/postinstall.js +3 -3
- package/dist/services/HandledError.d.ts +6 -4
- package/dist/services/HandledError.js +18 -3
- package/dist/services/child-process-promisified.d.ts +3 -1
- package/dist/services/env.d.ts +3 -1
- package/dist/services/env.js +4 -1
- package/dist/services/env.test.js +2 -2
- package/dist/services/git.d.ts +22 -9
- package/dist/services/git.integration.test.js +123 -24
- package/dist/services/git.js +66 -54
- package/dist/services/git.test.js +35 -20
- package/dist/services/github/commitFormatters.d.ts +0 -1
- package/dist/services/github/commitFormatters.js +1 -8
- package/dist/services/github/v3/createPullRequest.js +16 -10
- package/dist/services/github/v3/createPullRequest.test.js +248 -33
- package/dist/services/github/v3/createStatusComment.d.ts +1 -1
- package/dist/services/github/v3/createStatusComment.js +26 -15
- package/dist/services/github/v3/createStatusComment.test.js +165 -70
- package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +2 -1
- package/dist/services/github/v4/FetchPullRequestId.d.ts +0 -7
- package/dist/services/github/v4/apiRequestV4.d.ts +21 -17
- package/dist/services/github/v4/apiRequestV4.js +38 -28
- package/dist/services/github/v4/apiRequestV4.test.js +4 -4
- package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -7
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -7
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +37 -19
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +17 -8
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +23 -14
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +4 -4
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +41 -19
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +1 -8
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +31 -14
- package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -4
- package/dist/services/github/v4/fetchExistingPullRequest.js +1 -2
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -9
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +6 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +41 -34
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +6 -0
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +2 -1
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +56 -0
- package/dist/{options/parseRequiredOptions.test.d.ts → services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts} +0 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +71 -0
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +11 -11
- package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +4 -5
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -7
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +5 -5
- package/dist/services/logger.d.ts +9 -3
- package/dist/services/logger.js +38 -35
- package/dist/services/prompt.test.js +66 -19
- package/dist/services/prompts.js +12 -10
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +1 -1
- package/dist/services/sourceCommit/getMockSourceCommit.js +6 -6
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +18 -10
- package/dist/services/sourceCommit/parseSourceCommit.js +20 -14
- package/dist/services/sourceCommit/parseSourceCommit.test.js +18 -20
- package/dist/{runWithOptions.test.d.ts → test/backport-e2e.mutation.test.d.ts} +0 -0
- package/dist/test/{integration/integration.private.test.js → backport-e2e.mutation.test.js} +143 -123
- package/dist/{scripts/generate-gql.d.ts → test/handleUnbackportedPullRequests.private.test.d.ts} +0 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.js +57 -0
- package/dist/test/mockConfigFiles.js +4 -20
- package/dist/test/mocks.d.ts +10 -0
- package/dist/test/mocks.js +23 -0
- package/dist/test/private/getDevAccessToken.js +5 -4
- package/dist/test/sandbox.d.ts +5 -0
- package/dist/test/sandbox.js +43 -0
- package/dist/test/setupFiles/automatic-mocks.d.ts +1 -0
- package/dist/test/setupFiles/automatic-mocks.js +27 -11
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +12 -13
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +50 -27
- package/dist/ui/getCommits.js +8 -14
- package/dist/ui/getCommitsWithoutBackports.js +6 -6
- package/dist/ui/getCommitsWithoutBackports.test.js +91 -39
- package/dist/ui/getTargetBranches.js +1 -1
- package/dist/ui/getTargetBranches.test.js +26 -8
- package/dist/ui/maybeSetupRepo.js +25 -5
- package/dist/ui/maybeSetupRepo.test.js +144 -14
- package/dist/utils/maybe.d.ts +1 -0
- package/dist/utils/maybe.js +7 -0
- package/dist/utils/packageVersion.d.ts +1 -0
- package/dist/{types/PromiseReturnType.js → utils/packageVersion.js} +2 -0
- package/package.json +24 -20
- package/yarn.lock +160 -237
- package/dist/index.d.ts +0 -783
- package/dist/index.js +0 -8001
- package/dist/ink.d.ts +0 -1
- package/dist/ink.js +0 -49
- package/dist/options/config/getOptionsFromGit.d.ts +0 -4
- package/dist/options/config/getOptionsFromGit.js +0 -8
- package/dist/options/getValidatedOptions.d.ts +0 -49
- package/dist/options/getValidatedOptions.js +0 -45
- package/dist/options/getValidatedOptions.test.js +0 -97
- package/dist/options/parseRequiredOptions.d.ts +0 -71
- package/dist/options/parseRequiredOptions.js +0 -68
- package/dist/options/parseRequiredOptions.test.js +0 -122
- package/dist/runWithOptions.d.ts +0 -9
- package/dist/runWithOptions.js +0 -43
- package/dist/runWithOptions.test.js +0 -304
- package/dist/scripts/generate-gql.js +0 -15
- package/dist/services/fs-promisified.d.ts +0 -6
- package/dist/services/fs-promisified.js +0 -12
- package/dist/services/getExpectedTarget.d.ts +0 -9
- package/dist/services/getExpectedTarget.js +0 -77
- package/dist/services/getExpectedTargetPullRequests.d.ts +0 -9
- package/dist/services/getExpectedTargetPullRequests.js +0 -77
- package/dist/services/github/v4/fetchCommitByPullNumber.d.ts +0 -5
- package/dist/services/github/v4/fetchCommitByPullNumber.js +0 -86
- package/dist/services/github/v4/fetchCommitByPullNumber.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitByPullNumber.private.test.js +0 -57
- package/dist/services/github/v4/fetchCommitBySha.d.ts +0 -5
- package/dist/services/github/v4/fetchCommitBySha.js +0 -95
- package/dist/services/github/v4/fetchCommitBySha.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitBySha.private.test.js +0 -50
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.d.ts +0 -28
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.js +0 -52
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.d.ts +0 -3
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.js +0 -55
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.js +0 -252
- package/dist/services/github/v4/fetchCommitsByAuthor.d.ts +0 -28
- package/dist/services/github/v4/fetchCommitsByAuthor.js +0 -161
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.js +0 -115
- package/dist/services/github/v4/fetchCommitsByAuthor.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitsByAuthor.test.js +0 -272
- package/dist/services/github/v4/fetchDefaultBranch.d.ts +0 -9
- package/dist/services/github/v4/fetchDefaultBranch.js +0 -24
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +0 -4
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.js +0 -52
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +0 -32
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.d.ts +0 -4
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.js +0 -72
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.js +0 -34
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.d.ts +0 -40
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.js +0 -72
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +0 -17
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.js +0 -69
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +0 -32
- package/dist/services/github/v4/fetchMergedPullRequests.d.ts +0 -37
- package/dist/services/github/v4/fetchMergedPullRequests.js +0 -37
- package/dist/services/github/v4/fetchMergedPullRequests.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchMergedPullRequests.private.test.js +0 -59
- package/dist/services/github/v4/fetchMergedPullRequests.test.d.ts +0 -1
- package/dist/services/github/v4/fetchMergedPullRequests.test.js +0 -22
- package/dist/services/github/v4/fetchProjectConfig.d.ts +0 -8
- package/dist/services/github/v4/fetchProjectConfig.js +0 -56
- package/dist/services/github/v4/fetchProjectConfig.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchProjectConfig.private.test.js +0 -52
- package/dist/services/github/v4/fetchProjectConfig.test.d.ts +0 -1
- package/dist/services/github/v4/fetchProjectConfig.test.js +0 -37
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.d.ts +0 -9
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.js +0 -92
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.js +0 -66
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.d.ts +0 -1
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.js +0 -242
- package/dist/services/github/v4/getExistingTargetPullRequests.d.ts +0 -7
- package/dist/services/github/v4/getExistingTargetPullRequests.js +0 -45
- package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +0 -63
- package/dist/services/github/v4/getOptionsFromGithub/index.js +0 -139
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.d.ts +0 -1
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +0 -147
- package/dist/services/github/v4/getTargetBranchesFromLabels.d.ts +0 -5
- package/dist/services/github/v4/getTargetBranchesFromLabels.js +0 -20
- package/dist/services/github/v4/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/services/github/v4/getTargetBranchesFromLabels.test.js +0 -201
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.js +0 -843
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.js +0 -73
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.d.ts +0 -12
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.js +0 -44
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.d.ts +0 -5
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.js +0 -20
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.js +0 -201
- package/dist/services/sourceCommit/sourceCommit.d.ts +0 -78
- package/dist/services/sourceCommit/sourceCommit.js +0 -86
- package/dist/services/sourceCommit/sourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit/sourceCommit.test.js +0 -287
- package/dist/services/sourceCommit.d.ts +0 -78
- package/dist/services/sourceCommit.js +0 -86
- package/dist/services/sourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit.test.js +0 -280
- package/dist/test/inquirer.private.test.d.ts +0 -1
- package/dist/test/inquirer.private.test.js +0 -168
- package/dist/test/integration/createSpies.d.ts +0 -17
- package/dist/test/integration/createSpies.js +0 -85
- package/dist/test/integration/envConstants.d.ts +0 -5
- package/dist/test/integration/envConstants.js +0 -9
- package/dist/test/integration/helpers.d.ts +0 -7
- package/dist/test/integration/helpers.js +0 -31
- package/dist/test/integration/integration.private.test.d.ts +0 -1
- package/dist/test/integration/integration.test.d.ts +0 -1
- package/dist/test/integration/integration.test.js +0 -214
- package/dist/todo-delete.d.ts +0 -1
- package/dist/todo-delete.js +0 -17
- package/dist/types/Commit.d.ts +0 -85
- package/dist/types/Commit.js +0 -139
- package/dist/types/PromiseReturnType.d.ts +0 -1
- package/dist/types/commitNode.d.ts +0 -89
- package/dist/types/commitNode.js +0 -139
- package/dist/types/commitNode.test.d.ts +0 -1
- package/dist/types/commitNode.test.js +0 -255
- package/dist/types/commitWithAssociatedPullRequests.d.ts +0 -86
- package/dist/types/commitWithAssociatedPullRequests.js +0 -145
- package/dist/ui/cherrypickAndCreatePullRequest.test.d.ts +0 -1
- package/dist/ui/cherrypickAndCreatePullRequest.test.js +0 -617
- package/dist/ui/getTargetBranchesFromLabels.d.ts +0 -6
- package/dist/ui/getTargetBranchesFromLabels.js +0 -40
- package/dist/ui/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/ui/getTargetBranchesFromLabels.test.js +0 -288
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const entrypoint_module_1 = require("../entrypoint.module");
|
|
4
|
+
const child_process_promisified_1 = require("../services/child-process-promisified");
|
|
5
|
+
const getDevAccessToken_1 = require("./private/getDevAccessToken");
|
|
6
|
+
const sandbox_1 = require("./sandbox");
|
|
7
|
+
jest.unmock('find-up');
|
|
8
|
+
jest.setTimeout(15000);
|
|
9
|
+
describe('Handle unbackported pull requests', () => {
|
|
10
|
+
it('shows missing backports for PR number 8', async () => {
|
|
11
|
+
const accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
12
|
+
const commits = await (0, entrypoint_module_1.getCommits)({
|
|
13
|
+
accessToken: accessToken,
|
|
14
|
+
repoOwner: 'backport-org',
|
|
15
|
+
repoName: 'repo-with-conflicts',
|
|
16
|
+
pullNumber: 8,
|
|
17
|
+
});
|
|
18
|
+
const expectedCommit = {
|
|
19
|
+
sourceCommit: {
|
|
20
|
+
committedDate: '2021-12-16T00:03:34Z',
|
|
21
|
+
message: 'Change Barca to Braithwaite (#8)',
|
|
22
|
+
sha: '343402a748be2375325b2730fa979bcea5b96ba1',
|
|
23
|
+
},
|
|
24
|
+
sourcePullRequest: {
|
|
25
|
+
number: 8,
|
|
26
|
+
url: 'https://github.com/backport-org/repo-with-conflicts/pull/8',
|
|
27
|
+
mergeCommit: {
|
|
28
|
+
message: 'Change Barca to Braithwaite (#8)',
|
|
29
|
+
sha: '343402a748be2375325b2730fa979bcea5b96ba1',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
sourceBranch: 'main',
|
|
33
|
+
expectedTargetPullRequests: [{ branch: '7.x', state: 'MISSING' }],
|
|
34
|
+
};
|
|
35
|
+
expect(commits[0]).toEqual(expectedCommit);
|
|
36
|
+
});
|
|
37
|
+
it('shows that backport failed because PR number 8 was not backported', async () => {
|
|
38
|
+
const accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
39
|
+
const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
40
|
+
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
41
|
+
await (0, child_process_promisified_1.exec)('git init', { cwd: sandboxPath });
|
|
42
|
+
const result = await (0, entrypoint_module_1.backportRun)({
|
|
43
|
+
accessToken: accessToken,
|
|
44
|
+
repoOwner: 'backport-org',
|
|
45
|
+
repoName: 'repo-with-conflicts',
|
|
46
|
+
pullNumber: 12,
|
|
47
|
+
targetBranches: ['7.x'],
|
|
48
|
+
dir: sandboxPath,
|
|
49
|
+
ci: true,
|
|
50
|
+
publishStatusComment: false,
|
|
51
|
+
});
|
|
52
|
+
const commit =
|
|
53
|
+
//@ts-expect-error
|
|
54
|
+
result.results[0].error.errorContext?.commitsWithoutBackports[0].commit;
|
|
55
|
+
expect(commit.sourcePullRequest?.number).toBe(8);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -1,29 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
4
|
};
|
|
21
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
6
|
exports.mockConfigFiles = void 0;
|
|
23
|
-
const
|
|
7
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
24
8
|
function mockConfigFiles({ projectConfig, globalConfig, }) {
|
|
25
9
|
jest
|
|
26
|
-
.spyOn(
|
|
10
|
+
.spyOn(promises_1.default, 'readFile')
|
|
27
11
|
//@ts-expect-error
|
|
28
12
|
.mockImplementation(async (filepath) => {
|
|
29
13
|
if (filepath === '/path/to/project/config') {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
export declare function mockOra(): void;
|
|
3
|
+
export declare function getOraMock(): {
|
|
4
|
+
start: () => any;
|
|
5
|
+
succeed: () => jest.Mock<any, any>;
|
|
6
|
+
stop: () => jest.Mock<any, any>;
|
|
7
|
+
fail: () => jest.Mock<any, any>;
|
|
8
|
+
stopAndPersist: () => jest.Mock<any, any>;
|
|
9
|
+
text: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getOraMock = exports.mockOra = void 0;
|
|
5
|
+
const oraMock = {
|
|
6
|
+
start: () => oraMock,
|
|
7
|
+
succeed: () => jest.fn(),
|
|
8
|
+
stop: () => jest.fn(),
|
|
9
|
+
fail: () => jest.fn(),
|
|
10
|
+
stopAndPersist: () => jest.fn(),
|
|
11
|
+
set text(value) { },
|
|
12
|
+
};
|
|
13
|
+
function mockOra() {
|
|
14
|
+
const ora = jest.fn(() => oraMock);
|
|
15
|
+
//@ts-expect-error
|
|
16
|
+
ora.oraMock = oraMock;
|
|
17
|
+
jest.mock('ora', () => ora);
|
|
18
|
+
}
|
|
19
|
+
exports.mockOra = mockOra;
|
|
20
|
+
function getOraMock() {
|
|
21
|
+
return oraMock;
|
|
22
|
+
}
|
|
23
|
+
exports.getOraMock = getOraMock;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDevAccessToken = void 0;
|
|
4
|
-
const
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const path_1 = require("path");
|
|
5
6
|
// get global config: either from .backport/config.json or via env variables
|
|
6
7
|
async function getDevAccessToken() {
|
|
7
8
|
const accessToken = process.env.accessToken;
|
|
@@ -10,15 +11,15 @@ async function getDevAccessToken() {
|
|
|
10
11
|
return accessToken;
|
|
11
12
|
}
|
|
12
13
|
// get credentials from config file
|
|
13
|
-
const accessTokenFile = './src/test/private/accessToken.txt';
|
|
14
|
+
const accessTokenFile = (0, path_1.resolve)('./src/test/private/accessToken.txt');
|
|
14
15
|
try {
|
|
15
|
-
const accessToken = await
|
|
16
|
+
const accessToken = await (0, promises_1.readFile)(accessTokenFile, {
|
|
16
17
|
encoding: 'utf-8',
|
|
17
18
|
});
|
|
18
19
|
return accessToken.trim();
|
|
19
20
|
}
|
|
20
21
|
catch (e) {
|
|
21
|
-
throw new Error(`Missing accessToken in "${accessTokenFile}"`);
|
|
22
|
+
throw new Error(`Missing accessToken in "${accessTokenFile}":\n${e.message}`);
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
exports.getDevAccessToken = getDevAccessToken;
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
exports.resetSandbox = exports.getSandboxPath = void 0;
|
|
26
|
+
const path_1 = __importStar(require("path"));
|
|
27
|
+
const del_1 = __importDefault(require("del"));
|
|
28
|
+
const make_dir_1 = __importDefault(require("make-dir"));
|
|
29
|
+
jest.unmock('make-dir');
|
|
30
|
+
jest.unmock('del');
|
|
31
|
+
function getSandboxPath({ filename, specname, }) {
|
|
32
|
+
const baseFilename = getFilenameWithoutExtension(filename);
|
|
33
|
+
return (0, path_1.resolve)(`${__dirname}/_tmp_sandbox_/${baseFilename}${specname ? `/${specname}` : ''}`);
|
|
34
|
+
}
|
|
35
|
+
exports.getSandboxPath = getSandboxPath;
|
|
36
|
+
async function resetSandbox(sandboxPath) {
|
|
37
|
+
await (0, del_1.default)(sandboxPath);
|
|
38
|
+
await (0, make_dir_1.default)(sandboxPath);
|
|
39
|
+
}
|
|
40
|
+
exports.resetSandbox = resetSandbox;
|
|
41
|
+
function getFilenameWithoutExtension(filename) {
|
|
42
|
+
return path_1.default.basename(filename, path_1.default.extname(filename));
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,27 +3,42 @@
|
|
|
3
3
|
* This file is included in `setupFiles` in jest.config.js
|
|
4
4
|
* It will be run once per test file
|
|
5
5
|
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
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 packageVersionModule = __importStar(require("../../utils/packageVersion"));
|
|
27
|
+
const mocks_1 = require("../mocks");
|
|
6
28
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
7
29
|
jest.mock('find-up', () => {
|
|
8
30
|
return jest.fn(async () => '/path/to/project/config');
|
|
9
31
|
});
|
|
32
|
+
// @ts-expect-error
|
|
33
|
+
// eslint-disable-next-line no-import-assign
|
|
34
|
+
packageVersionModule.PACKAGE_VERSION = '1.2.3';
|
|
10
35
|
jest.mock('make-dir', () => {
|
|
11
36
|
return jest.fn(() => Promise.resolve('/some/path'));
|
|
12
37
|
});
|
|
13
38
|
jest.mock('del', () => {
|
|
14
39
|
return jest.fn(async (path) => `Attempted to delete ${path}`);
|
|
15
40
|
});
|
|
16
|
-
|
|
17
|
-
const ora = {
|
|
18
|
-
start: () => ({
|
|
19
|
-
succeed: () => { },
|
|
20
|
-
stop: () => { },
|
|
21
|
-
fail: () => { },
|
|
22
|
-
stopAndPersist: () => { },
|
|
23
|
-
}),
|
|
24
|
-
};
|
|
25
|
-
return jest.fn(() => ora);
|
|
26
|
-
});
|
|
41
|
+
(0, mocks_1.mockOra)();
|
|
27
42
|
// silence logger
|
|
28
43
|
jest.mock('../../services/logger', () => {
|
|
29
44
|
const spy = jest.fn();
|
|
@@ -37,6 +52,7 @@ jest.mock('../../services/logger', () => {
|
|
|
37
52
|
info: (msg, meta) => spy(`[INFO] ${msg}`, meta),
|
|
38
53
|
verbose: (msg, meta) => spy(`[VERBOSE] ${msg}`, meta),
|
|
39
54
|
warn: (msg, meta) => spy(`[WARN] ${msg}`, meta),
|
|
55
|
+
error: (msg, meta) => spy(`[ERROR] ${msg}`, meta),
|
|
40
56
|
debug: (msg, meta) => spy(`[DEBUG] ${msg}`, meta),
|
|
41
57
|
},
|
|
42
58
|
};
|
|
@@ -3,7 +3,7 @@ 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.cherrypickAndCreateTargetPullRequest = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
9
|
const ora = require("ora");
|
|
@@ -62,8 +62,8 @@ async function cherrypickAndCreateTargetPullRequest({ options, commits, targetBr
|
|
|
62
62
|
// add labels to source pull requests
|
|
63
63
|
if (options.sourcePRLabels.length > 0) {
|
|
64
64
|
const promises = commits.map((commit) => {
|
|
65
|
-
if (commit.
|
|
66
|
-
return (0, addLabelsToPullRequest_1.addLabelsToPullRequest)(options, commit.
|
|
65
|
+
if (commit.sourcePullRequest) {
|
|
66
|
+
return (0, addLabelsToPullRequest_1.addLabelsToPullRequest)(options, commit.sourcePullRequest.number, options.sourcePRLabels);
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
await Promise.all(promises);
|
|
@@ -93,16 +93,15 @@ async function backportViaFilesystem({ options, prPayload, commits, targetBranch
|
|
|
93
93
|
*/
|
|
94
94
|
function getBackportBranchName(targetBranch, commits) {
|
|
95
95
|
const refValues = commits
|
|
96
|
-
.map((commit) => commit.
|
|
97
|
-
? `pr-${commit.
|
|
98
|
-
: `commit-${(0, commitFormatters_1.getShortSha)(commit.sha)}`)
|
|
96
|
+
.map((commit) => commit.sourcePullRequest
|
|
97
|
+
? `pr-${commit.sourcePullRequest.number}`
|
|
98
|
+
: `commit-${(0, commitFormatters_1.getShortSha)(commit.sourceCommit.sha)}`)
|
|
99
99
|
.join('_')
|
|
100
100
|
.slice(0, 200);
|
|
101
101
|
return `backport/${targetBranch}/${refValues}`;
|
|
102
102
|
}
|
|
103
|
-
exports.getBackportBranchName = getBackportBranchName;
|
|
104
103
|
async function waitForCherrypick(options, commit, targetBranch) {
|
|
105
|
-
const spinnerText = `Cherry-picking: ${chalk_1.default.greenBright((0, commitFormatters_1.getFirstLine)(commit.
|
|
104
|
+
const spinnerText = `Cherry-picking: ${chalk_1.default.greenBright((0, commitFormatters_1.getFirstLine)(commit.sourceCommit.message))}`;
|
|
106
105
|
const mergedTargetPullRequest = commit.expectedTargetPullRequests.find((pr) => pr.state === 'MERGED' && pr.branch === targetBranch);
|
|
107
106
|
const cherrypickSpinner = ora(spinnerText).start();
|
|
108
107
|
let conflictingFiles;
|
|
@@ -110,7 +109,7 @@ async function waitForCherrypick(options, commit, targetBranch) {
|
|
|
110
109
|
let needsResolving;
|
|
111
110
|
try {
|
|
112
111
|
await (0, git_1.fetchBranch)(options, commit.sourceBranch);
|
|
113
|
-
({ conflictingFiles, unstagedFiles, needsResolving } = await (0, git_1.cherrypick)(options, commit.sha, mergedTargetPullRequest));
|
|
112
|
+
({ conflictingFiles, unstagedFiles, needsResolving } = await (0, git_1.cherrypick)(options, commit.sourceCommit.sha, mergedTargetPullRequest));
|
|
114
113
|
// no conflicts encountered
|
|
115
114
|
if (!needsResolving) {
|
|
116
115
|
cherrypickSpinner.succeed();
|
|
@@ -147,8 +146,8 @@ async function waitForCherrypick(options, commit, targetBranch) {
|
|
|
147
146
|
conflictingFiles: conflictingFiles.map((f) => f.relative).slice(0, 50),
|
|
148
147
|
});
|
|
149
148
|
if (options.ci) {
|
|
150
|
-
throw new HandledError_1.HandledError(
|
|
151
|
-
|
|
149
|
+
throw new HandledError_1.HandledError({
|
|
150
|
+
code: 'merge-conflict-exception',
|
|
152
151
|
commitsWithoutBackports,
|
|
153
152
|
});
|
|
154
153
|
}
|
|
@@ -162,7 +161,7 @@ async function waitForCherrypick(options, commit, targetBranch) {
|
|
|
162
161
|
*/
|
|
163
162
|
if (options.editor) {
|
|
164
163
|
const repoPath = (0, env_1.getRepoPath)(options);
|
|
165
|
-
await (0, child_process_promisified_1.exec)(`${options.editor} ${repoPath}`, {});
|
|
164
|
+
await (0, child_process_promisified_1.exec)(`${options.editor} ${repoPath}`, { cwd: options.cwd });
|
|
166
165
|
}
|
|
167
166
|
// list files with conflict markers + unstaged files and require user to resolve them
|
|
168
167
|
await listConflictingAndUnstagedFiles({
|
|
@@ -208,7 +207,7 @@ ${unstagedSection}
|
|
|
208
207
|
|
|
209
208
|
Press ENTER when the conflicts are resolved and files are staged`);
|
|
210
209
|
if (!res) {
|
|
211
|
-
throw new HandledError_1.HandledError('
|
|
210
|
+
throw new HandledError_1.HandledError({ code: 'abort-exception' });
|
|
212
211
|
}
|
|
213
212
|
const MAX_RETRIES = 100;
|
|
214
213
|
if (retries++ > MAX_RETRIES) {
|
|
@@ -63,7 +63,6 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
63
63
|
assignees: [],
|
|
64
64
|
authenticatedUsername: 'sqren_authenticated',
|
|
65
65
|
fork: true,
|
|
66
|
-
prDescription: 'myPrSuffix',
|
|
67
66
|
prTitle: '[{targetBranch}] {commitMessages}',
|
|
68
67
|
repoName: 'kibana',
|
|
69
68
|
repoOwner: 'elastic',
|
|
@@ -75,19 +74,37 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
75
74
|
};
|
|
76
75
|
const commits = [
|
|
77
76
|
{
|
|
78
|
-
committedDate: 'fff',
|
|
79
77
|
sourceBranch: '7.x',
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
sourceCommit: {
|
|
79
|
+
committedDate: 'fff',
|
|
80
|
+
sha: 'mySha',
|
|
81
|
+
message: 'My original commit message (#1000)',
|
|
82
|
+
},
|
|
83
|
+
sourcePullRequest: {
|
|
84
|
+
url: 'foo',
|
|
85
|
+
number: 1000,
|
|
86
|
+
mergeCommit: {
|
|
87
|
+
sha: 'mySha',
|
|
88
|
+
message: 'My original commit message (#1000)',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
83
91
|
expectedTargetPullRequests: [],
|
|
84
92
|
},
|
|
85
93
|
{
|
|
86
|
-
committedDate: 'ggg',
|
|
87
94
|
sourceBranch: '7.x',
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
sourceCommit: {
|
|
96
|
+
committedDate: 'ggg',
|
|
97
|
+
sha: 'mySha2',
|
|
98
|
+
message: 'My other commit message (#2000)',
|
|
99
|
+
},
|
|
100
|
+
sourcePullRequest: {
|
|
101
|
+
url: 'foo',
|
|
102
|
+
number: 2000,
|
|
103
|
+
mergeCommit: {
|
|
104
|
+
sha: 'mySha2',
|
|
105
|
+
message: 'My other commit message (#2000)',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
91
108
|
expectedTargetPullRequests: [],
|
|
92
109
|
},
|
|
93
110
|
];
|
|
@@ -110,14 +127,14 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
110
127
|
"base": "6.x",
|
|
111
128
|
"body": "# Backport
|
|
112
129
|
|
|
113
|
-
This
|
|
114
|
-
- #1000
|
|
115
|
-
- #2000
|
|
130
|
+
This will backport the following commits from \`7.x\` to \`6.x\`:
|
|
131
|
+
- [My original commit message (#1000)](foo)
|
|
132
|
+
- [My other commit message (#2000)](foo)
|
|
116
133
|
|
|
117
|
-
|
|
118
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
134
|
+
<!--- Backport version: 1.2.3 -->
|
|
119
135
|
|
|
120
|
-
|
|
136
|
+
### Questions ?
|
|
137
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
121
138
|
"head": "sqren_authenticated:backport/6.x/pr-1000_pr-2000",
|
|
122
139
|
"title": "[6.x] My original commit message (#1000) | My other commit message (#2000)",
|
|
123
140
|
},
|
|
@@ -171,10 +188,12 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
171
188
|
};
|
|
172
189
|
const commits = [
|
|
173
190
|
{
|
|
174
|
-
|
|
191
|
+
sourceCommit: {
|
|
192
|
+
committedDate: 'hhh',
|
|
193
|
+
sha: 'mySha',
|
|
194
|
+
message: 'My original commit message',
|
|
195
|
+
},
|
|
175
196
|
sourceBranch: '7.x',
|
|
176
|
-
sha: 'mySha',
|
|
177
|
-
originalMessage: 'My original commit message',
|
|
178
197
|
expectedTargetPullRequests: [],
|
|
179
198
|
},
|
|
180
199
|
];
|
|
@@ -197,12 +216,13 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
197
216
|
"base": "6.x",
|
|
198
217
|
"body": "# Backport
|
|
199
218
|
|
|
200
|
-
This
|
|
219
|
+
This will backport the following commits from \`7.x\` to \`6.x\`:
|
|
201
220
|
- My original commit message (mySha)
|
|
202
221
|
|
|
222
|
+
<!--- Backport version: 1.2.3 -->
|
|
223
|
+
|
|
203
224
|
### Questions ?
|
|
204
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
205
|
-
",
|
|
225
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
206
226
|
"head": "sqren_authenticated:backport/6.x/commit-mySha",
|
|
207
227
|
"title": "[6.x] My original commit message",
|
|
208
228
|
},
|
|
@@ -251,10 +271,12 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
251
271
|
options,
|
|
252
272
|
commits: [
|
|
253
273
|
{
|
|
254
|
-
|
|
274
|
+
sourceCommit: {
|
|
275
|
+
committedDate: '2021-08-18T16:11:38Z',
|
|
276
|
+
sha: 'mySha',
|
|
277
|
+
message: 'My original commit message',
|
|
278
|
+
},
|
|
255
279
|
sourceBranch: '7.x',
|
|
256
|
-
sha: 'mySha',
|
|
257
|
-
originalMessage: 'My original commit message',
|
|
258
280
|
expectedTargetPullRequests: [],
|
|
259
281
|
},
|
|
260
282
|
],
|
|
@@ -270,12 +292,13 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
270
292
|
"base": "6.x",
|
|
271
293
|
"body": "# Backport
|
|
272
294
|
|
|
273
|
-
This
|
|
295
|
+
This will backport the following commits from \`7.x\` to \`6.x\`:
|
|
274
296
|
- My original commit message (mySha)
|
|
275
297
|
|
|
298
|
+
<!--- Backport version: 1.2.3 -->
|
|
299
|
+
|
|
276
300
|
### Questions ?
|
|
277
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
278
|
-
",
|
|
301
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
279
302
|
"head": "sqren_authenticated:backport/6.x/commit-mySha",
|
|
280
303
|
"title": "[6.x] My original commit message",
|
|
281
304
|
},
|
package/dist/ui/getCommits.js
CHANGED
|
@@ -25,7 +25,7 @@ async function getCommits(options) {
|
|
|
25
25
|
if (options.sha) {
|
|
26
26
|
spinner.text = `Loading commit "${(0, commitFormatters_1.getShortSha)(options.sha)}"`;
|
|
27
27
|
const commit = await (0, fetchCommitBySha_1.fetchCommitBySha)({ ...options, sha: options.sha });
|
|
28
|
-
spinner.stopAndPersist(getOraPersistsOption('Select commit', commit.
|
|
28
|
+
spinner.stopAndPersist(getOraPersistsOption('Select commit', commit.sourceCommit.message));
|
|
29
29
|
return [commit];
|
|
30
30
|
}
|
|
31
31
|
if (options.pullNumber) {
|
|
@@ -35,24 +35,18 @@ async function getCommits(options) {
|
|
|
35
35
|
pullNumber: options.pullNumber, // must extract pullNumber to satisfy the ts gods
|
|
36
36
|
});
|
|
37
37
|
// add styles to make it look like a prompt question
|
|
38
|
-
spinner.stopAndPersist(getOraPersistsOption('Select pull request', (0, commitFormatters_1.getFirstLine)(commit.
|
|
38
|
+
spinner.stopAndPersist(getOraPersistsOption('Select pull request', (0, commitFormatters_1.getFirstLine)(commit.sourceCommit.message)));
|
|
39
39
|
return [commit];
|
|
40
40
|
}
|
|
41
41
|
if (options.ci) {
|
|
42
42
|
throw new HandledError_1.HandledError('When "--ci" flag is enabled either `--sha` or `--pr` must be specified');
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
isMultipleChoice: options.multipleCommits,
|
|
51
|
-
showDetails: options.details,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
spinner.text = `Loading commits from branch "${options.sourceBranch}"...`;
|
|
55
|
-
const commitChoices = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)(options);
|
|
44
|
+
spinner.text = options.prFilter
|
|
45
|
+
? 'Loading pull requests...'
|
|
46
|
+
: `Loading commits from branch "${options.sourceBranch}"...`;
|
|
47
|
+
const commitChoices = options.prFilter
|
|
48
|
+
? await (0, fetchPullRequestBySearchQuery_1.fetchPullRequestBySearchQuery)(options)
|
|
49
|
+
: await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)(options);
|
|
56
50
|
spinner.stop();
|
|
57
51
|
return (0, prompts_1.promptForCommits)({
|
|
58
52
|
commitChoices,
|
|
@@ -22,21 +22,21 @@ conflictingFiles, }) {
|
|
|
22
22
|
...options,
|
|
23
23
|
author: null,
|
|
24
24
|
dateSince: null,
|
|
25
|
-
dateUntil: commit.committedDate,
|
|
25
|
+
dateUntil: commit.sourceCommit.committedDate,
|
|
26
26
|
commitPaths: conflictingFiles,
|
|
27
27
|
});
|
|
28
28
|
const promises = await Promise.all(commitsInConflictingPaths
|
|
29
29
|
.filter((c) => {
|
|
30
30
|
// exclude the commit we are currently trying to backport
|
|
31
|
-
if (c.sha === commit.sha) {
|
|
31
|
+
if (c.sourceCommit.sha === commit.sourceCommit.sha) {
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
// exclude commits that are newer than the commit we are trying to backport
|
|
35
|
-
if (c.committedDate > commit.committedDate) {
|
|
35
|
+
if (c.sourceCommit.committedDate > commit.sourceCommit.committedDate) {
|
|
36
36
|
return false;
|
|
37
37
|
}
|
|
38
38
|
// only consider commits that have an associated pull request
|
|
39
|
-
if (!c.
|
|
39
|
+
if (!c.sourcePullRequest?.url) {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
42
|
// only include commit if it has an unmerged PR for the given target branch
|
|
@@ -60,8 +60,8 @@ conflictingFiles, }) {
|
|
|
60
60
|
// get pull request for the target branch (if it exists)
|
|
61
61
|
const pendingBackportPr = c.expectedTargetPullRequests.find((pr) => pr.branch === targetBranch && pr.state === 'OPEN');
|
|
62
62
|
const formatted = pendingBackportPr
|
|
63
|
-
? ` - ${(0, commitFormatters_1.getFirstLine)(c.
|
|
64
|
-
: ` - ${(0, commitFormatters_1.getFirstLine)(c.
|
|
63
|
+
? ` - ${(0, commitFormatters_1.getFirstLine)(c.sourceCommit.message)} ${chalk_1.default.gray('(backport pending)')}\n ${pendingBackportPr.url}`
|
|
64
|
+
: ` - ${(0, commitFormatters_1.getFirstLine)(c.sourceCommit.message)} ${chalk_1.default.red('(backport missing)')}\n ${c.sourcePullRequest?.url}`;
|
|
65
65
|
return { formatted, commit: c };
|
|
66
66
|
});
|
|
67
67
|
}
|