backport 8.3.1 → 8.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -178
- package/dist/lib/cherrypickAndCreateTargetPullRequest.js +42 -21
- package/dist/lib/child-process-promisified.js +2 -2
- package/dist/lib/git.d.ts +4 -3
- package/dist/lib/git.js +22 -29
- package/dist/lib/git.private.test.js +10 -7
- package/dist/lib/git.test.js +47 -15
- package/dist/lib/github/v4/apiRequestV4.js +14 -8
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +1 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -0
- package/dist/lib/ora.d.ts +1 -0
- package/dist/options/ConfigOptions.d.ts +1 -0
- package/dist/options/cliArgs.d.ts +1 -0
- package/dist/options/cliArgs.js +5 -0
- package/dist/options/config/config.d.ts +1 -0
- package/dist/options/config/readConfigFile.d.ts +1 -0
- package/dist/options/options.d.ts +2 -0
- package/dist/options/options.js +3 -2
- package/dist/options/options.test.js +5 -4
- package/dist/test/e2e/cli/date-filters.private.test.js +1 -0
- package/dist/test/e2e/cli/different-merge-strategies.private.test.js +122 -6
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +2 -0
- package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.js +27 -13
- package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.js +3 -2
- package/dist/{entrypoint.cli.private.test.d.ts → test/e2e/cli/gracefully-handles-corrupt-repo.private.test.d.ts} +0 -0
- package/dist/test/e2e/cli/gracefully-handles-corrupt-repo.private.test.js +52 -0
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +2 -2
- package/dist/{lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts → test/e2e/cli/repo-with-programatically-added-commits.mutation.test.d.ts} +0 -0
- package/dist/test/e2e/cli/repo-with-programatically-added-commits.mutation.test.js +114 -0
- package/dist/test/e2e/cli/runBackportViaCli.d.ts +8 -2
- package/dist/test/e2e/cli/runBackportViaCli.js +47 -17
- package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +7 -1
- package/dist/test/e2e/module/entrypoint.module.mutation.test.js +1 -1
- package/dist/test/handleUnbackportedPullRequests.private.test.js +1 -1
- package/dist/test/replaceStringAndLinebreaks.d.ts +5 -0
- package/dist/test/replaceStringAndLinebreaks.js +8 -0
- package/dist/test/sandbox.js +6 -2
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +23 -24
- package/yarn.lock +841 -950
- package/dist/entrypoint.cli.private.test.js +0 -47
- package/dist/errors/BackportError.d.ts +0 -19
- package/dist/errors/BackportError.js +0 -29
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
- package/dist/runSequentially.test.d.ts +0 -1
- package/dist/runSequentially.test.js +0 -243
- package/dist/services/BackportError.d.ts +0 -19
- package/dist/services/BackportError.js +0 -29
- package/dist/services/HandledBackportError.d.ts +0 -19
- package/dist/services/HandledBackportError.js +0 -29
- package/dist/services/HandledError.d.ts +0 -19
- package/dist/services/HandledError.js +0 -29
- package/dist/services/child-process-promisified.d.ts +0 -25
- package/dist/services/child-process-promisified.js +0 -58
- package/dist/services/env.d.ts +0 -7
- package/dist/services/env.js +0 -30
- package/dist/services/env.test.d.ts +0 -1
- package/dist/services/env.test.js +0 -21
- package/dist/services/git.d.ts +0 -77
- package/dist/services/git.integration.test.d.ts +0 -1
- package/dist/services/git.integration.test.js +0 -616
- package/dist/services/git.js +0 -439
- package/dist/services/git.private.test.d.ts +0 -1
- package/dist/services/git.private.test.js +0 -618
- package/dist/services/git.test.d.ts +0 -1
- package/dist/services/git.test.js +0 -580
- package/dist/services/github/commitFormatters.d.ts +0 -3
- package/dist/services/github/commitFormatters.js +0 -17
- package/dist/services/github/commitFormatters.test.d.ts +0 -1
- package/dist/services/github/commitFormatters.test.js +0 -11
- package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +0 -2
- package/dist/services/github/v3/addAssigneesToPullRequest.js +0 -32
- package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +0 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.test.js +0 -27
- package/dist/services/github/v3/addLabelsToPullRequest.d.ts +0 -2
- package/dist/services/github/v3/addLabelsToPullRequest.js +0 -30
- package/dist/services/github/v3/addReviewersToPullRequest.d.ts +0 -2
- package/dist/services/github/v3/addReviewersToPullRequest.js +0 -32
- package/dist/services/github/v3/createPullRequest.d.ts +0 -29
- package/dist/services/github/v3/createPullRequest.js +0 -91
- package/dist/services/github/v3/createPullRequest.test.d.ts +0 -1
- package/dist/services/github/v3/createPullRequest.test.js +0 -377
- package/dist/services/github/v3/createStatusComment.d.ts +0 -11
- package/dist/services/github/v3/createStatusComment.js +0 -131
- package/dist/services/github/v3/createStatusComment.test.d.ts +0 -1
- package/dist/services/github/v3/createStatusComment.test.js +0 -409
- package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +0 -14
- package/dist/services/github/v3/getGithubV3ErrorMessage.js +0 -16
- package/dist/services/github/v4/FetchPullRequestId.d.ts +0 -2
- package/dist/services/github/v4/FetchPullRequestId.js +0 -36
- package/dist/services/github/v4/apiRequestV4.d.ts +0 -31
- package/dist/services/github/v4/apiRequestV4.js +0 -71
- package/dist/services/github/v4/apiRequestV4.test.d.ts +0 -1
- package/dist/services/github/v4/apiRequestV4.test.js +0 -109
- package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -2
- package/dist/services/github/v4/disablePullRequestAutoMerge.js +0 -32
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -2
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +0 -50
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +0 -1
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
- package/dist/services/github/v4/fetchAuthorId.d.ts +0 -10
- package/dist/services/github/v4/fetchAuthorId.js +0 -28
- package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchAuthorId.private.test.js +0 -25
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -93
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +0 -11
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +0 -58
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +0 -136
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +0 -11
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +0 -48
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +0 -118
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +0 -29
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +0 -110
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +0 -196
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -157
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +0 -3
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +0 -61
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +0 -107
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +0 -12
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +0 -69
- package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -9
- package/dist/services/github/v4/fetchExistingPullRequest.js +0 -64
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -44
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -2
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +0 -39
- package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +0 -8
- package/dist/services/github/v4/fetchRemoteProjectConfig.js +0 -49
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +0 -49
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +0 -69
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +0 -73
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +0 -1
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -116
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +0 -16
- package/dist/services/github/v4/getOptionsFromGithub/query.js +0 -29
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +0 -29
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +0 -61
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +0 -1
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +0 -72
- package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +0 -176
- package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +0 -6
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +0 -45
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +0 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +0 -87
- package/dist/services/logger.d.ts +0 -9
- package/dist/services/logger.js +0 -74
- package/dist/services/prompt.test.d.ts +0 -1
- package/dist/services/prompt.test.js +0 -139
- package/dist/services/prompts.d.ts +0 -17
- package/dist/services/prompts.js +0 -132
- package/dist/services/remoteConfig.d.ts +0 -20
- package/dist/services/remoteConfig.js +0 -52
- package/dist/services/sequentially.d.ts +0 -1
- package/dist/services/sequentially.js +0 -10
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +0 -16
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +0 -102
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +0 -1
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +0 -467
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +0 -26
- package/dist/services/sourceCommit/getMockSourceCommit.js +0 -103
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +0 -108
- package/dist/services/sourceCommit/parseSourceCommit.js +0 -123
- package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit/parseSourceCommit.test.js +0 -226
- package/dist/services/test.d.ts +0 -1
- package/dist/services/test.js +0 -23
- package/dist/state.d.ts +0 -0
- package/dist/state.js +0 -1
- package/dist/test/ExecError.d.ts +0 -16
- package/dist/test/ExecError.js +0 -15
- package/dist/test/e2e/cli/cli.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/cli.private.test.js +0 -222
- package/dist/test/e2e/cli/date-filters.d.ts +0 -1
- package/dist/test/e2e/cli/date-filters.js +0 -43
- package/dist/test/e2e/cli/interactive-error-handling.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/interactive-error-handling.private.test.js +0 -80
- package/dist/test/e2e/cli/non-interactive-error-handling.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/non-interactive-error-handling.private.test.js +0 -198
- package/dist/test/e2e/cli.e2e.private.test.d.ts +0 -1
- package/dist/test/e2e/cli.e2e.private.test.js +0 -433
- package/dist/test/e2e/module/module.mutation.test.d.ts +0 -1
- package/dist/test/e2e/module/module.mutation.test.js +0 -369
- package/dist/test/e2e/module.e2e.mutation.test.d.ts +0 -1
- package/dist/test/e2e/module.e2e.mutation.test.js +0 -369
- package/dist/test/e2e/module.e2e.private.test.d.ts +0 -1
- package/dist/test/e2e/module.e2e.private.test.js +0 -369
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -13
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +0 -243
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +0 -320
- package/dist/ui/getCommits.d.ts +0 -2
- package/dist/ui/getCommits.js +0 -75
- package/dist/ui/getCommitsWithoutBackports.d.ts +0 -11
- package/dist/ui/getCommitsWithoutBackports.js +0 -68
- package/dist/ui/getCommitsWithoutBackports.test.d.ts +0 -1
- package/dist/ui/getCommitsWithoutBackports.test.js +0 -335
- package/dist/ui/getGitConfigAuthor.d.ts +0 -6
- package/dist/ui/getGitConfigAuthor.js +0 -15
- package/dist/ui/getTargetBranches.d.ts +0 -5
- package/dist/ui/getTargetBranches.js +0 -67
- package/dist/ui/getTargetBranches.test.d.ts +0 -1
- package/dist/ui/getTargetBranches.test.js +0 -204
- package/dist/ui/maybeSetupRepo.d.ts +0 -2
- package/dist/ui/maybeSetupRepo.js +0 -53
- package/dist/ui/maybeSetupRepo.test.d.ts +0 -1
- package/dist/ui/maybeSetupRepo.test.js +0 -238
- package/dist/ui/ora.d.ts +0 -2
- package/dist/ui/ora.js +0 -21
- package/dist/ui/setupRepo.d.ts +0 -2
- package/dist/ui/setupRepo.js +0 -56
- package/dist/ui/setupRepo.test.d.ts +0 -1
- package/dist/ui/setupRepo.test.js +0 -273
- package/dist/utils/filterMissingCommits.d.ts +0 -2
- package/dist/utils/filterMissingCommits.js +0 -7
- package/dist/utils/redact.d.ts +0 -1
- package/dist/utils/redact.js +0 -7
package/dist/lib/git.test.js
CHANGED
|
@@ -238,6 +238,7 @@ describe('createBackportBranch', () => {
|
|
|
238
238
|
repoOwner: 'elastic',
|
|
239
239
|
repoName: 'kibana',
|
|
240
240
|
};
|
|
241
|
+
const sourceBranch = 'main';
|
|
241
242
|
const targetBranch = '4.x';
|
|
242
243
|
const backportBranch = 'backport/4.x/commit-72f94e76';
|
|
243
244
|
it(`should handle "couldn't find remote ref" error`, async () => {
|
|
@@ -249,7 +250,12 @@ describe('createBackportBranch', () => {
|
|
|
249
250
|
stderr: "fatal: couldn't find remote ref 4.x\n",
|
|
250
251
|
});
|
|
251
252
|
jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
|
|
252
|
-
await expect((0, git_1.createBackportBranch)({
|
|
253
|
+
await expect((0, git_1.createBackportBranch)({
|
|
254
|
+
options,
|
|
255
|
+
sourceBranch,
|
|
256
|
+
targetBranch,
|
|
257
|
+
backportBranch,
|
|
258
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`"The branch \\"4.x\\" is invalid or doesn't exist"`);
|
|
253
259
|
});
|
|
254
260
|
it('should throw "Invalid refspec" error', async () => {
|
|
255
261
|
expect.assertions(1);
|
|
@@ -260,14 +266,24 @@ describe('createBackportBranch', () => {
|
|
|
260
266
|
stderr: "fatal: Invalid refspec 'https://github.com/elastic/kibana.git'\n",
|
|
261
267
|
});
|
|
262
268
|
jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
|
|
263
|
-
await expect((0, git_1.createBackportBranch)({
|
|
269
|
+
await expect((0, git_1.createBackportBranch)({
|
|
270
|
+
options,
|
|
271
|
+
sourceBranch,
|
|
272
|
+
targetBranch,
|
|
273
|
+
backportBranch,
|
|
274
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`"The branch \\"4.x\\" is invalid or doesn't exist"`);
|
|
264
275
|
});
|
|
265
276
|
it('should rethrow normal error', async () => {
|
|
266
277
|
expect.assertions(1);
|
|
267
278
|
const err = new Error('just a normal error');
|
|
268
279
|
jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
|
|
269
280
|
expect.assertions(1);
|
|
270
|
-
await expect((0, git_1.createBackportBranch)({
|
|
281
|
+
await expect((0, git_1.createBackportBranch)({
|
|
282
|
+
options,
|
|
283
|
+
sourceBranch,
|
|
284
|
+
targetBranch,
|
|
285
|
+
backportBranch,
|
|
286
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`"just a normal error"`);
|
|
271
287
|
});
|
|
272
288
|
});
|
|
273
289
|
describe('deleteRemote', () => {
|
|
@@ -301,8 +317,7 @@ describe('cherrypick', () => {
|
|
|
301
317
|
it('should return `needsResolving: false` when no errors are encountered', async () => {
|
|
302
318
|
jest
|
|
303
319
|
.spyOn(childProcess, 'spawnPromise')
|
|
304
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }) // mock
|
|
305
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }); // mock cherrypick(...)
|
|
320
|
+
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }); // mock `git cherrypick`
|
|
306
321
|
expect(await (0, git_1.cherrypick)({
|
|
307
322
|
options,
|
|
308
323
|
sha: 'abcd',
|
|
@@ -316,8 +331,7 @@ describe('cherrypick', () => {
|
|
|
316
331
|
it('should use mainline option when specified', async () => {
|
|
317
332
|
const spawnSpy = jest
|
|
318
333
|
.spyOn(childProcess, 'spawnPromise')
|
|
319
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }) // mock
|
|
320
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }); // mock cherrypick(...)
|
|
334
|
+
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }); // mock `git cherrypick`
|
|
321
335
|
await (0, git_1.cherrypick)({
|
|
322
336
|
options: { ...options, mainline: 1 },
|
|
323
337
|
sha: 'abcd',
|
|
@@ -340,10 +354,34 @@ describe('cherrypick', () => {
|
|
|
340
354
|
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
341
355
|
]);
|
|
342
356
|
});
|
|
357
|
+
it('should use signoff option when specified', async () => {
|
|
358
|
+
const spawnSpy = jest
|
|
359
|
+
.spyOn(childProcess, 'spawnPromise')
|
|
360
|
+
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }); // mock `git cherrypick`
|
|
361
|
+
await (0, git_1.cherrypick)({
|
|
362
|
+
options: { ...options, signoff: true },
|
|
363
|
+
sha: 'abcd',
|
|
364
|
+
commitAuthor,
|
|
365
|
+
});
|
|
366
|
+
const args = spawnSpy.mock.calls[0];
|
|
367
|
+
expect(args).toEqual([
|
|
368
|
+
'git',
|
|
369
|
+
[
|
|
370
|
+
'-c',
|
|
371
|
+
'user.name="Soren L"',
|
|
372
|
+
'-c',
|
|
373
|
+
'user.email="soren@mail.dk"',
|
|
374
|
+
'cherry-pick',
|
|
375
|
+
'-x',
|
|
376
|
+
'--signoff',
|
|
377
|
+
'abcd',
|
|
378
|
+
],
|
|
379
|
+
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
380
|
+
]);
|
|
381
|
+
});
|
|
343
382
|
it('should return `needsResolving: true` upon cherrypick error', async () => {
|
|
344
383
|
jest
|
|
345
384
|
.spyOn(childProcess, 'spawnPromise')
|
|
346
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }) // mock getIsMergeCommit(...)
|
|
347
385
|
// mock `git cherrypick`
|
|
348
386
|
.mockRejectedValueOnce(new childProcess.SpawnError({
|
|
349
387
|
code: 128,
|
|
@@ -378,8 +416,6 @@ describe('cherrypick', () => {
|
|
|
378
416
|
it('should let the user know about the "--mainline" argument when cherry-picking a merge commit without specifying it', async () => {
|
|
379
417
|
jest
|
|
380
418
|
.spyOn(childProcess, 'spawnPromise')
|
|
381
|
-
// mock getIsMergeCommit(...)
|
|
382
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] })
|
|
383
419
|
// mock cherry pick command
|
|
384
420
|
.mockRejectedValueOnce(new childProcess.SpawnError({
|
|
385
421
|
code: 128,
|
|
@@ -405,8 +441,6 @@ Or refer to the git documentation for more information: https://git-scm.com/docs
|
|
|
405
441
|
it('should gracefully handle empty commits', async () => {
|
|
406
442
|
jest
|
|
407
443
|
.spyOn(childProcess, 'spawnPromise')
|
|
408
|
-
// mock getIsMergeCommit(...)
|
|
409
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] })
|
|
410
444
|
// mock cherry pick command
|
|
411
445
|
.mockRejectedValueOnce(new childProcess.SpawnError({
|
|
412
446
|
code: 1,
|
|
@@ -423,8 +457,6 @@ Or refer to the git documentation for more information: https://git-scm.com/docs
|
|
|
423
457
|
it('should re-throw non-cherrypick errors', async () => {
|
|
424
458
|
jest
|
|
425
459
|
.spyOn(childProcess, 'spawnPromise')
|
|
426
|
-
// mock getIsMergeCommit(...)
|
|
427
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] })
|
|
428
460
|
// mock cherry pick command
|
|
429
461
|
.mockRejectedValueOnce(new Error('non-cherrypick error'))
|
|
430
462
|
// getConflictingFiles
|
|
@@ -574,7 +606,7 @@ describe('pushBackportBranch', () => {
|
|
|
574
606
|
await expect((0, git_1.pushBackportBranch)({ options, backportBranch })).rejects
|
|
575
607
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
576
608
|
"Error pushing to https://github.com/the_fork_owner/kibana. Repository does not exist. Either fork the repository (https://github.com/elastic/kibana) or disable fork mode via \\"--no-fork\\".
|
|
577
|
-
Read more about fork mode in the docs: https://github.com/sqren/backport/blob/main/docs/
|
|
609
|
+
Read more about fork mode in the docs: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#fork"
|
|
578
610
|
`);
|
|
579
611
|
});
|
|
580
612
|
});
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getQueryName = exports.GithubV4Exception = exports.apiRequestV4 = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const printer_1 = require("graphql/language/printer");
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
9
10
|
const BackportError_1 = require("../../BackportError");
|
|
10
11
|
const logger_1 = require("../../logger");
|
|
11
12
|
async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graphql', accessToken, query, variables, }) {
|
|
@@ -28,7 +29,7 @@ async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graph
|
|
|
28
29
|
return response.data.data;
|
|
29
30
|
}
|
|
30
31
|
catch (e) {
|
|
31
|
-
if (
|
|
32
|
+
if (isAxiosGithubError(e) && e.response) {
|
|
32
33
|
addDebugLogs({
|
|
33
34
|
githubApiBaseUrlV4,
|
|
34
35
|
query,
|
|
@@ -42,13 +43,10 @@ async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graph
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
exports.apiRequestV4 = apiRequestV4;
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
logger_1.logger.verbose('Variables:', variables);
|
|
50
|
-
logger_1.logger.verbose('Response headers:', githubResponse.headers);
|
|
51
|
-
logger_1.logger.verbose('Response data:', githubResponse.data);
|
|
46
|
+
function isAxiosGithubError(e) {
|
|
47
|
+
return (axios_1.default.isAxiosError(e) &&
|
|
48
|
+
e.response !== undefined &&
|
|
49
|
+
(0, lodash_1.isObject)(e.response.data));
|
|
52
50
|
}
|
|
53
51
|
class GithubV4Exception extends Error {
|
|
54
52
|
constructor(githubResponse, errorMessage) {
|
|
@@ -69,3 +67,11 @@ function getQueryName(query) {
|
|
|
69
67
|
return query.definitions[0].name?.value;
|
|
70
68
|
}
|
|
71
69
|
exports.getQueryName = getQueryName;
|
|
70
|
+
function addDebugLogs({ githubApiBaseUrlV4, query, variables, githubResponse, didThrow = false, }) {
|
|
71
|
+
const gqlQueryName = getQueryName(query);
|
|
72
|
+
logger_1.logger.info(`POST ${githubApiBaseUrlV4} (name:${gqlQueryName}, status: ${githubResponse.status}${didThrow ? ', EXCEPTION THROWN' : ''})`);
|
|
73
|
+
logger_1.logger.verbose(`Query: ${(0, printer_1.print)(query)}`);
|
|
74
|
+
logger_1.logger.verbose('Variables:', variables);
|
|
75
|
+
logger_1.logger.verbose('Response headers:', githubResponse.headers);
|
|
76
|
+
logger_1.logger.verbose('Response data:', githubResponse.data);
|
|
77
|
+
}
|
|
@@ -6,6 +6,7 @@ const fetchCommitBySha_1 = require("./fetchCommitBySha");
|
|
|
6
6
|
const fetchCommitsByAuthor_1 = require("./fetchCommitsByAuthor");
|
|
7
7
|
const fetchPullRequestsBySearchQuery_1 = require("./fetchPullRequestsBySearchQuery");
|
|
8
8
|
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
|
+
jest.setTimeout(15000);
|
|
9
10
|
describe('allFetchers', () => {
|
|
10
11
|
let commitByAuthor;
|
|
11
12
|
beforeEach(async () => {
|
|
@@ -61,6 +61,7 @@ export declare function getOptionsFromGithub(options: {
|
|
|
61
61
|
targetBranchChoices?: import("../../../../options/ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
62
62
|
targetBranches?: string[] | undefined;
|
|
63
63
|
targetPRLabels?: string[] | undefined;
|
|
64
|
+
signoff?: boolean | undefined;
|
|
64
65
|
help?: boolean | undefined;
|
|
65
66
|
version?: boolean | undefined;
|
|
66
67
|
v?: boolean | undefined;
|
package/dist/lib/ora.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare function getOptionsFromCliArgs(processArgs: readonly string[]): {
|
|
|
28
28
|
gitAuthorEmail?: string | undefined;
|
|
29
29
|
ls?: boolean | undefined;
|
|
30
30
|
mainline?: number | undefined;
|
|
31
|
+
signoff?: boolean | undefined;
|
|
31
32
|
maxNumber?: number | undefined;
|
|
32
33
|
multipleBranches?: boolean | undefined;
|
|
33
34
|
multipleCommits?: boolean | undefined;
|
package/dist/options/cliArgs.js
CHANGED
|
@@ -176,6 +176,11 @@ function getOptionsFromCliArgs(processArgs) {
|
|
|
176
176
|
// Invalid value provided
|
|
177
177
|
throw new Error(`--mainline must be an integer. Received: ${mainline}`);
|
|
178
178
|
},
|
|
179
|
+
})
|
|
180
|
+
.option('signoff', {
|
|
181
|
+
description: 'Pass the --signoff option to the cherry-pick command',
|
|
182
|
+
type: 'boolean',
|
|
183
|
+
alias: ['s'],
|
|
179
184
|
})
|
|
180
185
|
// display 10 commits to pick from
|
|
181
186
|
.option('maxNumber', {
|
|
@@ -58,6 +58,7 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
|
|
|
58
58
|
targetBranchChoices?: import("../ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
59
59
|
targetBranches?: string[] | undefined;
|
|
60
60
|
targetPRLabels?: string[] | undefined;
|
|
61
|
+
signoff?: boolean | undefined;
|
|
61
62
|
help?: boolean | undefined;
|
|
62
63
|
version?: boolean | undefined;
|
|
63
64
|
v?: boolean | undefined;
|
|
@@ -24,6 +24,7 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
|
|
|
24
24
|
gitAuthorName?: string | undefined;
|
|
25
25
|
gitAuthorEmail?: string | undefined;
|
|
26
26
|
ls?: boolean | undefined;
|
|
27
|
+
signoff?: boolean | undefined;
|
|
27
28
|
maxNumber?: number | undefined;
|
|
28
29
|
multiple?: boolean | undefined;
|
|
29
30
|
multipleBranches?: boolean | undefined;
|
|
@@ -29,6 +29,7 @@ export declare const defaultConfigOptions: {
|
|
|
29
29
|
targetBranchChoices: TargetBranchChoiceOrString[];
|
|
30
30
|
targetBranches: string[];
|
|
31
31
|
targetPRLabels: string[];
|
|
32
|
+
signoff: boolean;
|
|
32
33
|
};
|
|
33
34
|
export declare function getOptions({ optionsFromCliArgs, optionsFromModule, }: {
|
|
34
35
|
optionsFromCliArgs: OptionsFromCliArgs;
|
|
@@ -63,6 +64,7 @@ export declare function getOptions({ optionsFromCliArgs, optionsFromModule, }: {
|
|
|
63
64
|
gitAuthorEmail?: string | undefined;
|
|
64
65
|
ls?: boolean | undefined;
|
|
65
66
|
mainline?: number | undefined;
|
|
67
|
+
signoff: boolean;
|
|
66
68
|
maxNumber: number;
|
|
67
69
|
multipleBranches: boolean;
|
|
68
70
|
multipleCommits: boolean;
|
package/dist/options/options.js
CHANGED
|
@@ -8,8 +8,8 @@ const getOptionsFromGithub_1 = require("../lib/github/v4/getOptionsFromGithub/ge
|
|
|
8
8
|
const getRepoOwnerAndNameFromGitRemotes_1 = require("../lib/github/v4/getRepoOwnerAndNameFromGitRemotes");
|
|
9
9
|
const logger_1 = require("../lib/logger");
|
|
10
10
|
const config_1 = require("./config/config");
|
|
11
|
-
const PROJECT_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/
|
|
12
|
-
const GLOBAL_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/
|
|
11
|
+
const PROJECT_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/config-file-options.md#project-config-backportrcjson';
|
|
12
|
+
const GLOBAL_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/config-file-options.md#global-config-backportconfigjson';
|
|
13
13
|
exports.defaultConfigOptions = {
|
|
14
14
|
assignees: [],
|
|
15
15
|
autoAssign: false,
|
|
@@ -38,6 +38,7 @@ exports.defaultConfigOptions = {
|
|
|
38
38
|
targetBranchChoices: [],
|
|
39
39
|
targetBranches: [],
|
|
40
40
|
targetPRLabels: [],
|
|
41
|
+
signoff: false,
|
|
41
42
|
};
|
|
42
43
|
async function getOptions({ optionsFromCliArgs, optionsFromModule, }) {
|
|
43
44
|
const optionsFromConfigFiles = await (0, config_1.getOptionsFromConfigFiles)({
|
|
@@ -71,7 +71,7 @@ describe('getOptions', () => {
|
|
|
71
71
|
"Please update your config file: \\"/myHomeDir/.backport/config.json\\".
|
|
72
72
|
It must contain a valid \\"accessToken\\".
|
|
73
73
|
|
|
74
|
-
Read more: https://github.com/sqren/backport/blob/main/docs/
|
|
74
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#global-config-backportconfigjson"
|
|
75
75
|
`);
|
|
76
76
|
});
|
|
77
77
|
it('when `targetBranches`, `targetBranchChoices` and `branchLabelMapping` are all empty', async () => {
|
|
@@ -83,7 +83,7 @@ describe('getOptions', () => {
|
|
|
83
83
|
await expect(() => (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
84
84
|
"Please specify a target branch: \\"--branch 6.1\\".
|
|
85
85
|
|
|
86
|
-
Read more: https://github.com/sqren/backport/blob/main/docs/
|
|
86
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#project-config-backportrcjson"
|
|
87
87
|
`);
|
|
88
88
|
});
|
|
89
89
|
describe('whe option is an empty string', () => {
|
|
@@ -107,7 +107,7 @@ describe('getOptions', () => {
|
|
|
107
107
|
"Please update your config file: \\"/myHomeDir/.backport/config.json\\".
|
|
108
108
|
It must contain a valid \\"accessToken\\".
|
|
109
109
|
|
|
110
|
-
Read more: https://github.com/sqren/backport/blob/main/docs/
|
|
110
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#global-config-backportconfigjson"
|
|
111
111
|
`);
|
|
112
112
|
});
|
|
113
113
|
});
|
|
@@ -120,7 +120,7 @@ describe('getOptions', () => {
|
|
|
120
120
|
await expect(() => (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
121
121
|
"Please specify a repository: \\"--repo elastic/kibana\\".
|
|
122
122
|
|
|
123
|
-
Read more: https://github.com/sqren/backport/blob/main/docs/
|
|
123
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#project-config-backportrcjson"
|
|
124
124
|
`);
|
|
125
125
|
});
|
|
126
126
|
it('should get repoName from the remote', async () => {
|
|
@@ -212,6 +212,7 @@ describe('getOptions', () => {
|
|
|
212
212
|
repoOwner: 'elastic',
|
|
213
213
|
resetAuthor: false,
|
|
214
214
|
reviewers: [],
|
|
215
|
+
signoff: false,
|
|
215
216
|
sourceBranch: 'default-branch-from-github',
|
|
216
217
|
sourcePRLabels: [],
|
|
217
218
|
targetBranchChoices: ['7.9', '8.0'],
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const getDevAccessToken_1 = require("../../private/getDevAccessToken");
|
|
4
4
|
const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
5
5
|
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
6
|
+
jest.setTimeout(15000);
|
|
6
7
|
describe('date filters (dateSince, dateUntil)', () => {
|
|
7
8
|
it(`filters commits by "since" and "until"`, async () => {
|
|
8
9
|
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
3
7
|
const child_process_promisified_1 = require("../../../lib/child-process-promisified");
|
|
4
8
|
const getDevAccessToken_1 = require("../../private/getDevAccessToken");
|
|
9
|
+
const replaceStringAndLinebreaks_1 = require("../../replaceStringAndLinebreaks");
|
|
5
10
|
const sandbox_1 = require("../../sandbox");
|
|
6
11
|
const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
7
12
|
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
13
|
+
jest.setTimeout(40000);
|
|
8
14
|
describe('different-merge-strategies', () => {
|
|
9
15
|
it('list all commits regardless how they were merged', async () => {
|
|
10
16
|
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
@@ -24,8 +30,8 @@ describe('different-merge-strategies', () => {
|
|
|
24
30
|
7. Merge strategy: Third of many merges
|
|
25
31
|
8. Merge strategy: Second of many merges
|
|
26
32
|
9. Merge strategy: First of many merges
|
|
27
|
-
10.Using squash to merge commits (#3)
|
|
28
|
-
11.Rebase strategy: Second commit
|
|
33
|
+
10.Using squash to merge commits (#3)
|
|
34
|
+
11.Rebase strategy: Second commit
|
|
29
35
|
12.Rebase strategy: First commit
|
|
30
36
|
13.Merge pull request #1 from backport-org/merge-strategy
|
|
31
37
|
14.Merge strategy: Second commit
|
|
@@ -33,7 +39,7 @@ describe('different-merge-strategies', () => {
|
|
|
33
39
|
16.Initial commit"
|
|
34
40
|
`);
|
|
35
41
|
});
|
|
36
|
-
describe('when selecting a merge commit', () => {
|
|
42
|
+
describe('when selecting a merge commit with eight commits', () => {
|
|
37
43
|
let output;
|
|
38
44
|
let sandboxPath;
|
|
39
45
|
beforeAll(async () => {
|
|
@@ -58,8 +64,22 @@ describe('different-merge-strategies', () => {
|
|
|
58
64
|
Backporting to 7.x:
|
|
59
65
|
- Pulling latest changes
|
|
60
66
|
✔ Pulling latest changes
|
|
61
|
-
- Cherry-picking: Merge
|
|
62
|
-
✔ Cherry-picking: Merge
|
|
67
|
+
- Cherry-picking: Merge strategy: First of many merges
|
|
68
|
+
✔ Cherry-picking: Merge strategy: First of many merges
|
|
69
|
+
- Cherry-picking: Merge strategy: Second of many merges
|
|
70
|
+
✔ Cherry-picking: Merge strategy: Second of many merges
|
|
71
|
+
- Cherry-picking: Merge strategy: Third of many merges
|
|
72
|
+
✔ Cherry-picking: Merge strategy: Third of many merges
|
|
73
|
+
- Cherry-picking: Merge strategy: Fourth of many merges
|
|
74
|
+
✔ Cherry-picking: Merge strategy: Fourth of many merges
|
|
75
|
+
- Cherry-picking: Merge strategy: Fifth of many merges
|
|
76
|
+
✔ Cherry-picking: Merge strategy: Fifth of many merges
|
|
77
|
+
- Cherry-picking: Merge strategy: Sixth of many merges
|
|
78
|
+
✔ Cherry-picking: Merge strategy: Sixth of many merges
|
|
79
|
+
- Cherry-picking: Merge strategy: Seventh of many merges
|
|
80
|
+
✔ Cherry-picking: Merge strategy: Seventh of many merges
|
|
81
|
+
- Cherry-picking: Merge strategy: Eighth of many merges
|
|
82
|
+
✔ Cherry-picking: Merge strategy: Eighth of many merges
|
|
63
83
|
✔ Dry run complete"
|
|
64
84
|
`);
|
|
65
85
|
});
|
|
@@ -78,7 +98,7 @@ describe('different-merge-strategies', () => {
|
|
|
78
98
|
]);
|
|
79
99
|
});
|
|
80
100
|
});
|
|
81
|
-
describe('when selecting
|
|
101
|
+
describe('when selecting a merge commit with two commits', () => {
|
|
82
102
|
let sandboxPath;
|
|
83
103
|
beforeAll(async () => {
|
|
84
104
|
sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
@@ -101,6 +121,102 @@ describe('different-merge-strategies', () => {
|
|
|
101
121
|
]);
|
|
102
122
|
});
|
|
103
123
|
});
|
|
124
|
+
describe('when selecting a merge commit with eight commits and a conflict occurs', () => {
|
|
125
|
+
let sandboxPath;
|
|
126
|
+
let output;
|
|
127
|
+
beforeAll(async () => {
|
|
128
|
+
sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
129
|
+
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
130
|
+
const proc = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
131
|
+
'--branch=7.1',
|
|
132
|
+
'--repo=backport-org/different-merge-strategies',
|
|
133
|
+
`--accessToken=${accessToken}`,
|
|
134
|
+
`--dir=${sandboxPath}`,
|
|
135
|
+
'--pr=9',
|
|
136
|
+
'--dry-run',
|
|
137
|
+
], {
|
|
138
|
+
keepAlive: true,
|
|
139
|
+
timeoutSeconds: 5,
|
|
140
|
+
showOra: true,
|
|
141
|
+
waitForString: 'Press ENTER when the conflicts are resolved and files are staged',
|
|
142
|
+
});
|
|
143
|
+
await (0, child_process_promisified_1.exec)(`git status`, { cwd: sandboxPath });
|
|
144
|
+
await promises_1.default.writeFile(`${sandboxPath}/new-file-added-with-many-merge-commits.txt`, `File added directly to 7.1 to cause merge conflict\nPrevious merge commit didn't have enough commits\n`);
|
|
145
|
+
await (0, child_process_promisified_1.exec)(`git add -A`, { cwd: sandboxPath });
|
|
146
|
+
const res = await proc.keypress('enter', {
|
|
147
|
+
showOra: true,
|
|
148
|
+
timeoutSeconds: 5,
|
|
149
|
+
});
|
|
150
|
+
output = (0, replaceStringAndLinebreaks_1.replaceStringAndLinebreaks)({
|
|
151
|
+
haystack: res.output,
|
|
152
|
+
stringBefore: sandboxPath,
|
|
153
|
+
stringAfter: '<SANDBOX_PATH>',
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
it('has the right output', async () => {
|
|
157
|
+
expect(output).toMatchInlineSnapshot(`
|
|
158
|
+
"- Initializing...
|
|
159
|
+
? Select pull request Merge pull request #9 from backport-org/many-merge-commits
|
|
160
|
+
✔ 100% Cloning repository from github.com (one-time operation)
|
|
161
|
+
|
|
162
|
+
Backporting to 7.1:
|
|
163
|
+
- Pulling latest changes
|
|
164
|
+
✔ Pulling latest changes
|
|
165
|
+
- Cherry-picking: Merge strategy: First of many merges
|
|
166
|
+
✖ Cherry-picking: Merge strategy: First of many merges
|
|
167
|
+
|
|
168
|
+
The commit could not be backported due to conflicts
|
|
169
|
+
|
|
170
|
+
Please fix the conflicts in <SANDBOX_PATH>
|
|
171
|
+
? Fix the following conflicts manually:
|
|
172
|
+
|
|
173
|
+
Conflicting files:
|
|
174
|
+
- <SANDBOX_PATH>/new-fi
|
|
175
|
+
le-added-with-many-merge-commits.txt
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
Press ENTER when the conflicts are resolved and files are staged (Y/n) ? Fix the following conflicts manually:
|
|
179
|
+
|
|
180
|
+
Conflicting files:
|
|
181
|
+
- <SANDBOX_PATH>/new-fi
|
|
182
|
+
le-added-with-many-merge-commits.txt
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
Press ENTER when the conflicts are resolved and files are staged Yes
|
|
186
|
+
✔ Cherry-picking: Merge strategy: First of many merges
|
|
187
|
+
- Cherry-picking: Merge strategy: Second of many merges
|
|
188
|
+
✔ Cherry-picking: Merge strategy: Second of many merges
|
|
189
|
+
- Cherry-picking: Merge strategy: Third of many merges
|
|
190
|
+
✔ Cherry-picking: Merge strategy: Third of many merges
|
|
191
|
+
- Cherry-picking: Merge strategy: Fourth of many merges
|
|
192
|
+
✔ Cherry-picking: Merge strategy: Fourth of many merges
|
|
193
|
+
- Cherry-picking: Merge strategy: Fifth of many merges
|
|
194
|
+
✔ Cherry-picking: Merge strategy: Fifth of many merges
|
|
195
|
+
- Cherry-picking: Merge strategy: Sixth of many merges
|
|
196
|
+
✔ Cherry-picking: Merge strategy: Sixth of many merges
|
|
197
|
+
- Cherry-picking: Merge strategy: Seventh of many merges
|
|
198
|
+
✔ Cherry-picking: Merge strategy: Seventh of many merges
|
|
199
|
+
- Cherry-picking: Merge strategy: Eighth of many merges
|
|
200
|
+
✔ Cherry-picking: Merge strategy: Eighth of many merges
|
|
201
|
+
✔ Dry run complete"
|
|
202
|
+
`);
|
|
203
|
+
});
|
|
204
|
+
it('backports all immediate children of the merge commit', async () => {
|
|
205
|
+
const commits = await listCommits(sandboxPath);
|
|
206
|
+
expect(commits).toEqual([
|
|
207
|
+
'Merge strategy: Eighth of many merges',
|
|
208
|
+
'Merge strategy: Seventh of many merges',
|
|
209
|
+
'Merge strategy: Sixth of many merges',
|
|
210
|
+
'Merge strategy: Fifth of many merges',
|
|
211
|
+
'Merge strategy: Fourth of many merges',
|
|
212
|
+
'Merge strategy: Third of many merges',
|
|
213
|
+
'Merge strategy: Second of many merges',
|
|
214
|
+
'Merge strategy: First of many merges',
|
|
215
|
+
'Create new-file-added-with-many-merge-commits.txt',
|
|
216
|
+
'Initial commit',
|
|
217
|
+
]);
|
|
218
|
+
});
|
|
219
|
+
});
|
|
104
220
|
});
|
|
105
221
|
async function listCommits(sandboxPath) {
|
|
106
222
|
const { stdout } = await (0, child_process_promisified_1.exec)('git --no-pager log --pretty=format:%s', {
|
|
@@ -82,6 +82,8 @@ describe('entrypoint cli', () => {
|
|
|
82
82
|
--ls List commits instead of backporting them [boolean]
|
|
83
83
|
--mainline Parent id of merge commit. Defaults to 1 when supplied
|
|
84
84
|
without arguments [number]
|
|
85
|
+
-s, --signoff Pass the --signoff option to the cherry-pick command
|
|
86
|
+
[boolean]
|
|
85
87
|
-n, --maxNumber, --number Number of commits to choose from [number]
|
|
86
88
|
--multiple Select multiple branches/commits [boolean]
|
|
87
89
|
--multipleBranches Backport to multiple branches [boolean]
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const getDevAccessToken_1 = require("../../private/getDevAccessToken");
|
|
4
|
+
const replaceStringAndLinebreaks_1 = require("../../replaceStringAndLinebreaks");
|
|
4
5
|
const sandbox_1 = require("../../sandbox");
|
|
5
6
|
const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
6
7
|
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
8
|
+
jest.setTimeout(15000);
|
|
7
9
|
describe('interactive error handling', () => {
|
|
8
10
|
it('when branch is missing', async () => {
|
|
9
11
|
const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
@@ -14,7 +16,7 @@ describe('interactive error handling', () => {
|
|
|
14
16
|
expect(output).toMatchInlineSnapshot(`
|
|
15
17
|
"Please specify a target branch: \\"--branch 6.1\\".
|
|
16
18
|
|
|
17
|
-
Read more: https://github.com/sqren/backport/blob/main/docs/
|
|
19
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#project-config-backportrcjson"
|
|
18
20
|
`);
|
|
19
21
|
});
|
|
20
22
|
it('when supplying invalid argument', async () => {
|
|
@@ -64,17 +66,29 @@ describe('interactive error handling', () => {
|
|
|
64
66
|
waitForString: 'Press ENTER when the conflicts',
|
|
65
67
|
timeoutSeconds: 5,
|
|
66
68
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
69
|
+
expect((0, replaceStringAndLinebreaks_1.replaceStringAndLinebreaks)({
|
|
70
|
+
haystack: output,
|
|
71
|
+
stringBefore: backportDir,
|
|
72
|
+
stringAfter: '<BACKPORT_DIR>',
|
|
73
|
+
})).toMatchInlineSnapshot(`
|
|
74
|
+
"Backporting to 7.x:
|
|
75
|
+
|
|
76
|
+
The commit could not be backported due to conflicts
|
|
77
|
+
|
|
78
|
+
Please fix the conflicts in <BACKPORT_DIR>
|
|
79
|
+
Hint: Before fixing the conflicts manually you should consider backporting the following pull requests to \\"7.x\\":
|
|
80
|
+
- Change Barca to Braithwaite (#8) (backport missing)
|
|
81
|
+
https://github.com/backport-org/repo-with-conflicts/pull/8
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
? Fix the following conflicts manually:
|
|
85
|
+
|
|
86
|
+
Conflicting files:
|
|
87
|
+
- <BACKPORT_DIR>/l
|
|
88
|
+
a-liga.md
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
Press ENTER when the conflicts are resolved and files are staged (Y/n)"
|
|
92
|
+
`);
|
|
79
93
|
});
|
|
80
94
|
});
|
|
@@ -9,6 +9,7 @@ const getDevAccessToken_1 = require("../../private/getDevAccessToken");
|
|
|
9
9
|
const sandbox_1 = require("../../sandbox");
|
|
10
10
|
const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
11
11
|
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
12
|
+
jest.setTimeout(15000);
|
|
12
13
|
describe('non interactive (json) error handling', () => {
|
|
13
14
|
it(`when access token is missing`, async () => {
|
|
14
15
|
const configFilePath = await createConfigFile({ editor: 'code' });
|
|
@@ -25,7 +26,7 @@ describe('non interactive (json) error handling', () => {
|
|
|
25
26
|
"Please update your config file: \\"<GLOBAL_CONFIG_FILE>\\".
|
|
26
27
|
It must contain a valid \\"accessToken\\".
|
|
27
28
|
|
|
28
|
-
Read more: https://github.com/sqren/backport/blob/main/docs/
|
|
29
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#global-config-backportconfigjson"
|
|
29
30
|
`);
|
|
30
31
|
});
|
|
31
32
|
it('when target branches cannot be inferred from pull request', async () => {
|
|
@@ -55,7 +56,7 @@ describe('non interactive (json) error handling', () => {
|
|
|
55
56
|
expect(backportResult.errorMessage).toMatchInlineSnapshot(`
|
|
56
57
|
"Please specify a target branch: \\"--branch 6.1\\".
|
|
57
58
|
|
|
58
|
-
Read more: https://github.com/sqren/backport/blob/main/docs/
|
|
59
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#project-config-backportrcjson"
|
|
59
60
|
`);
|
|
60
61
|
});
|
|
61
62
|
it(`when argument is invalid`, async () => {
|
|
File without changes
|