backport 8.3.0 → 8.4.1
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/backportRun.js +1 -1
- package/dist/entrypoint.module.d.ts +2 -2
- package/dist/entrypoint.module.js +2 -0
- package/dist/entrypoint.module.private.test.js +11 -10
- package/dist/lib/cherrypickAndCreateTargetPullRequest.js +30 -20
- package/dist/lib/child-process-promisified.js +2 -2
- package/dist/lib/getCommits.js +1 -1
- package/dist/lib/git.d.ts +1 -1
- package/dist/lib/git.js +8 -28
- package/dist/lib/git.private.test.js +7 -7
- package/dist/lib/git.test.js +28 -12
- package/dist/lib/github/v3/createStatusComment.js +3 -2
- package/dist/lib/github/v3/createStatusComment.test.js +61 -0
- package/dist/lib/github/v4/apiRequestV4.js +1 -1
- package/dist/lib/github/v4/enablePullRequestAutoMerge.js +2 -1
- package/dist/{entrypoint.cli.private.test.d.ts → lib/github/v4/enablePullRequestAutoMerge.mutation.test.d.ts} +0 -0
- package/dist/lib/github/v4/{enablePullRequestAutoMerge.private.test.js → enablePullRequestAutoMerge.mutation.test.js} +34 -8
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +6 -3
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.js +0 -1
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.js +0 -1
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.js +5 -6
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +7 -3
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +2 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +23 -7
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +2 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +1 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +2 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.d.ts +1 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.js +1 -0
- package/dist/lib/ora.d.ts +1 -0
- package/dist/lib/remoteConfig.d.ts +1 -1
- package/dist/lib/remoteConfig.js +4 -0
- package/dist/options/ConfigOptions.d.ts +1 -0
- package/dist/options/cliArgs.d.ts +3 -2
- package/dist/options/cliArgs.js +21 -6
- package/dist/options/config/config.d.ts +1 -0
- package/dist/options/config/readConfigFile.d.ts +1 -0
- package/dist/options/options.d.ts +5 -2
- package/dist/options/options.js +3 -3
- package/dist/options/options.test.js +7 -4
- package/dist/{lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts → test/e2e/cli/date-filters.private.test.d.ts} +0 -0
- package/dist/test/e2e/cli/date-filters.private.test.js +48 -0
- package/dist/test/e2e/cli/different-merge-strategies.private.test.js +120 -4
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +4 -18
- package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.js +2 -1
- package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.js +3 -2
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +2 -2
- 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 +1 -0
- package/dist/test/e2e/module/entrypoint.module.mutation.test.js +1 -1
- package/dist/test/handleUnbackportedPullRequests.private.test.js +1 -1
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +20 -21
- package/yarn.lock +210 -220
- 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/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/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
|
@@ -301,8 +301,7 @@ describe('cherrypick', () => {
|
|
|
301
301
|
it('should return `needsResolving: false` when no errors are encountered', async () => {
|
|
302
302
|
jest
|
|
303
303
|
.spyOn(childProcess, 'spawnPromise')
|
|
304
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }) // mock
|
|
305
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }); // mock cherrypick(...)
|
|
304
|
+
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }); // mock `git cherrypick`
|
|
306
305
|
expect(await (0, git_1.cherrypick)({
|
|
307
306
|
options,
|
|
308
307
|
sha: 'abcd',
|
|
@@ -316,8 +315,7 @@ describe('cherrypick', () => {
|
|
|
316
315
|
it('should use mainline option when specified', async () => {
|
|
317
316
|
const spawnSpy = jest
|
|
318
317
|
.spyOn(childProcess, 'spawnPromise')
|
|
319
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }) // mock
|
|
320
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }); // mock cherrypick(...)
|
|
318
|
+
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }); // mock `git cherrypick`
|
|
321
319
|
await (0, git_1.cherrypick)({
|
|
322
320
|
options: { ...options, mainline: 1 },
|
|
323
321
|
sha: 'abcd',
|
|
@@ -340,10 +338,34 @@ describe('cherrypick', () => {
|
|
|
340
338
|
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
341
339
|
]);
|
|
342
340
|
});
|
|
341
|
+
it('should use signoff option when specified', async () => {
|
|
342
|
+
const spawnSpy = jest
|
|
343
|
+
.spyOn(childProcess, 'spawnPromise')
|
|
344
|
+
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }); // mock `git cherrypick`
|
|
345
|
+
await (0, git_1.cherrypick)({
|
|
346
|
+
options: { ...options, signoff: true },
|
|
347
|
+
sha: 'abcd',
|
|
348
|
+
commitAuthor,
|
|
349
|
+
});
|
|
350
|
+
const args = spawnSpy.mock.calls[0];
|
|
351
|
+
expect(args).toEqual([
|
|
352
|
+
'git',
|
|
353
|
+
[
|
|
354
|
+
'-c',
|
|
355
|
+
'user.name="Soren L"',
|
|
356
|
+
'-c',
|
|
357
|
+
'user.email="soren@mail.dk"',
|
|
358
|
+
'cherry-pick',
|
|
359
|
+
'-x',
|
|
360
|
+
'--signoff',
|
|
361
|
+
'abcd',
|
|
362
|
+
],
|
|
363
|
+
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
364
|
+
]);
|
|
365
|
+
});
|
|
343
366
|
it('should return `needsResolving: true` upon cherrypick error', async () => {
|
|
344
367
|
jest
|
|
345
368
|
.spyOn(childProcess, 'spawnPromise')
|
|
346
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }) // mock getIsMergeCommit(...)
|
|
347
369
|
// mock `git cherrypick`
|
|
348
370
|
.mockRejectedValueOnce(new childProcess.SpawnError({
|
|
349
371
|
code: 128,
|
|
@@ -378,8 +400,6 @@ describe('cherrypick', () => {
|
|
|
378
400
|
it('should let the user know about the "--mainline" argument when cherry-picking a merge commit without specifying it', async () => {
|
|
379
401
|
jest
|
|
380
402
|
.spyOn(childProcess, 'spawnPromise')
|
|
381
|
-
// mock getIsMergeCommit(...)
|
|
382
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] })
|
|
383
403
|
// mock cherry pick command
|
|
384
404
|
.mockRejectedValueOnce(new childProcess.SpawnError({
|
|
385
405
|
code: 128,
|
|
@@ -405,8 +425,6 @@ Or refer to the git documentation for more information: https://git-scm.com/docs
|
|
|
405
425
|
it('should gracefully handle empty commits', async () => {
|
|
406
426
|
jest
|
|
407
427
|
.spyOn(childProcess, 'spawnPromise')
|
|
408
|
-
// mock getIsMergeCommit(...)
|
|
409
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] })
|
|
410
428
|
// mock cherry pick command
|
|
411
429
|
.mockRejectedValueOnce(new childProcess.SpawnError({
|
|
412
430
|
code: 1,
|
|
@@ -423,8 +441,6 @@ Or refer to the git documentation for more information: https://git-scm.com/docs
|
|
|
423
441
|
it('should re-throw non-cherrypick errors', async () => {
|
|
424
442
|
jest
|
|
425
443
|
.spyOn(childProcess, 'spawnPromise')
|
|
426
|
-
// mock getIsMergeCommit(...)
|
|
427
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] })
|
|
428
444
|
// mock cherry pick command
|
|
429
445
|
.mockRejectedValueOnce(new Error('non-cherrypick error'))
|
|
430
446
|
// getConflictingFiles
|
|
@@ -574,7 +590,7 @@ describe('pushBackportBranch', () => {
|
|
|
574
590
|
await expect((0, git_1.pushBackportBranch)({ options, backportBranch })).rejects
|
|
575
591
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
576
592
|
"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/
|
|
593
|
+
Read more about fork mode in the docs: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#fork"
|
|
578
594
|
`);
|
|
579
595
|
});
|
|
580
596
|
});
|
|
@@ -42,7 +42,7 @@ async function createStatusComment({ options, backportResponse, }) {
|
|
|
42
42
|
}
|
|
43
43
|
exports.createStatusComment = createStatusComment;
|
|
44
44
|
function getCommentBody({ options, pullNumber, backportResponse, }) {
|
|
45
|
-
const { repoName, repoOwner, autoMerge, publishStatusCommentOnAbort, publishStatusCommentOnFailure, publishStatusCommentOnSuccess, } = options;
|
|
45
|
+
const { repoName, repoOwner, autoMerge, isRepoPrivate, publishStatusCommentOnAbort, publishStatusCommentOnFailure, publishStatusCommentOnSuccess, } = options;
|
|
46
46
|
// eg. in addition to `--noStatusComment` add `--noFailureStatusComment` and `--noSuccessStatusComment` where the former will overwrite the two latter
|
|
47
47
|
const didAllBackportsSucceed = backportResponse.status === 'success' &&
|
|
48
48
|
backportResponse.results.every((r) => r.status === 'success');
|
|
@@ -86,10 +86,11 @@ ${manualBackportCommand}${questionsAndLinkToBackport}${packageVersionSection}`;
|
|
|
86
86
|
const tableBody = backportResponse.results
|
|
87
87
|
.map((result) => {
|
|
88
88
|
if (result.status === 'success') {
|
|
89
|
+
const prShield = `[<img src="https://img.shields.io/github/pulls/detail/state/${repoOwner}/${repoName}/${result.pullRequestNumber}">](${result.pullRequestUrl})`;
|
|
89
90
|
return [
|
|
90
91
|
'✅',
|
|
91
92
|
result.targetBranch,
|
|
92
|
-
|
|
93
|
+
isRepoPrivate ? result.pullRequestUrl : prShield,
|
|
93
94
|
];
|
|
94
95
|
}
|
|
95
96
|
if (result.error instanceof BackportError_1.BackportError &&
|
|
@@ -563,4 +563,65 @@ describe('getCommentBody', () => {
|
|
|
563
563
|
expect((0, createStatusComment_1.getCommentBody)(params)).toBe(undefined);
|
|
564
564
|
});
|
|
565
565
|
});
|
|
566
|
+
describe('shield.io badges', () => {
|
|
567
|
+
const getParams = (opts) => ({
|
|
568
|
+
options: {
|
|
569
|
+
interactive: true,
|
|
570
|
+
repoName: 'kibana',
|
|
571
|
+
repoOwner: 'elastic',
|
|
572
|
+
autoMerge: true,
|
|
573
|
+
backportBinary: 'node scripts/backport',
|
|
574
|
+
publishStatusCommentOnSuccess: true,
|
|
575
|
+
...opts,
|
|
576
|
+
},
|
|
577
|
+
pullNumber: 55,
|
|
578
|
+
backportResponse: {
|
|
579
|
+
status: 'success',
|
|
580
|
+
results: [
|
|
581
|
+
{
|
|
582
|
+
status: 'success',
|
|
583
|
+
targetBranch: '7.x',
|
|
584
|
+
pullRequestNumber: 55,
|
|
585
|
+
pullRequestUrl: 'url-to-pr',
|
|
586
|
+
},
|
|
587
|
+
],
|
|
588
|
+
},
|
|
589
|
+
});
|
|
590
|
+
it('posts a comment without shields.io badge when repo is private`', () => {
|
|
591
|
+
const params = getParams({ isRepoPrivate: true });
|
|
592
|
+
expect((0, createStatusComment_1.getCommentBody)(params)).not.toContain('img.shields.io');
|
|
593
|
+
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
594
|
+
"## 💚 All backports created successfully
|
|
595
|
+
|
|
596
|
+
| Status | Branch | Result |
|
|
597
|
+
|:------:|:------:|:------|
|
|
598
|
+
|✅|7.x|url-to-pr|
|
|
599
|
+
|
|
600
|
+
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
601
|
+
|
|
602
|
+
### Questions ?
|
|
603
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
604
|
+
|
|
605
|
+
<!--- Backport version: 1.2.3-mocked -->"
|
|
606
|
+
`);
|
|
607
|
+
});
|
|
608
|
+
it('posts a comment with shields.io badge when repo is public`', () => {
|
|
609
|
+
const params = getParams({ isRepoPrivate: false });
|
|
610
|
+
expect((0, createStatusComment_1.getCommentBody)(params)).toContain('img.shields.io');
|
|
611
|
+
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
612
|
+
"## 💚 All backports created successfully
|
|
613
|
+
|
|
614
|
+
| Status | Branch | Result |
|
|
615
|
+
|:------:|:------:|:------|
|
|
616
|
+
|✅|7.x|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/55\\">](url-to-pr)|
|
|
617
|
+
|
|
618
|
+
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
619
|
+
|
|
620
|
+
### Questions ?
|
|
621
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
622
|
+
|
|
623
|
+
<!--- Backport version: 1.2.3-mocked -->"
|
|
624
|
+
`);
|
|
625
|
+
});
|
|
626
|
+
});
|
|
566
627
|
});
|
|
@@ -45,7 +45,7 @@ exports.apiRequestV4 = apiRequestV4;
|
|
|
45
45
|
function addDebugLogs({ githubApiBaseUrlV4, query, variables, githubResponse, didThrow = false, }) {
|
|
46
46
|
const gqlQueryName = getQueryName(query);
|
|
47
47
|
logger_1.logger.info(`POST ${githubApiBaseUrlV4} (name:${gqlQueryName}, status: ${githubResponse.status}${didThrow ? ', EXCEPTION THROWN' : ''})`);
|
|
48
|
-
logger_1.logger.verbose(`Query: ${query}`);
|
|
48
|
+
logger_1.logger.verbose(`Query: ${(0, printer_1.print)(query)}`);
|
|
49
49
|
logger_1.logger.verbose('Variables:', variables);
|
|
50
50
|
logger_1.logger.verbose('Response headers:', githubResponse.headers);
|
|
51
51
|
logger_1.logger.verbose('Response data:', githubResponse.data);
|
|
@@ -43,8 +43,9 @@ async function enablePullRequestAutoMerge(options, targetPullRequestNumber) {
|
|
|
43
43
|
return res.enablePullRequestAutoMerge.pullRequest?.number;
|
|
44
44
|
}
|
|
45
45
|
catch (e) {
|
|
46
|
+
const err = e;
|
|
46
47
|
spinner.fail();
|
|
47
|
-
logger_1.logger.info(`Could not enable auto merging for ${targetPullRequestNumber}`, e);
|
|
48
|
+
logger_1.logger.info(`Could not enable auto merging for ${targetPullRequestNumber} due to ${err.message}`, e);
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
exports.enablePullRequestAutoMerge = enablePullRequestAutoMerge;
|
|
File without changes
|
|
@@ -15,10 +15,18 @@ const fetchPullRequestAutoMergeMethod_1 = require("./fetchPullRequestAutoMergeMe
|
|
|
15
15
|
// otherwise it will be merged when auto-merge is turned on
|
|
16
16
|
const TEST_REPO_OWNER = 'backport-org';
|
|
17
17
|
const TEST_REPO_NAME = 'repo-with-auto-merge-enabled';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const COMMIT_SHA = '1a88d210f90a22e2a06253c5760909833dc820e9';
|
|
18
|
+
const INITIAL_SHA = '70aa879411e95b6662f8ddcb80a944fc4444579f';
|
|
19
|
+
jest.setTimeout(10000);
|
|
21
20
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
21
|
+
function resetReference(octokit) {
|
|
22
|
+
return octokit.rest.git.updateRef({
|
|
23
|
+
owner: TEST_REPO_OWNER,
|
|
24
|
+
repo: TEST_REPO_NAME,
|
|
25
|
+
ref: 'heads/main',
|
|
26
|
+
sha: INITIAL_SHA,
|
|
27
|
+
force: true,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
22
30
|
async function closePr(octokit, pullNumber) {
|
|
23
31
|
await octokit.pulls.update({
|
|
24
32
|
owner: TEST_REPO_OWNER,
|
|
@@ -29,7 +37,7 @@ async function closePr(octokit, pullNumber) {
|
|
|
29
37
|
}
|
|
30
38
|
async function createPr(options, branchName) {
|
|
31
39
|
const prPayload = {
|
|
32
|
-
base: '
|
|
40
|
+
base: '7.x',
|
|
33
41
|
head: branchName,
|
|
34
42
|
body: 'testing...',
|
|
35
43
|
owner: TEST_REPO_OWNER,
|
|
@@ -54,10 +62,23 @@ async function createBranch(octokit, branchName, sha) {
|
|
|
54
62
|
sha,
|
|
55
63
|
});
|
|
56
64
|
}
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
async function addCommit(octokit) {
|
|
66
|
+
const randomString = Math.random().toString(36).slice(2);
|
|
67
|
+
const res = await octokit.rest.repos.createOrUpdateFileContents({
|
|
68
|
+
owner: TEST_REPO_OWNER,
|
|
69
|
+
repo: TEST_REPO_NAME,
|
|
70
|
+
path: `file-to-change-${randomString}`,
|
|
71
|
+
message: 'Automatically changed',
|
|
72
|
+
content: Buffer.from(`My new hash ${randomString}`).toString('base64'),
|
|
73
|
+
branch: 'main',
|
|
74
|
+
});
|
|
75
|
+
const sha = res.data.commit.sha;
|
|
76
|
+
return sha;
|
|
77
|
+
}
|
|
78
|
+
// Error: cannot have more than 100 pull requests with the same head_sha
|
|
79
|
+
// TODO: have unique head sha for every test run
|
|
59
80
|
// eslint-disable-next-line jest/no-disabled-tests
|
|
60
|
-
describe
|
|
81
|
+
describe('enablePullRequestAutoMerge', () => {
|
|
61
82
|
let pullNumber;
|
|
62
83
|
let branchName;
|
|
63
84
|
let octokit;
|
|
@@ -72,13 +93,18 @@ describe.skip('enablePullRequestAutoMerge', () => {
|
|
|
72
93
|
repoName: TEST_REPO_NAME,
|
|
73
94
|
};
|
|
74
95
|
octokit = new rest_1.Octokit({ auth: accessToken });
|
|
75
|
-
await
|
|
96
|
+
await resetReference(octokit);
|
|
97
|
+
const sha = await addCommit(octokit);
|
|
98
|
+
if (sha) {
|
|
99
|
+
await createBranch(octokit, branchName, sha);
|
|
100
|
+
}
|
|
76
101
|
pullNumber = await createPr(options, branchName);
|
|
77
102
|
});
|
|
78
103
|
// cleanup
|
|
79
104
|
afterAll(async () => {
|
|
80
105
|
await closePr(octokit, pullNumber);
|
|
81
106
|
await deleteBranch(octokit, branchName);
|
|
107
|
+
await resetReference(octokit);
|
|
82
108
|
});
|
|
83
109
|
// reset auto-merge state between runs
|
|
84
110
|
afterEach(async () => {
|
|
@@ -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 () => {
|
|
@@ -47,13 +48,15 @@ describe('allFetchers', () => {
|
|
|
47
48
|
});
|
|
48
49
|
it('matches commitByAuthor with commitBySearchQuery', async () => {
|
|
49
50
|
const commitsBySearchQuery = await (0, fetchPullRequestsBySearchQuery_1.fetchPullRequestsBySearchQuery)({
|
|
50
|
-
repoOwner: 'elastic',
|
|
51
|
-
repoName: 'kibana',
|
|
52
51
|
accessToken,
|
|
52
|
+
author: 'sqren',
|
|
53
|
+
dateSince: null,
|
|
54
|
+
dateUntil: null,
|
|
53
55
|
maxNumber: 1,
|
|
54
56
|
prFilter: `created:2021-12-20..2021-12-20`,
|
|
57
|
+
repoName: 'kibana',
|
|
58
|
+
repoOwner: 'elastic',
|
|
55
59
|
sourceBranch: 'main',
|
|
56
|
-
author: 'sqren',
|
|
57
60
|
});
|
|
58
61
|
const commitBySearchQuery = commitsBySearchQuery[0];
|
|
59
62
|
expect(commitByAuthor).toEqual(commitBySearchQuery);
|
|
@@ -14,17 +14,17 @@ const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
|
14
14
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
15
15
|
const fetchAuthorId_1 = require("../fetchAuthorId");
|
|
16
16
|
async function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
17
|
-
const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', maxNumber = 10, repoName, repoOwner, sourceBranch,
|
|
17
|
+
const { accessToken, dateSince, dateUntil, githubApiBaseUrlV4 = 'https://api.github.com/graphql', maxNumber = 10, repoName, repoOwner, sourceBranch, } = options;
|
|
18
18
|
const query = (0, graphql_tag_1.default) `
|
|
19
19
|
query CommitsByAuthor(
|
|
20
|
-
$repoOwner: String!
|
|
21
|
-
$repoName: String!
|
|
22
|
-
$maxNumber: Int!
|
|
23
|
-
$sourceBranch: String!
|
|
24
20
|
$authorId: ID
|
|
25
21
|
$commitPath: String
|
|
26
22
|
$dateSince: GitTimestamp
|
|
27
23
|
$dateUntil: GitTimestamp
|
|
24
|
+
$maxNumber: Int!
|
|
25
|
+
$repoName: String!
|
|
26
|
+
$repoOwner: String!
|
|
27
|
+
$sourceBranch: String!
|
|
28
28
|
) {
|
|
29
29
|
repository(owner: $repoOwner, name: $repoName) {
|
|
30
30
|
ref(qualifiedName: $sourceBranch) {
|
|
@@ -70,7 +70,6 @@ async function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
catch (e) {
|
|
73
|
-
//@ts-expect-error
|
|
74
73
|
return (0, remoteConfig_1.swallowMissingConfigFileException)(e);
|
|
75
74
|
}
|
|
76
75
|
}
|
|
@@ -8,17 +8,19 @@ describe('fetchPullRequestsBySearchQuery', () => {
|
|
|
8
8
|
it('throws an error', async () => {
|
|
9
9
|
const options = {
|
|
10
10
|
accessToken,
|
|
11
|
+
author: 'sqren',
|
|
12
|
+
dateSince: null,
|
|
13
|
+
dateUntil: null,
|
|
11
14
|
maxNumber: 10,
|
|
12
15
|
prFilter: 'label:non-existing',
|
|
13
16
|
repoName: 'backport-e2e',
|
|
14
17
|
repoOwner: 'backport-org',
|
|
15
18
|
sourceBranch: 'master',
|
|
16
|
-
author: 'sqren',
|
|
17
19
|
};
|
|
18
20
|
await expect((0, fetchPullRequestsBySearchQuery_1.fetchPullRequestsBySearchQuery)(options)).rejects
|
|
19
21
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
20
22
|
"No commits found for query:
|
|
21
|
-
type:pr is:merged sort:
|
|
23
|
+
type:pr is:merged sort:created-desc repo:backport-org/backport-e2e author:sqren base:master label:non-existing
|
|
22
24
|
|
|
23
25
|
Use \`--all\` to see commits by all users or \`--author=<username>\` for commits from a specific user"
|
|
24
26
|
`);
|
|
@@ -28,12 +30,14 @@ describe('fetchPullRequestsBySearchQuery', () => {
|
|
|
28
30
|
it('returns the merge commits for those PRs', async () => {
|
|
29
31
|
const options = {
|
|
30
32
|
accessToken,
|
|
33
|
+
author: 'sqren',
|
|
34
|
+
dateSince: null,
|
|
35
|
+
dateUntil: null,
|
|
31
36
|
maxNumber: 10,
|
|
32
37
|
prFilter: 'label:v7.8.0',
|
|
33
38
|
repoName: 'backport-e2e',
|
|
34
39
|
repoOwner: 'backport-org',
|
|
35
40
|
sourceBranch: 'master',
|
|
36
|
-
author: 'sqren',
|
|
37
41
|
};
|
|
38
42
|
const expectedCommits = [
|
|
39
43
|
{
|
|
@@ -2,6 +2,8 @@ import { Commit } from '../../../sourceCommit/parseSourceCommit';
|
|
|
2
2
|
export declare function fetchPullRequestsBySearchQuery(options: {
|
|
3
3
|
accessToken: string;
|
|
4
4
|
author: string | null;
|
|
5
|
+
dateSince: string | null;
|
|
6
|
+
dateUntil: string | null;
|
|
5
7
|
githubApiBaseUrlV4?: string;
|
|
6
8
|
maxNumber?: number;
|
|
7
9
|
onlyMissing?: boolean;
|
|
@@ -12,7 +12,7 @@ const remoteConfig_1 = require("../../../remoteConfig");
|
|
|
12
12
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
13
13
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
14
14
|
async function fetchPullRequestsBySearchQuery(options) {
|
|
15
|
-
const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', maxNumber = 10, prFilter, repoName, repoOwner, sourceBranch,
|
|
15
|
+
const { accessToken, author, dateSince, dateUntil, githubApiBaseUrlV4 = 'https://api.github.com/graphql', maxNumber = 10, prFilter, repoName, repoOwner, sourceBranch, } = options;
|
|
16
16
|
const query = (0, graphql_tag_1.default) `
|
|
17
17
|
query PullRequestBySearchQuery($query: String!, $maxNumber: Int!) {
|
|
18
18
|
search(query: $query, type: ISSUE, first: $maxNumber) {
|
|
@@ -28,11 +28,28 @@ async function fetchPullRequestsBySearchQuery(options) {
|
|
|
28
28
|
|
|
29
29
|
${parseSourceCommit_1.SourceCommitWithTargetPullRequestFragment}
|
|
30
30
|
`;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
function dateFilter() {
|
|
32
|
+
if (dateUntil && dateSince) {
|
|
33
|
+
return [`merged:${dateSince}..${dateUntil}`];
|
|
34
|
+
}
|
|
35
|
+
if (dateUntil) {
|
|
36
|
+
return [`merged:<${dateUntil}`];
|
|
37
|
+
}
|
|
38
|
+
if (dateSince) {
|
|
39
|
+
return [`merged:>${dateSince}`];
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
const searchQuery = [
|
|
44
|
+
'type:pr',
|
|
45
|
+
'is:merged',
|
|
46
|
+
'sort:created-desc',
|
|
47
|
+
`repo:${repoOwner}/${repoName}`,
|
|
48
|
+
...(options.author ? [`author:${options.author}`] : []),
|
|
49
|
+
...(prFilter.includes('base:') ? [] : [`base:${sourceBranch}`]),
|
|
50
|
+
...dateFilter(),
|
|
51
|
+
prFilter,
|
|
52
|
+
].join(' ');
|
|
36
53
|
const variables = {
|
|
37
54
|
query: searchQuery,
|
|
38
55
|
maxNumber,
|
|
@@ -47,7 +64,6 @@ async function fetchPullRequestsBySearchQuery(options) {
|
|
|
47
64
|
});
|
|
48
65
|
}
|
|
49
66
|
catch (e) {
|
|
50
|
-
//@ts-expect-error
|
|
51
67
|
res = (0, remoteConfig_1.swallowMissingConfigFileException)(e);
|
|
52
68
|
}
|
|
53
69
|
const commits = res.search.nodes.map((pullRequestNode) => {
|
|
@@ -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;
|
|
@@ -69,4 +70,5 @@ export declare function getOptionsFromGithub(options: {
|
|
|
69
70
|
branches?: import("../../../../options/ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
70
71
|
labels?: string[] | undefined;
|
|
71
72
|
authenticatedUsername: string;
|
|
73
|
+
isRepoPrivate: boolean;
|
|
72
74
|
}>;
|
|
@@ -40,6 +40,7 @@ describe('getOptionsFromGithub', () => {
|
|
|
40
40
|
'^v7.9.0$': '7.x',
|
|
41
41
|
'^v8.0.0$': 'master',
|
|
42
42
|
},
|
|
43
|
+
isRepoPrivate: false,
|
|
43
44
|
sourceBranch: 'master',
|
|
44
45
|
targetBranchChoices: [
|
|
45
46
|
{ checked: true, name: 'master' },
|
|
@@ -109,6 +110,7 @@ describe('getOptionsFromGithub', () => {
|
|
|
109
110
|
const options = await (0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions);
|
|
110
111
|
expect(options).toEqual({
|
|
111
112
|
authenticatedUsername: 'sqren',
|
|
113
|
+
isRepoPrivate: false,
|
|
112
114
|
sourceBranch: 'main',
|
|
113
115
|
});
|
|
114
116
|
});
|
package/dist/lib/ora.d.ts
CHANGED
|
@@ -17,4 +17,4 @@ export interface RemoteConfigHistory {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
export declare function parseRemoteConfig(remoteConfig: RemoteConfig): ConfigFileOptions | undefined;
|
|
20
|
-
export declare function swallowMissingConfigFileException<T>(error: GithubV4Exception<T>): T;
|
|
20
|
+
export declare function swallowMissingConfigFileException<T>(error: GithubV4Exception<T> | unknown): T;
|
package/dist/lib/remoteConfig.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.swallowMissingConfigFileException = exports.parseRemoteConfig = exports.RemoteConfigHistoryFragment = void 0;
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
8
|
const readConfigFile_1 = require("../options/config/readConfigFile");
|
|
9
|
+
const apiRequestV4_1 = require("./github/v4/apiRequestV4");
|
|
9
10
|
const logger_1 = require("./logger");
|
|
10
11
|
exports.RemoteConfigHistoryFragment = (0, graphql_tag_1.default) `
|
|
11
12
|
fragment RemoteConfigHistoryFragment on Commit {
|
|
@@ -38,6 +39,9 @@ function parseRemoteConfig(remoteConfig) {
|
|
|
38
39
|
}
|
|
39
40
|
exports.parseRemoteConfig = parseRemoteConfig;
|
|
40
41
|
function swallowMissingConfigFileException(error) {
|
|
42
|
+
if (!(error instanceof apiRequestV4_1.GithubV4Exception)) {
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
41
45
|
const { data, errors } = error.githubResponse.data;
|
|
42
46
|
const missingConfigError = errors?.some((error) => {
|
|
43
47
|
return error.path?.includes('remoteConfig') && error.type === 'NOT_FOUND';
|
|
@@ -15,6 +15,8 @@ export declare function getOptionsFromCliArgs(processArgs: readonly string[]): {
|
|
|
15
15
|
cherrypickRef?: boolean | undefined;
|
|
16
16
|
projectConfigFile?: string | undefined;
|
|
17
17
|
globalConfigFile?: string | undefined;
|
|
18
|
+
dateSince?: string | undefined;
|
|
19
|
+
dateUntil?: string | undefined;
|
|
18
20
|
details?: boolean | undefined;
|
|
19
21
|
dryRun?: boolean | undefined;
|
|
20
22
|
editor?: string | undefined;
|
|
@@ -26,6 +28,7 @@ export declare function getOptionsFromCliArgs(processArgs: readonly string[]): {
|
|
|
26
28
|
gitAuthorEmail?: string | undefined;
|
|
27
29
|
ls?: boolean | undefined;
|
|
28
30
|
mainline?: number | undefined;
|
|
31
|
+
signoff?: boolean | undefined;
|
|
29
32
|
maxNumber?: number | undefined;
|
|
30
33
|
multipleBranches?: boolean | undefined;
|
|
31
34
|
multipleCommits?: boolean | undefined;
|
|
@@ -41,8 +44,6 @@ export declare function getOptionsFromCliArgs(processArgs: readonly string[]): {
|
|
|
41
44
|
repoOwner?: string | undefined;
|
|
42
45
|
repoName?: string | undefined;
|
|
43
46
|
sourceBranch?: string | undefined;
|
|
44
|
-
dateSince?: string | undefined;
|
|
45
|
-
dateUntil?: string | undefined;
|
|
46
47
|
commitPaths?: string[] | undefined;
|
|
47
48
|
reviewers?: string[] | undefined;
|
|
48
49
|
sourcePRLabels?: string[] | undefined;
|
package/dist/options/cliArgs.js
CHANGED
|
@@ -76,13 +76,25 @@ function getOptionsFromCliArgs(processArgs) {
|
|
|
76
76
|
description: 'Path to global config',
|
|
77
77
|
type: 'string',
|
|
78
78
|
})
|
|
79
|
-
.option('
|
|
79
|
+
.option('dateSince', {
|
|
80
|
+
alias: 'since',
|
|
80
81
|
description: 'ISO-8601 date for filtering commits',
|
|
81
82
|
type: 'string',
|
|
83
|
+
coerce: (since) => {
|
|
84
|
+
if (since) {
|
|
85
|
+
return new Date(since).toISOString();
|
|
86
|
+
}
|
|
87
|
+
},
|
|
82
88
|
})
|
|
83
|
-
.option('
|
|
89
|
+
.option('dateUntil', {
|
|
90
|
+
alias: 'until',
|
|
84
91
|
description: 'ISO-8601 date for filtering commits',
|
|
85
92
|
type: 'string',
|
|
93
|
+
coerce: (until) => {
|
|
94
|
+
if (until) {
|
|
95
|
+
return new Date(until).toISOString();
|
|
96
|
+
}
|
|
97
|
+
},
|
|
86
98
|
})
|
|
87
99
|
.option('dir', {
|
|
88
100
|
description: 'Path to temporary backport repo',
|
|
@@ -164,6 +176,11 @@ function getOptionsFromCliArgs(processArgs) {
|
|
|
164
176
|
// Invalid value provided
|
|
165
177
|
throw new Error(`--mainline must be an integer. Received: ${mainline}`);
|
|
166
178
|
},
|
|
179
|
+
})
|
|
180
|
+
.option('signoff', {
|
|
181
|
+
description: 'Pass the --signoff option to the cherry-pick command',
|
|
182
|
+
type: 'boolean',
|
|
183
|
+
alias: ['s'],
|
|
167
184
|
})
|
|
168
185
|
// display 10 commits to pick from
|
|
169
186
|
.option('maxNumber', {
|
|
@@ -230,7 +247,7 @@ function getOptionsFromCliArgs(processArgs) {
|
|
|
230
247
|
type: 'string',
|
|
231
248
|
})
|
|
232
249
|
.option('prFilter', {
|
|
233
|
-
conflicts: ['pullNumber', 'sha'],
|
|
250
|
+
conflicts: ['pullNumber', 'sha', 'path'],
|
|
234
251
|
description: `Filter source pull requests by a query`,
|
|
235
252
|
type: 'string',
|
|
236
253
|
})
|
|
@@ -329,7 +346,7 @@ function getOptionsFromCliArgs(processArgs) {
|
|
|
329
346
|
// shorthands
|
|
330
347
|
repo,
|
|
331
348
|
// filters
|
|
332
|
-
author,
|
|
349
|
+
author,
|
|
333
350
|
// negations
|
|
334
351
|
noCherrypickRef, noFork, noStatusComment, noVerify, verify, nonInteractive,
|
|
335
352
|
// array types (should be renamed to plural form)
|
|
@@ -345,8 +362,6 @@ function getOptionsFromCliArgs(processArgs) {
|
|
|
345
362
|
repoName,
|
|
346
363
|
// filters
|
|
347
364
|
author: all ? null : author,
|
|
348
|
-
dateSince: since ? new Date(since).toISOString() : undefined,
|
|
349
|
-
dateUntil: until ? new Date(until).toISOString() : undefined,
|
|
350
365
|
// `multiple` is a cli-only flag to override `multipleBranches` and `multipleCommits`
|
|
351
366
|
multipleBranches: multiple ?? multipleBranches,
|
|
352
367
|
multipleCommits: multiple ?? multipleCommits,
|