backport 8.0.0 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/backportRun.d.ts +5 -4
- package/dist/backportRun.js +41 -42
- package/dist/entrypoint.cli.js +3 -7
- package/dist/entrypoint.module.d.ts +7 -5
- package/dist/entrypoint.module.js +11 -9
- package/dist/entrypoint.module.private.test.js +4 -4
- package/dist/errors/BackportError.d.ts +19 -0
- package/dist/errors/BackportError.js +29 -0
- package/dist/lib/BackportError.d.ts +19 -0
- package/dist/lib/BackportError.js +29 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.d.ts +13 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.js +238 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.test.js +321 -0
- package/dist/lib/child-process-promisified.d.ts +25 -0
- package/dist/lib/child-process-promisified.js +58 -0
- package/dist/lib/env.d.ts +7 -0
- package/dist/lib/env.js +33 -0
- package/dist/lib/env.test.d.ts +1 -0
- package/dist/lib/env.test.js +26 -0
- package/dist/lib/getCommits.d.ts +2 -0
- package/dist/lib/getCommits.js +75 -0
- package/dist/lib/getCommitsWithoutBackports.d.ts +11 -0
- package/dist/lib/getCommitsWithoutBackports.js +68 -0
- package/dist/lib/getCommitsWithoutBackports.test.d.ts +1 -0
- package/dist/lib/getCommitsWithoutBackports.test.js +335 -0
- package/dist/lib/getGitConfigAuthor.d.ts +6 -0
- package/dist/lib/getGitConfigAuthor.js +15 -0
- package/dist/lib/getTargetBranches.d.ts +5 -0
- package/dist/lib/getTargetBranches.js +67 -0
- package/dist/lib/getTargetBranches.test.d.ts +1 -0
- package/dist/lib/getTargetBranches.test.js +206 -0
- package/dist/lib/git.d.ts +77 -0
- package/dist/lib/git.js +439 -0
- package/dist/lib/git.private.test.d.ts +1 -0
- package/dist/lib/git.private.test.js +618 -0
- package/dist/lib/git.test.d.ts +1 -0
- package/dist/lib/git.test.js +580 -0
- package/dist/lib/github/commitFormatters.d.ts +3 -0
- package/dist/lib/github/commitFormatters.js +17 -0
- package/dist/lib/github/commitFormatters.test.d.ts +1 -0
- package/dist/lib/github/commitFormatters.test.js +11 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.js +32 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.test.d.ts +1 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.test.js +27 -0
- package/dist/lib/github/v3/addLabelsToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addLabelsToPullRequest.js +30 -0
- package/dist/lib/github/v3/addReviewersToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addReviewersToPullRequest.js +32 -0
- package/dist/lib/github/v3/createPullRequest.d.ts +29 -0
- package/dist/lib/github/v3/createPullRequest.js +91 -0
- package/dist/lib/github/v3/createPullRequest.test.d.ts +1 -0
- package/dist/lib/github/v3/createPullRequest.test.js +377 -0
- package/dist/lib/github/v3/createStatusComment.d.ts +11 -0
- package/dist/lib/github/v3/createStatusComment.js +136 -0
- package/dist/lib/github/v3/createStatusComment.test.d.ts +1 -0
- package/dist/lib/github/v3/createStatusComment.test.js +461 -0
- package/dist/lib/github/v3/getGithubV3ErrorMessage.d.ts +14 -0
- package/dist/lib/github/v3/getGithubV3ErrorMessage.js +16 -0
- package/dist/lib/github/v4/FetchPullRequestId.d.ts +2 -0
- package/dist/lib/github/v4/FetchPullRequestId.js +36 -0
- package/dist/lib/github/v4/apiRequestV4.d.ts +31 -0
- package/dist/lib/github/v4/apiRequestV4.js +71 -0
- package/dist/lib/github/v4/apiRequestV4.test.d.ts +1 -0
- package/dist/lib/github/v4/apiRequestV4.test.js +109 -0
- package/dist/lib/github/v4/disablePullRequestAutoMerge.d.ts +2 -0
- package/dist/lib/github/v4/disablePullRequestAutoMerge.js +32 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.d.ts +2 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.js +50 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.js +112 -0
- package/dist/lib/github/v4/fetchAuthorId.d.ts +10 -0
- package/dist/lib/github/v4/fetchAuthorId.js +28 -0
- package/dist/lib/github/v4/fetchAuthorId.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchAuthorId.private.test.js +25 -0
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +93 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +11 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.js +58 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +136 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.d.ts +11 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.js +48 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.js +118 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +29 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.js +110 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +196 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +157 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +107 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +12 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +69 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.d.ts +9 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.js +64 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.private.test.js +44 -0
- package/dist/lib/github/v4/fetchPullRequestAutoMergeMethod.d.ts +2 -0
- package/dist/lib/github/v4/fetchPullRequestAutoMergeMethod.js +39 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.d.ts +8 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.js +49 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.private.test.js +49 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +72 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +78 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +116 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.d.ts +16 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.js +29 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.js +61 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +1 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +72 -0
- package/dist/lib/github/v4/mocks/commitsByAuthorMock.d.ts +2 -0
- package/dist/lib/github/v4/mocks/commitsByAuthorMock.js +176 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.d.ts +7 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.js +45 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.test.d.ts +1 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.test.js +87 -0
- package/dist/lib/logger.d.ts +9 -0
- package/dist/lib/logger.js +74 -0
- package/dist/lib/ora.d.ts +2 -0
- package/dist/lib/ora.js +21 -0
- package/dist/lib/prompt.test.d.ts +1 -0
- package/dist/lib/prompt.test.js +139 -0
- package/dist/lib/prompts.d.ts +17 -0
- package/dist/lib/prompts.js +132 -0
- package/dist/lib/remoteConfig.d.ts +20 -0
- package/dist/lib/remoteConfig.js +52 -0
- package/dist/lib/sequentially.d.ts +1 -0
- package/dist/lib/sequentially.js +10 -0
- package/dist/lib/setupRepo.d.ts +2 -0
- package/dist/lib/setupRepo.js +56 -0
- package/dist/lib/setupRepo.test.d.ts +1 -0
- package/dist/lib/setupRepo.test.js +278 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.d.ts +16 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.js +102 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.js +467 -0
- package/dist/lib/sourceCommit/getMockSourceCommit.d.ts +26 -0
- package/dist/lib/sourceCommit/getMockSourceCommit.js +103 -0
- package/dist/lib/sourceCommit/parseSourceCommit.d.ts +108 -0
- package/dist/lib/sourceCommit/parseSourceCommit.js +123 -0
- package/dist/lib/sourceCommit/parseSourceCommit.test.d.ts +1 -0
- package/dist/lib/sourceCommit/parseSourceCommit.test.js +226 -0
- package/dist/options/ConfigOptions.d.ts +4 -2
- package/dist/options/cliArgs.d.ts +15 -12
- package/dist/options/cliArgs.js +34 -19
- package/dist/options/cliArgs.test.js +125 -1
- 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 +3 -1
- package/dist/options/config/globalConfig.js +5 -5
- package/dist/options/config/readConfigFile.d.ts +9 -7
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +43 -7
- package/dist/options/options.js +20 -24
- package/dist/options/options.test.js +112 -54
- package/dist/runSequentially.d.ts +10 -7
- package/dist/runSequentially.js +5 -5
- package/dist/scripts/postinstall.js +3 -3
- package/dist/scripts/postinstall.test.js +1 -1
- 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 +1 -1
- package/dist/services/HandledError.js +5 -5
- package/dist/services/git.js +7 -7
- package/dist/services/github/v3/createPullRequest.js +2 -2
- package/dist/services/github/v3/createStatusComment.js +2 -2
- package/dist/services/github/v3/createStatusComment.test.js +5 -4
- package/dist/services/github/v4/apiRequestV4.js +2 -2
- package/dist/services/github/v4/apiRequestV4.test.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +3 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +3 -3
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +2 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +2 -2
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +5 -5
- package/dist/state.d.ts +0 -0
- package/dist/state.js +1 -0
- package/dist/test/e2e/cli/commit-author.private.test.js +4 -4
- package/dist/test/e2e/cli/different-merge-strategies.private.test.js +26 -24
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +189 -140
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +12 -14
- package/dist/test/e2e/cli/runBackportViaCli.d.ts +5 -2
- package/dist/test/e2e/cli/runBackportViaCli.js +42 -29
- 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 +2 -2
- package/dist/test/handleUnbackportedPullRequests.private.test.js +3 -2
- package/dist/test/setupFiles/automatic-mocks.js +1 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +3 -3
- package/dist/ui/getCommits.js +2 -2
- package/dist/ui/getTargetBranches.js +3 -3
- package/dist/ui/setupRepo.js +2 -2
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +12 -12
- package/yarn.lock +112 -65
|
@@ -22,37 +22,41 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const
|
|
27
|
-
const
|
|
29
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
30
|
+
const path_1 = __importDefault(require("path"));
|
|
31
|
+
const child_process_promisified_1 = require("../../../lib/child-process-promisified");
|
|
28
32
|
const packageVersion = __importStar(require("../../../utils/packageVersion"));
|
|
29
33
|
const getDevAccessToken_1 = require("../../private/getDevAccessToken");
|
|
30
34
|
const sandbox_1 = require("../../sandbox");
|
|
31
35
|
const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
32
|
-
|
|
33
|
-
jest.setTimeout(TIMEOUT_IN_SECONDS * 1000);
|
|
36
|
+
jest.setTimeout(10000);
|
|
34
37
|
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
35
38
|
describe('entrypoint cli', () => {
|
|
36
39
|
it('--version', async () => {
|
|
37
|
-
const
|
|
40
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([`--version`], {
|
|
38
41
|
showOra: true,
|
|
39
42
|
});
|
|
40
|
-
expect(
|
|
43
|
+
expect(output).toEqual(process.env.npm_package_version);
|
|
41
44
|
});
|
|
42
45
|
it('-v', async () => {
|
|
43
|
-
const
|
|
46
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([`-v`], {
|
|
44
47
|
showOra: true,
|
|
45
48
|
});
|
|
46
|
-
expect(
|
|
49
|
+
expect(output).toEqual(process.env.npm_package_version);
|
|
47
50
|
});
|
|
48
51
|
it('PACKAGE_VERSION should match', async () => {
|
|
49
52
|
// @ts-expect-error
|
|
50
53
|
expect(packageVersion.UNMOCKED_PACKAGE_VERSION).toBe(process.env.npm_package_version);
|
|
51
54
|
});
|
|
52
55
|
it('--help', async () => {
|
|
53
|
-
const
|
|
54
|
-
expect(
|
|
56
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([`--help`]);
|
|
57
|
+
expect(output).toMatchInlineSnapshot(`
|
|
55
58
|
"entrypoint.cli.ts [args]
|
|
59
|
+
|
|
56
60
|
Options:
|
|
57
61
|
-v, --version Show version number [boolean]
|
|
58
62
|
--accessToken, --accesstoken Github access token [string]
|
|
@@ -62,10 +66,10 @@ describe('entrypoint cli', () => {
|
|
|
62
66
|
--autoMerge Enable auto-merge for created pull requests [boolean]
|
|
63
67
|
--autoMergeMethod Sets auto-merge method when using --auto-merge. Default:
|
|
64
68
|
merge [string] [choices: \\"merge\\", \\"rebase\\", \\"squash\\"]
|
|
65
|
-
--ci Disable interactive prompts [boolean]
|
|
66
69
|
--cherrypickRef Append commit message with \\"(cherry picked from commit...)
|
|
67
70
|
[boolean]
|
|
68
71
|
--projectConfigFile, --config Path to project config [string]
|
|
72
|
+
--globalConfigFile Path to global config [string]
|
|
69
73
|
--since ISO-8601 date for filtering commits [string]
|
|
70
74
|
--until ISO-8601 date for filtering commits [string]
|
|
71
75
|
--dir Path to temporary backport repo [string]
|
|
@@ -78,6 +82,8 @@ describe('entrypoint cli', () => {
|
|
|
78
82
|
[boolean]
|
|
79
83
|
--gitAuthorName Set commit author name [string]
|
|
80
84
|
--gitAuthorEmail Set commit author email [string]
|
|
85
|
+
--nonInteractive, --json Disable interactive prompts and return response as JSON
|
|
86
|
+
[boolean]
|
|
81
87
|
--ls List commits instead of backporting them [boolean]
|
|
82
88
|
--mainline Parent id of merge commit. Defaults to 1 when supplied
|
|
83
89
|
without arguments [number]
|
|
@@ -112,102 +118,36 @@ describe('entrypoint cli', () => {
|
|
|
112
118
|
-l, --targetPRLabel, --label Add labels to the target (backport) PR [array]
|
|
113
119
|
--verify Opposite of no-verify [boolean]
|
|
114
120
|
--help Show help [boolean]
|
|
121
|
+
|
|
115
122
|
For bugs, feature requests or questions: https://github.com/sqren/backport/issues
|
|
116
123
|
Or contact me directly: https://twitter.com/sorenlouv"
|
|
117
124
|
`);
|
|
118
125
|
});
|
|
119
|
-
it('should output error when branch is missing', async () => {
|
|
120
|
-
const res = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
121
|
-
'--skip-remote-config',
|
|
122
|
-
'--repo=backport-org/backport-e2e',
|
|
123
|
-
`--accessToken=${accessToken}`,
|
|
124
|
-
]);
|
|
125
|
-
expect(res).toMatchInlineSnapshot(`
|
|
126
|
-
"Please specify a target branch: \\"--branch 6.1\\".
|
|
127
|
-
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
128
|
-
`);
|
|
129
|
-
});
|
|
130
|
-
it('should output error when access token is invalid', async () => {
|
|
131
|
-
const res = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
132
|
-
'--branch=foo',
|
|
133
|
-
'--repo=foo/bar',
|
|
134
|
-
'--accessToken=some-token',
|
|
135
|
-
]);
|
|
136
|
-
expect(res).toContain('Please check your access token and make sure it is valid');
|
|
137
|
-
});
|
|
138
126
|
it('should list commits based on .git/config when `repoOwner`/`repoName` is missing', async () => {
|
|
139
127
|
const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
140
128
|
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
141
129
|
await (0, child_process_promisified_1.exec)(`git init`, { cwd: sandboxPath });
|
|
142
130
|
await (0, child_process_promisified_1.exec)(`git remote add origin git@github.com:backport-org/backport-e2e.git`, { cwd: sandboxPath });
|
|
143
|
-
const
|
|
131
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([`--accessToken=${accessToken}`], {
|
|
144
132
|
cwd: sandboxPath,
|
|
145
133
|
waitForString: 'Select commit',
|
|
146
134
|
});
|
|
147
|
-
expect(
|
|
135
|
+
expect(output).toMatchInlineSnapshot(`
|
|
148
136
|
"? Select commit (Use arrow keys)
|
|
149
|
-
❯ 1. Add sheep emoji (#9) 7.8
|
|
150
|
-
2. Change Ulysses to Gretha (conflict) (#8) 7.x
|
|
151
|
-
3. Add 🍏 emoji (#5) 7.x, 7.8
|
|
152
|
-
4. Add family emoji (#2) 7.x
|
|
153
|
-
5. Add \`backport\` dep
|
|
154
|
-
6. Merge pull request #1 from backport-org/add-heart-emoji
|
|
155
|
-
7. Add ❤️ emoji
|
|
156
|
-
8. Update .backportrc.json
|
|
157
|
-
9. Bump to 8.0.0
|
|
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
|
|
158
146
|
10.Add package.json"
|
|
159
147
|
`);
|
|
160
148
|
});
|
|
161
|
-
it(`should output error when repo doesn't exist`, async () => {
|
|
162
|
-
const res = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
163
|
-
'--branch=foo',
|
|
164
|
-
'--repo=foo/bar',
|
|
165
|
-
'--author=sqren',
|
|
166
|
-
`--accessToken=${accessToken}`,
|
|
167
|
-
]);
|
|
168
|
-
expect(res).toMatchInlineSnapshot(`"The repository \\"foo/bar\\" doesn't exist"`);
|
|
169
|
-
});
|
|
170
|
-
it(`should output error when given branch is invalid`, async () => {
|
|
171
|
-
const res = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
172
|
-
'--branch=foo',
|
|
173
|
-
'--repo=backport-org/backport-e2e',
|
|
174
|
-
'--pr=9',
|
|
175
|
-
`--accessToken=${accessToken}`,
|
|
176
|
-
], { waitForString: "is invalid or doesn't exist" });
|
|
177
|
-
expect(res).toMatchInlineSnapshot(`
|
|
178
|
-
"
|
|
179
|
-
Backporting to foo:
|
|
180
|
-
The branch \\"foo\\" is invalid or doesn't exist"
|
|
181
|
-
`);
|
|
182
|
-
});
|
|
183
|
-
it(`should output merge conflict`, async () => {
|
|
184
|
-
const res = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
185
|
-
'--repo=backport-org/repo-with-conflicts',
|
|
186
|
-
'--pr=12',
|
|
187
|
-
'--branch=7.x',
|
|
188
|
-
`--accessToken=${accessToken}`,
|
|
189
|
-
'--dry-run',
|
|
190
|
-
], {
|
|
191
|
-
waitForString: 'Press ENTER when the conflicts',
|
|
192
|
-
});
|
|
193
|
-
const backportDir = (0, env_1.getBackportDirPath)();
|
|
194
|
-
expect(res.replaceAll(backportDir, '<HOMEDIR>')).toMatchInlineSnapshot(`
|
|
195
|
-
"
|
|
196
|
-
Backporting to 7.x:
|
|
197
|
-
The commit could not be backported due to conflicts
|
|
198
|
-
Please fix the conflicts in <HOMEDIR>/repositories/backport-org/repo-with-conflicts
|
|
199
|
-
Hint: Before fixing the conflicts manually you should consider backporting the following pull requests to \\"7.x\\":
|
|
200
|
-
- Change Barca to Braithwaite (#8) (backport missing)
|
|
201
|
-
https://github.com/backport-org/repo-with-conflicts/pull/8
|
|
202
|
-
? Fix the following conflicts manually:
|
|
203
|
-
Conflicting files:
|
|
204
|
-
- <HOMEDIR>/repositories/backport-org/repo-with-conflicts/la-liga.
|
|
205
|
-
md
|
|
206
|
-
Press ENTER when the conflicts are resolved and files are staged (Y/n)"
|
|
207
|
-
`);
|
|
208
|
-
});
|
|
209
149
|
it(`should list commits from master`, async () => {
|
|
210
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
150
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
211
151
|
'--branch=foo',
|
|
212
152
|
'--repo=backport-org/backport-e2e',
|
|
213
153
|
'--author=sqren',
|
|
@@ -216,16 +156,16 @@ describe('entrypoint cli', () => {
|
|
|
216
156
|
], { waitForString: 'Select commit' });
|
|
217
157
|
expect(output).toMatchInlineSnapshot(`
|
|
218
158
|
"? Select commit (Use arrow keys)
|
|
219
|
-
❯ 1. Add sheep emoji (#9) 7.8
|
|
220
|
-
2. Change Ulysses to Gretha (conflict) (#8) 7.x
|
|
221
|
-
3. Add 🍏 emoji (#5) 7.x, 7.8
|
|
222
|
-
4. Add family emoji (#2) 7.x
|
|
223
|
-
5. Add \`backport\` dep
|
|
159
|
+
❯ 1. Add sheep emoji (#9) 7.8
|
|
160
|
+
2. Change Ulysses to Gretha (conflict) (#8) 7.x
|
|
161
|
+
3. Add 🍏 emoji (#5) 7.x, 7.8
|
|
162
|
+
4. Add family emoji (#2) 7.x
|
|
163
|
+
5. Add \`backport\` dep
|
|
224
164
|
6. Merge pull request #1 from backport-org/add-heart-emoji"
|
|
225
165
|
`);
|
|
226
166
|
});
|
|
227
167
|
it(`should filter commits by "since" and "until"`, async () => {
|
|
228
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
168
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
229
169
|
'--branch=foo',
|
|
230
170
|
'--repo=backport-org/backport-e2e',
|
|
231
171
|
`--accessToken=${accessToken}`,
|
|
@@ -234,14 +174,14 @@ describe('entrypoint cli', () => {
|
|
|
234
174
|
], { waitForString: 'Select commit' });
|
|
235
175
|
expect(output).toMatchInlineSnapshot(`
|
|
236
176
|
"? Select commit (Use arrow keys)
|
|
237
|
-
❯ 1. Bump to 8.0.0
|
|
238
|
-
2. Add package.json
|
|
239
|
-
3. Update .backportrc.json
|
|
177
|
+
❯ 1. Bump to 8.0.0
|
|
178
|
+
2. Add package.json
|
|
179
|
+
3. Update .backportrc.json
|
|
240
180
|
4. Create .backportrc.json"
|
|
241
181
|
`);
|
|
242
182
|
});
|
|
243
183
|
it(`should list commits from 7.x`, async () => {
|
|
244
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
184
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
245
185
|
'--branch=foo',
|
|
246
186
|
'--repo=backport-org/backport-e2e',
|
|
247
187
|
'--author=sqren',
|
|
@@ -251,31 +191,154 @@ describe('entrypoint cli', () => {
|
|
|
251
191
|
], { waitForString: 'Select commit' });
|
|
252
192
|
expect(output).toMatchInlineSnapshot(`
|
|
253
193
|
"? Select commit (Use arrow keys)
|
|
254
|
-
❯ 1. Add 🍏 emoji (#5) (#6)
|
|
255
|
-
2. Change Ulysses to Carol
|
|
256
|
-
3. Add family emoji (#2) (#4)
|
|
257
|
-
4. Update .backportrc.json
|
|
258
|
-
5. Branch off: 7.9.0 (7.x)
|
|
194
|
+
❯ 1. Add 🍏 emoji (#5) (#6)
|
|
195
|
+
2. Change Ulysses to Carol
|
|
196
|
+
3. Add family emoji (#2) (#4)
|
|
197
|
+
4. Update .backportrc.json
|
|
198
|
+
5. Branch off: 7.9.0 (7.x)
|
|
259
199
|
6. Bump to 8.0.0"
|
|
260
200
|
`);
|
|
261
201
|
});
|
|
262
|
-
|
|
202
|
+
async function createConfigFile(options) {
|
|
203
|
+
const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
204
|
+
const configPath = path_1.default.join(sandboxPath, 'config.json');
|
|
205
|
+
await promises_1.default.writeFile(configPath, JSON.stringify(options));
|
|
206
|
+
return configPath;
|
|
207
|
+
}
|
|
208
|
+
describe('errors in interactive mode (non-json)', () => {
|
|
209
|
+
it('when branch is missing', async () => {
|
|
210
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
211
|
+
'--skip-remote-config',
|
|
212
|
+
'--repo=backport-org/backport-e2e',
|
|
213
|
+
`--accessToken=${accessToken}`,
|
|
214
|
+
]);
|
|
215
|
+
expect(output).toMatchInlineSnapshot(`
|
|
216
|
+
"Please specify a target branch: \\"--branch 6.1\\".
|
|
217
|
+
|
|
218
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
219
|
+
`);
|
|
220
|
+
});
|
|
221
|
+
it('when supplying invalid argument', async () => {
|
|
222
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([`--foo`]);
|
|
223
|
+
expect(output).toMatchInlineSnapshot(`
|
|
224
|
+
"Unknown argument: foo
|
|
225
|
+
Run \\"backport --help\\" to see all options"
|
|
226
|
+
`);
|
|
227
|
+
});
|
|
228
|
+
it('when access token is invalid', async () => {
|
|
229
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
230
|
+
'--branch=foo',
|
|
231
|
+
'--repo=foo/bar',
|
|
232
|
+
'--accessToken=some-token',
|
|
233
|
+
]);
|
|
234
|
+
expect(output).toContain('Please check your access token and make sure it is valid');
|
|
235
|
+
});
|
|
236
|
+
it(`should output error when repo doesn't exist`, async () => {
|
|
237
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
238
|
+
'--branch=foo',
|
|
239
|
+
'--repo=foo/bar',
|
|
240
|
+
'--author=sqren',
|
|
241
|
+
`--accessToken=${accessToken}`,
|
|
242
|
+
]);
|
|
243
|
+
expect(output).toMatchInlineSnapshot(`"The repository \\"foo/bar\\" doesn't exist"`);
|
|
244
|
+
});
|
|
245
|
+
it(`should output error when given branch is invalid`, async () => {
|
|
246
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
247
|
+
'--branch=foo',
|
|
248
|
+
'--repo=backport-org/backport-e2e',
|
|
249
|
+
'--pr=9',
|
|
250
|
+
`--accessToken=${accessToken}`,
|
|
251
|
+
]);
|
|
252
|
+
expect(output).toMatchInlineSnapshot(`
|
|
253
|
+
"Backporting to foo:
|
|
254
|
+
The branch \\"foo\\" is invalid or doesn't exist"
|
|
255
|
+
`);
|
|
256
|
+
});
|
|
257
|
+
it(`should output merge conflict`, async () => {
|
|
258
|
+
const backportDir = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
259
|
+
await (0, sandbox_1.resetSandbox)(backportDir);
|
|
260
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
261
|
+
'--repo=backport-org/repo-with-conflicts',
|
|
262
|
+
'--pr=12',
|
|
263
|
+
'--branch=7.x',
|
|
264
|
+
`--accessToken=${accessToken}`,
|
|
265
|
+
`--dir=${backportDir}`,
|
|
266
|
+
'--dry-run',
|
|
267
|
+
], {
|
|
268
|
+
waitForString: 'Press ENTER when the conflicts',
|
|
269
|
+
timeoutSeconds: 5,
|
|
270
|
+
});
|
|
271
|
+
// //@ts-expect-error
|
|
272
|
+
// const lineToReplace = output.match(
|
|
273
|
+
// /Conflicting files:[\s]+- (.*[\s].*)la-liga.md/
|
|
274
|
+
// )[1];
|
|
275
|
+
// const lineWithoutBreaks = lineToReplace.replace(/\s/g, '');
|
|
276
|
+
// const outputReplaced = output
|
|
277
|
+
// .replace(lineToReplace, lineWithoutBreaks)
|
|
278
|
+
// .replaceAll(backportDir, '<BACKPORT_DIR>');
|
|
279
|
+
const outputReplaced = output
|
|
280
|
+
.replaceAll('\n', '')
|
|
281
|
+
.replaceAll(backportDir, '<BACKPORT_DIR>');
|
|
282
|
+
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)"`);
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
describe('failure cases in json mode (and non-interactive)', () => {
|
|
263
286
|
it(`when access token is missing`, async () => {
|
|
264
|
-
const
|
|
287
|
+
const configFilePath = await createConfigFile({});
|
|
288
|
+
const { output, code } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
289
|
+
'--json',
|
|
290
|
+
`--globalConfigFile=${configFilePath}`,
|
|
291
|
+
]);
|
|
292
|
+
const backportResult = JSON.parse(output);
|
|
293
|
+
expect(code).toBe(1);
|
|
294
|
+
expect(backportResult.status).toBe('failure');
|
|
295
|
+
expect(backportResult.errorMessage.replace(configFilePath, '<GLOBAL_CONFIG_FILE>')).toMatchInlineSnapshot(`
|
|
296
|
+
"Please update your config file: \\"<GLOBAL_CONFIG_FILE>\\".
|
|
297
|
+
It must contain a valid \\"accessToken\\".
|
|
298
|
+
|
|
299
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
|
|
300
|
+
`);
|
|
301
|
+
});
|
|
302
|
+
it('when target branches cannot be inferred from pull request', async () => {
|
|
303
|
+
const { output, code } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
304
|
+
'--json',
|
|
305
|
+
'--repo=backport-org/backport-e2e',
|
|
306
|
+
'--pr=9',
|
|
307
|
+
`--accessToken=${accessToken}`,
|
|
308
|
+
]);
|
|
309
|
+
expect(code).toBe(0);
|
|
310
|
+
const backportResult = JSON.parse(output);
|
|
311
|
+
expect(backportResult.status).toBe('aborted');
|
|
312
|
+
expect(backportResult.error).toEqual({
|
|
313
|
+
errorContext: { code: 'no-branches-exception' },
|
|
314
|
+
name: 'BackportError',
|
|
315
|
+
});
|
|
316
|
+
expect(backportResult.errorMessage).toBe('There are no branches to backport to. Aborting.');
|
|
317
|
+
});
|
|
318
|
+
it(`when target branch and branch label mapping are missing`, async () => {
|
|
319
|
+
const { output, code } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
320
|
+
'--json',
|
|
321
|
+
`--access-token=${accessToken}`,
|
|
322
|
+
]);
|
|
323
|
+
expect(code).toBe(1);
|
|
265
324
|
const backportResult = JSON.parse(output);
|
|
266
325
|
expect(backportResult.status).toBe('failure');
|
|
267
|
-
expect(backportResult.errorMessage).
|
|
326
|
+
expect(backportResult.errorMessage).toMatchInlineSnapshot(`
|
|
327
|
+
"Please specify a target branch: \\"--branch 6.1\\".
|
|
328
|
+
|
|
329
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
330
|
+
`);
|
|
268
331
|
});
|
|
269
332
|
it(`when argument is invalid`, async () => {
|
|
270
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)(['--
|
|
333
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)(['--json', '--foo'], {});
|
|
271
334
|
const backportResult = JSON.parse(output);
|
|
272
335
|
expect(backportResult.status).toBe('failure');
|
|
273
336
|
expect(backportResult.errorMessage).toEqual('Unknown argument: foo');
|
|
274
337
|
});
|
|
275
338
|
it('when `--repo` is invalid', async () => {
|
|
276
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
339
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
340
|
+
'--json',
|
|
277
341
|
'--repo=backport-org/backport-e2e-foo',
|
|
278
|
-
'--ci',
|
|
279
342
|
`--accessToken=${accessToken}`,
|
|
280
343
|
]);
|
|
281
344
|
const backportResult = JSON.parse(output);
|
|
@@ -283,10 +346,10 @@ describe('entrypoint cli', () => {
|
|
|
283
346
|
expect(backportResult.errorMessage).toEqual('The repository "backport-org/backport-e2e-foo" doesn\'t exist');
|
|
284
347
|
});
|
|
285
348
|
it('when `--sha` is invalid', async () => {
|
|
286
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
349
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
350
|
+
'--json',
|
|
287
351
|
'--repo=backport-org/backport-e2e',
|
|
288
352
|
'--sha=abcdefg',
|
|
289
|
-
'--ci',
|
|
290
353
|
`--accessToken=${accessToken}`,
|
|
291
354
|
]);
|
|
292
355
|
const backportResult = JSON.parse(output);
|
|
@@ -294,11 +357,11 @@ describe('entrypoint cli', () => {
|
|
|
294
357
|
expect(backportResult.errorMessage).toEqual('No commit found on branch "master" with sha "abcdefg"');
|
|
295
358
|
});
|
|
296
359
|
it('when `--branch` is invalid', async () => {
|
|
297
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
360
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
361
|
+
'--json',
|
|
298
362
|
'--repo=backport-org/backport-e2e',
|
|
299
363
|
'--pr=9',
|
|
300
364
|
'--branch=foobar',
|
|
301
|
-
'--ci',
|
|
302
365
|
`--accessToken=${accessToken}`,
|
|
303
366
|
]);
|
|
304
367
|
const backportResult = JSON.parse(output);
|
|
@@ -309,30 +372,30 @@ describe('entrypoint cli', () => {
|
|
|
309
372
|
code: 'message-only-exception',
|
|
310
373
|
message: 'The branch "foobar" is invalid or doesn\'t exist',
|
|
311
374
|
},
|
|
312
|
-
name: '
|
|
375
|
+
name: 'BackportError',
|
|
313
376
|
},
|
|
314
377
|
status: 'handled-error',
|
|
315
378
|
targetBranch: 'foobar',
|
|
316
379
|
});
|
|
317
380
|
});
|
|
318
381
|
it('when `--pr` is invalid', async () => {
|
|
319
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
382
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
383
|
+
'--json',
|
|
320
384
|
'--repo=backport-org/backport-e2e',
|
|
321
385
|
'--pr=900',
|
|
322
386
|
'--branch=foobar',
|
|
323
|
-
'--ci',
|
|
324
387
|
`--accessToken=${accessToken}`,
|
|
325
388
|
]);
|
|
326
389
|
const backportResult = JSON.parse(output);
|
|
327
390
|
expect(backportResult.status).toEqual('failure');
|
|
328
391
|
expect(backportResult.errorMessage).toEqual('Could not resolve to a PullRequest with the number of 900. (Github API v4)');
|
|
329
392
|
});
|
|
330
|
-
it('when having conflicts', async () => {
|
|
331
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
393
|
+
it('when having conflicts in non-interactive mode', async () => {
|
|
394
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
395
|
+
'--json',
|
|
332
396
|
'--repo=backport-org/repo-with-conflicts',
|
|
333
397
|
'--pr=12',
|
|
334
398
|
'--branch=7.x',
|
|
335
|
-
'--ci',
|
|
336
399
|
`--accessToken=${accessToken}`,
|
|
337
400
|
]);
|
|
338
401
|
const backportResult = JSON.parse(output);
|
|
@@ -342,12 +405,12 @@ describe('entrypoint cli', () => {
|
|
|
342
405
|
backportResult.results[0].error.errorContext.conflictingFiles).toEqual(['la-liga.md']);
|
|
343
406
|
});
|
|
344
407
|
it('when `--source-branch` is invalid', async () => {
|
|
345
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
408
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
409
|
+
'--json',
|
|
346
410
|
'--repo=backport-org/backport-e2e',
|
|
347
411
|
'--pr=9',
|
|
348
412
|
'--branch=7.x',
|
|
349
413
|
'--source-branch=foo',
|
|
350
|
-
'--ci',
|
|
351
414
|
`--accessToken=${accessToken}`,
|
|
352
415
|
]);
|
|
353
416
|
const backportResult = JSON.parse(output);
|
|
@@ -367,10 +430,10 @@ describe('entrypoint cli', () => {
|
|
|
367
430
|
});
|
|
368
431
|
});
|
|
369
432
|
it('when PR is not merged', async () => {
|
|
370
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
433
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
434
|
+
'--json',
|
|
371
435
|
'--repo=backport-org/backport-e2e',
|
|
372
436
|
'--pr=12',
|
|
373
|
-
'--ci',
|
|
374
437
|
`--accessToken=${accessToken}`,
|
|
375
438
|
]);
|
|
376
439
|
const backportResult = JSON.parse(output);
|
|
@@ -380,21 +443,7 @@ describe('entrypoint cli', () => {
|
|
|
380
443
|
code: 'message-only-exception',
|
|
381
444
|
message: 'The PR #12 is not merged',
|
|
382
445
|
},
|
|
383
|
-
name: '
|
|
384
|
-
});
|
|
385
|
-
});
|
|
386
|
-
it('when target branch is missing', async () => {
|
|
387
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
388
|
-
'--repo=backport-org/backport-e2e',
|
|
389
|
-
'--pr=9',
|
|
390
|
-
'--ci',
|
|
391
|
-
`--accessToken=${accessToken}`,
|
|
392
|
-
]);
|
|
393
|
-
const backportResult = JSON.parse(output);
|
|
394
|
-
expect(backportResult.status).toBe('aborted');
|
|
395
|
-
expect(backportResult.error).toEqual({
|
|
396
|
-
errorContext: { code: 'no-branches-exception' },
|
|
397
|
-
name: 'HandledError',
|
|
446
|
+
name: 'BackportError',
|
|
398
447
|
});
|
|
399
448
|
});
|
|
400
449
|
});
|
|
@@ -5,44 +5,42 @@ const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
|
5
5
|
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
6
6
|
describe('repo-with-backportrc-removed (missing .backportrc.json config file)', () => {
|
|
7
7
|
it('lists commits', async () => {
|
|
8
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
8
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
9
9
|
'--branch=foo',
|
|
10
10
|
'--repo=backport-org/repo-with-backportrc-removed',
|
|
11
11
|
`--accessToken=${accessToken}`,
|
|
12
12
|
], { waitForString: 'Select commit' });
|
|
13
13
|
expect(output).toMatchInlineSnapshot(`
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
"? Select commit (Use arrow keys)
|
|
15
|
+
❯ 1. Rename README.me to README.md
|
|
16
|
+
2. Merge pull request #1 from backport-org/add-readme
|
|
17
|
+
3. Create README.me
|
|
18
|
+
4. Delete .backportrc.json
|
|
19
|
+
5. Create .backportrc.json
|
|
20
|
+
6. Delete .backportrc.json
|
|
21
|
+
7. Create .backportrc.json"
|
|
22
|
+
`);
|
|
23
23
|
});
|
|
24
24
|
it('backports via pr', async () => {
|
|
25
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
25
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
26
26
|
'--branch=production',
|
|
27
27
|
'--repo=backport-org/repo-with-backportrc-removed',
|
|
28
28
|
'--pr=1',
|
|
29
29
|
`--accessToken=${accessToken}`,
|
|
30
30
|
'--dry-run',
|
|
31
31
|
], {
|
|
32
|
-
waitForString: `Dry run complete`,
|
|
33
32
|
showOra: true,
|
|
34
33
|
});
|
|
35
34
|
expect(output).toContain('Cherry-picking: Merge pull request #1 from backport-org/add-readme');
|
|
36
35
|
});
|
|
37
36
|
it('backport by commit sha', async () => {
|
|
38
|
-
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
37
|
+
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
39
38
|
'--branch=production',
|
|
40
39
|
'--repo=backport-org/repo-with-backportrc-removed',
|
|
41
40
|
'--sha=be59df6912a550c8cb49ba3e18be3e512f3d608c',
|
|
42
41
|
`--accessToken=${accessToken}`,
|
|
43
42
|
'--dry-run',
|
|
44
43
|
], {
|
|
45
|
-
waitForString: `Dry run complete`,
|
|
46
44
|
showOra: true,
|
|
47
45
|
});
|
|
48
46
|
expect(output).toContain('Cherry-picking: Create README.me');
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
export declare function runBackportViaCli(
|
|
1
|
+
export declare function runBackportViaCli(backportArgs: string[], { timeoutSeconds, showOra, waitForString, cwd, }?: {
|
|
2
2
|
timeoutSeconds?: number;
|
|
3
3
|
showOra?: boolean;
|
|
4
4
|
waitForString?: string;
|
|
5
5
|
cwd?: string;
|
|
6
|
-
}): Promise<
|
|
6
|
+
}): Promise<{
|
|
7
|
+
output: string;
|
|
8
|
+
code: number | null;
|
|
9
|
+
}>;
|