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
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const child_process_promisified_1 = require("../../../
|
|
3
|
+
const child_process_promisified_1 = require("../../../lib/child-process-promisified");
|
|
4
4
|
const getDevAccessToken_1 = require("../../private/getDevAccessToken");
|
|
5
5
|
const sandbox_1 = require("../../sandbox");
|
|
6
6
|
const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
7
7
|
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
8
8
|
describe('different-merge-strategies', () => {
|
|
9
9
|
it('list all commits regardless how they were merged', async () => {
|
|
10
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
11
|
-
'--branch=
|
|
10
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
11
|
+
'--branch=7.x',
|
|
12
12
|
'--repo=backport-org/different-merge-strategies',
|
|
13
13
|
`--accessToken=${accessToken}`,
|
|
14
14
|
'-n=20',
|
|
15
|
-
], { waitForString: 'Select commit' });
|
|
15
|
+
], { waitForString: 'Select commit', timeoutSeconds: 4 });
|
|
16
16
|
expect(output).toMatchInlineSnapshot(`
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
"? Select commit (Use arrow keys)
|
|
18
|
+
❯ 1. Merge pull request #9 from backport-org/many-merge-commits
|
|
19
|
+
2. Merge strategy: Eighth of many merges
|
|
20
|
+
3. Merge strategy: Seventh of many merges
|
|
21
|
+
4. Merge strategy: Sixth of many merges
|
|
22
|
+
5. Merge strategy: Fifth of many merges
|
|
23
|
+
6. Merge strategy: Fourth of many merges
|
|
24
|
+
7. Merge strategy: Third of many merges
|
|
25
|
+
8. Merge strategy: Second of many merges
|
|
26
|
+
9. Merge strategy: First of many merges
|
|
27
|
+
10.Using squash to merge commits (#3) 7.x
|
|
28
|
+
11.Rebase strategy: Second commit 7.x
|
|
29
|
+
12.Rebase strategy: First commit
|
|
30
|
+
13.Merge pull request #1 from backport-org/merge-strategy
|
|
31
|
+
14.Merge strategy: Second commit
|
|
32
|
+
15.Merge strategy: First commit
|
|
33
|
+
16.Initial commit"
|
|
34
|
+
`);
|
|
35
35
|
});
|
|
36
36
|
describe('when selecting a merge commit', () => {
|
|
37
37
|
let output;
|
|
@@ -39,20 +39,22 @@ describe('different-merge-strategies', () => {
|
|
|
39
39
|
beforeAll(async () => {
|
|
40
40
|
sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
41
41
|
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
42
|
-
|
|
42
|
+
const res = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
43
43
|
'--branch=7.x',
|
|
44
44
|
'--repo=backport-org/different-merge-strategies',
|
|
45
45
|
`--accessToken=${accessToken}`,
|
|
46
46
|
`--dir=${sandboxPath}`,
|
|
47
47
|
'--pr=9',
|
|
48
48
|
'--dry-run',
|
|
49
|
-
], {
|
|
49
|
+
], { showOra: true });
|
|
50
|
+
output = res.output;
|
|
50
51
|
});
|
|
51
52
|
it('runs to completion without errors', () => {
|
|
52
53
|
expect(output).toMatchInlineSnapshot(`
|
|
53
54
|
"- Initializing...
|
|
54
55
|
? Select pull request Merge pull request #9 from backport-org/many-merge-commits
|
|
55
56
|
✔ 100% Cloning repository from github.com (one-time operation)
|
|
57
|
+
|
|
56
58
|
Backporting to 7.x:
|
|
57
59
|
- Pulling latest changes
|
|
58
60
|
✔ Pulling latest changes
|
|
@@ -88,7 +90,7 @@ describe('different-merge-strategies', () => {
|
|
|
88
90
|
`--dir=${sandboxPath}`,
|
|
89
91
|
'--pr=1',
|
|
90
92
|
'--dry-run',
|
|
91
|
-
], {
|
|
93
|
+
], { showOra: true });
|
|
92
94
|
});
|
|
93
95
|
it('backports all immediate children of the merge commit', async () => {
|
|
94
96
|
const commits = await listCommits(sandboxPath);
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -19,35 +23,35 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
23
|
return result;
|
|
20
24
|
};
|
|
21
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const child_process_promisified_1 = require("../../../
|
|
26
|
+
const child_process_promisified_1 = require("../../../lib/child-process-promisified");
|
|
23
27
|
const packageVersion = __importStar(require("../../../utils/packageVersion"));
|
|
24
28
|
const getDevAccessToken_1 = require("../../private/getDevAccessToken");
|
|
25
29
|
const sandbox_1 = require("../../sandbox");
|
|
26
30
|
const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
27
|
-
|
|
28
|
-
jest.setTimeout(TIMEOUT_IN_SECONDS * 1000);
|
|
31
|
+
jest.setTimeout(10000);
|
|
29
32
|
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
30
33
|
describe('entrypoint cli', () => {
|
|
31
34
|
it('--version', async () => {
|
|
32
|
-
const
|
|
35
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([`--version`], {
|
|
33
36
|
showOra: true,
|
|
34
37
|
});
|
|
35
|
-
expect(
|
|
38
|
+
expect(output).toEqual(process.env.npm_package_version);
|
|
36
39
|
});
|
|
37
40
|
it('-v', async () => {
|
|
38
|
-
const
|
|
41
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([`-v`], {
|
|
39
42
|
showOra: true,
|
|
40
43
|
});
|
|
41
|
-
expect(
|
|
44
|
+
expect(output).toEqual(process.env.npm_package_version);
|
|
42
45
|
});
|
|
43
46
|
it('PACKAGE_VERSION should match', async () => {
|
|
44
47
|
// @ts-expect-error
|
|
45
48
|
expect(packageVersion.UNMOCKED_PACKAGE_VERSION).toBe(process.env.npm_package_version);
|
|
46
49
|
});
|
|
47
50
|
it('--help', async () => {
|
|
48
|
-
const
|
|
49
|
-
expect(
|
|
51
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([`--help`]);
|
|
52
|
+
expect(output).toMatchInlineSnapshot(`
|
|
50
53
|
"entrypoint.cli.ts [args]
|
|
54
|
+
|
|
51
55
|
Options:
|
|
52
56
|
-v, --version Show version number [boolean]
|
|
53
57
|
--accessToken, --accesstoken Github access token [string]
|
|
@@ -57,14 +61,13 @@ describe('entrypoint cli', () => {
|
|
|
57
61
|
--autoMerge Enable auto-merge for created pull requests [boolean]
|
|
58
62
|
--autoMergeMethod Sets auto-merge method when using --auto-merge. Default:
|
|
59
63
|
merge [string] [choices: \\"merge\\", \\"rebase\\", \\"squash\\"]
|
|
60
|
-
--ci Disable interactive prompts [boolean]
|
|
61
64
|
--cherrypickRef Append commit message with \\"(cherry picked from commit...)
|
|
62
65
|
[boolean]
|
|
63
66
|
--projectConfigFile, --config Path to project config [string]
|
|
67
|
+
--globalConfigFile Path to global config [string]
|
|
64
68
|
--since ISO-8601 date for filtering commits [string]
|
|
65
69
|
--until ISO-8601 date for filtering commits [string]
|
|
66
|
-
--dir
|
|
67
|
-
[string]
|
|
70
|
+
--dir Path to temporary backport repo [string]
|
|
68
71
|
--details Show details about each commit [boolean]
|
|
69
72
|
--dryRun Run backport locally without pushing to Github [boolean]
|
|
70
73
|
--editor Editor to be opened during conflict resolution [string]
|
|
@@ -74,6 +77,8 @@ describe('entrypoint cli', () => {
|
|
|
74
77
|
[boolean]
|
|
75
78
|
--gitAuthorName Set commit author name [string]
|
|
76
79
|
--gitAuthorEmail Set commit author email [string]
|
|
80
|
+
--nonInteractive, --json Disable interactive prompts and return response as JSON
|
|
81
|
+
[boolean]
|
|
77
82
|
--ls List commits instead of backporting them [boolean]
|
|
78
83
|
--mainline Parent id of merge commit. Defaults to 1 when supplied
|
|
79
84
|
without arguments [number]
|
|
@@ -108,64 +113,37 @@ describe('entrypoint cli', () => {
|
|
|
108
113
|
-l, --targetPRLabel, --label Add labels to the target (backport) PR [array]
|
|
109
114
|
--verify Opposite of no-verify [boolean]
|
|
110
115
|
--help Show help [boolean]
|
|
116
|
+
|
|
111
117
|
For bugs, feature requests or questions: https://github.com/sqren/backport/issues
|
|
112
118
|
Or contact me directly: https://twitter.com/sorenlouv"
|
|
113
119
|
`);
|
|
114
120
|
});
|
|
115
|
-
it('
|
|
116
|
-
const res = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
117
|
-
'--skip-remote-config',
|
|
118
|
-
'--repo=backport-org/backport-e2e',
|
|
119
|
-
`--accessToken=${accessToken}`,
|
|
120
|
-
]);
|
|
121
|
-
expect(res).toMatchInlineSnapshot(`
|
|
122
|
-
"Please specify a target branch: \\"--branch 6.1\\".
|
|
123
|
-
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
124
|
-
`);
|
|
125
|
-
});
|
|
126
|
-
it('should list commits based on .git/config when `repoOwner`/`repoName` is missing', async () => {
|
|
121
|
+
it('lists commits based on .git/config when `repoOwner`/`repoName` is missing', async () => {
|
|
127
122
|
const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
128
123
|
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
129
124
|
await (0, child_process_promisified_1.exec)(`git init`, { cwd: sandboxPath });
|
|
130
125
|
await (0, child_process_promisified_1.exec)(`git remote add origin git@github.com:backport-org/backport-e2e.git`, { cwd: sandboxPath });
|
|
131
|
-
const
|
|
126
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([`--accessToken=${accessToken}`], {
|
|
132
127
|
cwd: sandboxPath,
|
|
133
128
|
waitForString: 'Select commit',
|
|
134
129
|
});
|
|
135
|
-
expect(
|
|
130
|
+
expect(output).toMatchInlineSnapshot(`
|
|
136
131
|
"? Select commit (Use arrow keys)
|
|
137
|
-
❯ 1. Add sheep emoji (#9) 7.8
|
|
138
|
-
2. Change Ulysses to Gretha (conflict) (#8) 7.x
|
|
139
|
-
3. Add 🍏 emoji (#5) 7.x, 7.8
|
|
140
|
-
4. Add family emoji (#2) 7.x
|
|
141
|
-
5. Add \`backport\` dep
|
|
142
|
-
6. Merge pull request #1 from backport-org/add-heart-emoji
|
|
143
|
-
7. Add ❤️ emoji
|
|
144
|
-
8. Update .backportrc.json
|
|
145
|
-
9. Bump to 8.0.0
|
|
132
|
+
❯ 1. Add sheep emoji (#9) 7.8
|
|
133
|
+
2. Change Ulysses to Gretha (conflict) (#8) 7.x
|
|
134
|
+
3. Add 🍏 emoji (#5) 7.x, 7.8
|
|
135
|
+
4. Add family emoji (#2) 7.x
|
|
136
|
+
5. Add \`backport\` dep
|
|
137
|
+
6. Merge pull request #1 from backport-org/add-heart-emoji
|
|
138
|
+
7. Add ❤️ emoji
|
|
139
|
+
8. Update .backportrc.json
|
|
140
|
+
9. Bump to 8.0.0
|
|
146
141
|
10.Add package.json"
|
|
147
142
|
`);
|
|
148
143
|
});
|
|
149
|
-
it(
|
|
150
|
-
const
|
|
151
|
-
'--branch=
|
|
152
|
-
'--repo=foo/bar',
|
|
153
|
-
'--accessToken=some-token',
|
|
154
|
-
]);
|
|
155
|
-
expect(res).toContain('Please check your access token and make sure it is valid');
|
|
156
|
-
});
|
|
157
|
-
it(`should return error when repo doesn't exist`, async () => {
|
|
158
|
-
const res = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
159
|
-
'--branch=foo',
|
|
160
|
-
'--repo=foo/bar',
|
|
161
|
-
'--author=sqren',
|
|
162
|
-
`--accessToken=${accessToken}`,
|
|
163
|
-
]);
|
|
164
|
-
expect(res).toMatchInlineSnapshot(`"The repository \\"foo/bar\\" doesn't exist"`);
|
|
165
|
-
});
|
|
166
|
-
it(`should list commits from master`, async () => {
|
|
167
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
168
|
-
'--branch=foo',
|
|
144
|
+
it(`lists commits from master`, async () => {
|
|
145
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
146
|
+
'--branch=7.x',
|
|
169
147
|
'--repo=backport-org/backport-e2e',
|
|
170
148
|
'--author=sqren',
|
|
171
149
|
`--accessToken=${accessToken}`,
|
|
@@ -173,17 +151,17 @@ describe('entrypoint cli', () => {
|
|
|
173
151
|
], { waitForString: 'Select commit' });
|
|
174
152
|
expect(output).toMatchInlineSnapshot(`
|
|
175
153
|
"? Select commit (Use arrow keys)
|
|
176
|
-
❯ 1. Add sheep emoji (#9) 7.8
|
|
177
|
-
2. Change Ulysses to Gretha (conflict) (#8) 7.x
|
|
178
|
-
3. Add 🍏 emoji (#5) 7.x, 7.8
|
|
179
|
-
4. Add family emoji (#2) 7.x
|
|
180
|
-
5. Add \`backport\` dep
|
|
154
|
+
❯ 1. Add sheep emoji (#9) 7.8
|
|
155
|
+
2. Change Ulysses to Gretha (conflict) (#8) 7.x
|
|
156
|
+
3. Add 🍏 emoji (#5) 7.x, 7.8
|
|
157
|
+
4. Add family emoji (#2) 7.x
|
|
158
|
+
5. Add \`backport\` dep
|
|
181
159
|
6. Merge pull request #1 from backport-org/add-heart-emoji"
|
|
182
160
|
`);
|
|
183
161
|
});
|
|
184
|
-
it(`
|
|
185
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
186
|
-
'--branch=
|
|
162
|
+
it(`filters commits by "since" and "until"`, async () => {
|
|
163
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
164
|
+
'--branch=7.x',
|
|
187
165
|
'--repo=backport-org/backport-e2e',
|
|
188
166
|
`--accessToken=${accessToken}`,
|
|
189
167
|
'--since=2020-08-15T10:00:00.000Z',
|
|
@@ -191,15 +169,15 @@ describe('entrypoint cli', () => {
|
|
|
191
169
|
], { waitForString: 'Select commit' });
|
|
192
170
|
expect(output).toMatchInlineSnapshot(`
|
|
193
171
|
"? Select commit (Use arrow keys)
|
|
194
|
-
❯ 1. Bump to 8.0.0
|
|
195
|
-
2. Add package.json
|
|
196
|
-
3. Update .backportrc.json
|
|
172
|
+
❯ 1. Bump to 8.0.0
|
|
173
|
+
2. Add package.json
|
|
174
|
+
3. Update .backportrc.json
|
|
197
175
|
4. Create .backportrc.json"
|
|
198
176
|
`);
|
|
199
177
|
});
|
|
200
|
-
it(`
|
|
201
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
202
|
-
'--branch=
|
|
178
|
+
it(`lists commits from 7.x`, async () => {
|
|
179
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
180
|
+
'--branch=7.x',
|
|
203
181
|
'--repo=backport-org/backport-e2e',
|
|
204
182
|
'--author=sqren',
|
|
205
183
|
`--accessToken=${accessToken}`,
|
|
@@ -208,11 +186,11 @@ describe('entrypoint cli', () => {
|
|
|
208
186
|
], { waitForString: 'Select commit' });
|
|
209
187
|
expect(output).toMatchInlineSnapshot(`
|
|
210
188
|
"? Select commit (Use arrow keys)
|
|
211
|
-
❯ 1. Add 🍏 emoji (#5) (#6)
|
|
212
|
-
2. Change Ulysses to Carol
|
|
213
|
-
3. Add family emoji (#2) (#4)
|
|
214
|
-
4. Update .backportrc.json
|
|
215
|
-
5. Branch off: 7.9.0 (7.x)
|
|
189
|
+
❯ 1. Add 🍏 emoji (#5) (#6)
|
|
190
|
+
2. Change Ulysses to Carol
|
|
191
|
+
3. Add family emoji (#2) (#4)
|
|
192
|
+
4. Update .backportrc.json
|
|
193
|
+
5. Branch off: 7.9.0 (7.x)
|
|
216
194
|
6. Bump to 8.0.0"
|
|
217
195
|
`);
|
|
218
196
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getDevAccessToken_1 = require("../../private/getDevAccessToken");
|
|
4
|
+
const sandbox_1 = require("../../sandbox");
|
|
5
|
+
const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
6
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
7
|
+
describe('interactive error handling', () => {
|
|
8
|
+
it('when branch is missing', async () => {
|
|
9
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
10
|
+
'--skip-remote-config',
|
|
11
|
+
'--repo=backport-org/backport-e2e',
|
|
12
|
+
`--accessToken=${accessToken}`,
|
|
13
|
+
]);
|
|
14
|
+
expect(output).toMatchInlineSnapshot(`
|
|
15
|
+
"Please specify a target branch: \\"--branch 6.1\\".
|
|
16
|
+
|
|
17
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
18
|
+
`);
|
|
19
|
+
});
|
|
20
|
+
it('when supplying invalid argument', async () => {
|
|
21
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([`--foo`]);
|
|
22
|
+
expect(output).toMatchInlineSnapshot(`
|
|
23
|
+
"Unknown argument: foo
|
|
24
|
+
Run \\"backport --help\\" to see all options"
|
|
25
|
+
`);
|
|
26
|
+
});
|
|
27
|
+
it('when access token is invalid', async () => {
|
|
28
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
29
|
+
'--branch=foo',
|
|
30
|
+
'--repo=foo/bar',
|
|
31
|
+
'--accessToken=some-token',
|
|
32
|
+
]);
|
|
33
|
+
expect(output).toContain('Please check your access token and make sure it is valid');
|
|
34
|
+
});
|
|
35
|
+
it(`when repo doesn't exist`, async () => {
|
|
36
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
37
|
+
'--branch=foo',
|
|
38
|
+
'--repo=foo/bar',
|
|
39
|
+
'--author=sqren',
|
|
40
|
+
`--accessToken=${accessToken}`,
|
|
41
|
+
]);
|
|
42
|
+
expect(output).toMatchInlineSnapshot(`"The repository \\"foo/bar\\" doesn't exist"`);
|
|
43
|
+
});
|
|
44
|
+
it(`when given branch is invalid`, async () => {
|
|
45
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
46
|
+
'--branch=foo',
|
|
47
|
+
'--repo=backport-org/backport-e2e',
|
|
48
|
+
'--pr=9',
|
|
49
|
+
`--accessToken=${accessToken}`,
|
|
50
|
+
]);
|
|
51
|
+
expect(output).toMatchInlineSnapshot(`"The branch \\"foo\\" does not exist"`);
|
|
52
|
+
});
|
|
53
|
+
it(`when encountering conflicts`, async () => {
|
|
54
|
+
const backportDir = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
55
|
+
await (0, sandbox_1.resetSandbox)(backportDir);
|
|
56
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
57
|
+
'--repo=backport-org/repo-with-conflicts',
|
|
58
|
+
'--pr=12',
|
|
59
|
+
'--branch=7.x',
|
|
60
|
+
`--accessToken=${accessToken}`,
|
|
61
|
+
`--dir=${backportDir}`,
|
|
62
|
+
'--dry-run',
|
|
63
|
+
], {
|
|
64
|
+
waitForString: 'Press ENTER when the conflicts',
|
|
65
|
+
timeoutSeconds: 5,
|
|
66
|
+
});
|
|
67
|
+
// //@ts-expect-error
|
|
68
|
+
// const lineToReplace = output.match(
|
|
69
|
+
// /Conflicting files:[\s]+- (.*[\s].*)la-liga.md/
|
|
70
|
+
// )[1];
|
|
71
|
+
// const lineWithoutBreaks = lineToReplace.replace(/\s/g, '');
|
|
72
|
+
// const outputReplaced = output
|
|
73
|
+
// .replace(lineToReplace, lineWithoutBreaks)
|
|
74
|
+
// .replaceAll(backportDir, '<BACKPORT_DIR>');
|
|
75
|
+
const outputReplaced = output
|
|
76
|
+
.replaceAll('\n', '')
|
|
77
|
+
.replaceAll(backportDir, '<BACKPORT_DIR>');
|
|
78
|
+
expect(outputReplaced).toMatchInlineSnapshot(`"Backporting to 7.x:The commit could not be backported due to conflictsPlease fix the conflicts in <BACKPORT_DIR>Hint: Before fixing the conflicts manually you should consider backporting the following pull requests to \\"7.x\\": - Change Barca to Braithwaite (#8) (backport missing) https://github.com/backport-org/repo-with-conflicts/pull/8? Fix the following conflicts manually:Conflicting files: - <BACKPORT_DIR>/la-liga.mdPress ENTER when the conflicts are resolved and files are staged (Y/n)"`);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,199 @@
|
|
|
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 promises_1 = __importDefault(require("fs/promises"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const getDevAccessToken_1 = require("../../private/getDevAccessToken");
|
|
9
|
+
const sandbox_1 = require("../../sandbox");
|
|
10
|
+
const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
11
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
12
|
+
describe('non interactive (json) error handling', () => {
|
|
13
|
+
it(`when access token is missing`, async () => {
|
|
14
|
+
const configFilePath = await createConfigFile({ editor: 'code' });
|
|
15
|
+
const { output, code } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
16
|
+
'--json',
|
|
17
|
+
`--globalConfigFile=${configFilePath}`,
|
|
18
|
+
]);
|
|
19
|
+
const backportResult = JSON.parse(output);
|
|
20
|
+
// remove absolute path to avoid issues on ci
|
|
21
|
+
const errorMessage = backportResult.errorMessage.replace(configFilePath, '<GLOBAL_CONFIG_FILE>');
|
|
22
|
+
expect(code).toBe(1);
|
|
23
|
+
expect(backportResult.status).toBe('failure');
|
|
24
|
+
expect(errorMessage).toMatchInlineSnapshot(`
|
|
25
|
+
"Please update your config file: \\"<GLOBAL_CONFIG_FILE>\\".
|
|
26
|
+
It must contain a valid \\"accessToken\\".
|
|
27
|
+
|
|
28
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
|
|
29
|
+
`);
|
|
30
|
+
});
|
|
31
|
+
it('when target branches cannot be inferred from pull request', async () => {
|
|
32
|
+
const { output, code } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
33
|
+
'--json',
|
|
34
|
+
'--repo=backport-org/backport-e2e',
|
|
35
|
+
'--pr=9',
|
|
36
|
+
`--accessToken=${accessToken}`,
|
|
37
|
+
]);
|
|
38
|
+
expect(code).toBe(0);
|
|
39
|
+
const backportResult = JSON.parse(output);
|
|
40
|
+
expect(backportResult.status).toBe('aborted');
|
|
41
|
+
expect(backportResult.error).toEqual({
|
|
42
|
+
errorContext: { code: 'no-branches-exception' },
|
|
43
|
+
name: 'BackportError',
|
|
44
|
+
});
|
|
45
|
+
expect(backportResult.errorMessage).toBe('There are no branches to backport to. Aborting.');
|
|
46
|
+
});
|
|
47
|
+
it(`when target branch and branch label mapping are missing`, async () => {
|
|
48
|
+
const { output, code } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
49
|
+
'--json',
|
|
50
|
+
`--access-token=${accessToken}`,
|
|
51
|
+
]);
|
|
52
|
+
expect(code).toBe(1);
|
|
53
|
+
const backportResult = JSON.parse(output);
|
|
54
|
+
expect(backportResult.status).toBe('failure');
|
|
55
|
+
expect(backportResult.errorMessage).toMatchInlineSnapshot(`
|
|
56
|
+
"Please specify a target branch: \\"--branch 6.1\\".
|
|
57
|
+
|
|
58
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
59
|
+
`);
|
|
60
|
+
});
|
|
61
|
+
it(`when argument is invalid`, async () => {
|
|
62
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)(['--json', '--foo'], {});
|
|
63
|
+
const backportResult = JSON.parse(output);
|
|
64
|
+
expect(backportResult.status).toBe('failure');
|
|
65
|
+
expect(backportResult.errorMessage).toEqual('Unknown argument: foo');
|
|
66
|
+
});
|
|
67
|
+
it('when `--repo` is invalid', async () => {
|
|
68
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
69
|
+
'--json',
|
|
70
|
+
'--repo=backport-org/backport-e2e-foo',
|
|
71
|
+
`--accessToken=${accessToken}`,
|
|
72
|
+
]);
|
|
73
|
+
const backportResult = JSON.parse(output);
|
|
74
|
+
expect(backportResult.status).toBe('failure');
|
|
75
|
+
expect(backportResult.errorMessage).toEqual('The repository "backport-org/backport-e2e-foo" doesn\'t exist');
|
|
76
|
+
});
|
|
77
|
+
it('when `--sha` is invalid', async () => {
|
|
78
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
79
|
+
'--json',
|
|
80
|
+
'--repo=backport-org/backport-e2e',
|
|
81
|
+
'--sha=abcdefg',
|
|
82
|
+
`--accessToken=${accessToken}`,
|
|
83
|
+
]);
|
|
84
|
+
const backportResult = JSON.parse(output);
|
|
85
|
+
expect(backportResult.status).toBe('failure');
|
|
86
|
+
expect(backportResult.errorMessage).toEqual('No commit found on branch "master" with sha "abcdefg"');
|
|
87
|
+
});
|
|
88
|
+
it('when `--branch` is invalid', async () => {
|
|
89
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
90
|
+
'--json',
|
|
91
|
+
'--repo=backport-org/backport-e2e',
|
|
92
|
+
'--pr=9',
|
|
93
|
+
'--branch=foobar',
|
|
94
|
+
`--accessToken=${accessToken}`,
|
|
95
|
+
]);
|
|
96
|
+
const backportResult = JSON.parse(output);
|
|
97
|
+
expect(backportResult.status).toBe('failure');
|
|
98
|
+
expect(backportResult.error).toEqual({
|
|
99
|
+
name: 'BackportError',
|
|
100
|
+
errorContext: {
|
|
101
|
+
code: 'message-only-exception',
|
|
102
|
+
message: 'The branch "foobar" does not exist',
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
it('when `--branch` tries to inject argument', async () => {
|
|
107
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
108
|
+
'--json',
|
|
109
|
+
'--repo=backport-org/backport-e2e',
|
|
110
|
+
'--pr=9',
|
|
111
|
+
'--branch=--foo bar',
|
|
112
|
+
`--accessToken=${accessToken}`,
|
|
113
|
+
]);
|
|
114
|
+
const backportResult = JSON.parse(output);
|
|
115
|
+
expect(backportResult.status).toBe('failure');
|
|
116
|
+
expect(backportResult.error).toEqual({
|
|
117
|
+
name: 'BackportError',
|
|
118
|
+
errorContext: {
|
|
119
|
+
code: 'message-only-exception',
|
|
120
|
+
message: 'The branch "--foo bar" does not exist',
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
it('when `--pr` is invalid', async () => {
|
|
125
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
126
|
+
'--json',
|
|
127
|
+
'--repo=backport-org/backport-e2e',
|
|
128
|
+
'--pr=900',
|
|
129
|
+
'--branch=7.x',
|
|
130
|
+
`--accessToken=${accessToken}`,
|
|
131
|
+
]);
|
|
132
|
+
const backportResult = JSON.parse(output);
|
|
133
|
+
expect(backportResult.status).toEqual('failure');
|
|
134
|
+
expect(backportResult.errorMessage).toEqual('Could not resolve to a PullRequest with the number of 900. (Github API v4)');
|
|
135
|
+
});
|
|
136
|
+
it('when encountering conflicts', async () => {
|
|
137
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
138
|
+
'--json',
|
|
139
|
+
'--repo=backport-org/repo-with-conflicts',
|
|
140
|
+
'--pr=12',
|
|
141
|
+
'--branch=7.x',
|
|
142
|
+
`--accessToken=${accessToken}`,
|
|
143
|
+
]);
|
|
144
|
+
const backportResult = JSON.parse(output);
|
|
145
|
+
expect(backportResult.status).toEqual('success');
|
|
146
|
+
expect(
|
|
147
|
+
//@ts-expect-error
|
|
148
|
+
backportResult.results[0].error.errorContext.conflictingFiles).toEqual(['la-liga.md']);
|
|
149
|
+
});
|
|
150
|
+
it('when `--source-branch` is invalid', async () => {
|
|
151
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
152
|
+
'--json',
|
|
153
|
+
'--repo=backport-org/backport-e2e',
|
|
154
|
+
'--pr=9',
|
|
155
|
+
'--branch=7.x',
|
|
156
|
+
'--source-branch=foo',
|
|
157
|
+
`--accessToken=${accessToken}`,
|
|
158
|
+
]);
|
|
159
|
+
const backportResult = JSON.parse(output);
|
|
160
|
+
expect(backportResult.status).toBe('success');
|
|
161
|
+
expect(backportResult.results[0]).toEqual({
|
|
162
|
+
error: {
|
|
163
|
+
context: {
|
|
164
|
+
cmdArgs: ['checkout', 'foo'],
|
|
165
|
+
code: 1,
|
|
166
|
+
stderr: "error: pathspec 'foo' did not match any file(s) known to git\n",
|
|
167
|
+
stdout: '',
|
|
168
|
+
},
|
|
169
|
+
name: 'SpawnError',
|
|
170
|
+
},
|
|
171
|
+
status: 'unhandled-error',
|
|
172
|
+
targetBranch: '7.x',
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
it('when attempting to backport unmerged PR', async () => {
|
|
176
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
177
|
+
'--json',
|
|
178
|
+
'--repo=backport-org/backport-e2e',
|
|
179
|
+
'--pr=12',
|
|
180
|
+
`--accessToken=${accessToken}`,
|
|
181
|
+
]);
|
|
182
|
+
const backportResult = JSON.parse(output);
|
|
183
|
+
expect(backportResult.status).toBe('failure');
|
|
184
|
+
expect(backportResult.error).toEqual({
|
|
185
|
+
errorContext: {
|
|
186
|
+
code: 'message-only-exception',
|
|
187
|
+
message: 'The PR #12 is not merged',
|
|
188
|
+
},
|
|
189
|
+
name: 'BackportError',
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
async function createConfigFile(options) {
|
|
194
|
+
const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
195
|
+
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
196
|
+
const configPath = path_1.default.join(sandboxPath, 'config.json');
|
|
197
|
+
await promises_1.default.writeFile(configPath, JSON.stringify(options));
|
|
198
|
+
return configPath;
|
|
199
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|