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.
Files changed (238) hide show
  1. package/README.md +11 -178
  2. package/dist/backportRun.js +1 -1
  3. package/dist/entrypoint.module.d.ts +2 -2
  4. package/dist/entrypoint.module.js +2 -0
  5. package/dist/entrypoint.module.private.test.js +11 -10
  6. package/dist/lib/cherrypickAndCreateTargetPullRequest.js +30 -20
  7. package/dist/lib/child-process-promisified.js +2 -2
  8. package/dist/lib/getCommits.js +1 -1
  9. package/dist/lib/git.d.ts +1 -1
  10. package/dist/lib/git.js +8 -28
  11. package/dist/lib/git.private.test.js +7 -7
  12. package/dist/lib/git.test.js +28 -12
  13. package/dist/lib/github/v3/createStatusComment.js +3 -2
  14. package/dist/lib/github/v3/createStatusComment.test.js +61 -0
  15. package/dist/lib/github/v4/apiRequestV4.js +1 -1
  16. package/dist/lib/github/v4/enablePullRequestAutoMerge.js +2 -1
  17. package/dist/{entrypoint.cli.private.test.d.ts → lib/github/v4/enablePullRequestAutoMerge.mutation.test.d.ts} +0 -0
  18. package/dist/lib/github/v4/{enablePullRequestAutoMerge.private.test.js → enablePullRequestAutoMerge.mutation.test.js} +34 -8
  19. package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +6 -3
  20. package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.js +0 -1
  21. package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.js +0 -1
  22. package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.js +5 -6
  23. package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +7 -3
  24. package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +2 -0
  25. package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +23 -7
  26. package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +2 -0
  27. package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +1 -0
  28. package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +2 -0
  29. package/dist/lib/github/v4/getOptionsFromGithub/query.d.ts +1 -0
  30. package/dist/lib/github/v4/getOptionsFromGithub/query.js +1 -0
  31. package/dist/lib/ora.d.ts +1 -0
  32. package/dist/lib/remoteConfig.d.ts +1 -1
  33. package/dist/lib/remoteConfig.js +4 -0
  34. package/dist/options/ConfigOptions.d.ts +1 -0
  35. package/dist/options/cliArgs.d.ts +3 -2
  36. package/dist/options/cliArgs.js +21 -6
  37. package/dist/options/config/config.d.ts +1 -0
  38. package/dist/options/config/readConfigFile.d.ts +1 -0
  39. package/dist/options/options.d.ts +5 -2
  40. package/dist/options/options.js +3 -3
  41. package/dist/options/options.test.js +7 -4
  42. package/dist/{lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts → test/e2e/cli/date-filters.private.test.d.ts} +0 -0
  43. package/dist/test/e2e/cli/date-filters.private.test.js +48 -0
  44. package/dist/test/e2e/cli/different-merge-strategies.private.test.js +120 -4
  45. package/dist/test/e2e/cli/entrypoint.cli.private.test.js +4 -18
  46. package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.js +2 -1
  47. package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.js +3 -2
  48. package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +2 -2
  49. package/dist/test/e2e/cli/runBackportViaCli.d.ts +8 -2
  50. package/dist/test/e2e/cli/runBackportViaCli.js +47 -17
  51. package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +1 -0
  52. package/dist/test/e2e/module/entrypoint.module.mutation.test.js +1 -1
  53. package/dist/test/handleUnbackportedPullRequests.private.test.js +1 -1
  54. package/dist/utils/packageVersion.d.ts +1 -1
  55. package/dist/utils/packageVersion.js +1 -1
  56. package/package.json +20 -21
  57. package/yarn.lock +210 -220
  58. package/dist/entrypoint.cli.private.test.js +0 -47
  59. package/dist/errors/BackportError.d.ts +0 -19
  60. package/dist/errors/BackportError.js +0 -29
  61. package/dist/runSequentially.test.d.ts +0 -1
  62. package/dist/runSequentially.test.js +0 -243
  63. package/dist/services/BackportError.d.ts +0 -19
  64. package/dist/services/BackportError.js +0 -29
  65. package/dist/services/HandledBackportError.d.ts +0 -19
  66. package/dist/services/HandledBackportError.js +0 -29
  67. package/dist/services/HandledError.d.ts +0 -19
  68. package/dist/services/HandledError.js +0 -29
  69. package/dist/services/child-process-promisified.d.ts +0 -25
  70. package/dist/services/child-process-promisified.js +0 -58
  71. package/dist/services/env.d.ts +0 -7
  72. package/dist/services/env.js +0 -30
  73. package/dist/services/env.test.d.ts +0 -1
  74. package/dist/services/env.test.js +0 -21
  75. package/dist/services/git.d.ts +0 -77
  76. package/dist/services/git.integration.test.d.ts +0 -1
  77. package/dist/services/git.integration.test.js +0 -616
  78. package/dist/services/git.js +0 -439
  79. package/dist/services/git.private.test.d.ts +0 -1
  80. package/dist/services/git.private.test.js +0 -618
  81. package/dist/services/git.test.d.ts +0 -1
  82. package/dist/services/git.test.js +0 -580
  83. package/dist/services/github/commitFormatters.d.ts +0 -3
  84. package/dist/services/github/commitFormatters.js +0 -17
  85. package/dist/services/github/commitFormatters.test.d.ts +0 -1
  86. package/dist/services/github/commitFormatters.test.js +0 -11
  87. package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +0 -2
  88. package/dist/services/github/v3/addAssigneesToPullRequest.js +0 -32
  89. package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +0 -1
  90. package/dist/services/github/v3/addAssigneesToPullRequest.test.js +0 -27
  91. package/dist/services/github/v3/addLabelsToPullRequest.d.ts +0 -2
  92. package/dist/services/github/v3/addLabelsToPullRequest.js +0 -30
  93. package/dist/services/github/v3/addReviewersToPullRequest.d.ts +0 -2
  94. package/dist/services/github/v3/addReviewersToPullRequest.js +0 -32
  95. package/dist/services/github/v3/createPullRequest.d.ts +0 -29
  96. package/dist/services/github/v3/createPullRequest.js +0 -91
  97. package/dist/services/github/v3/createPullRequest.test.d.ts +0 -1
  98. package/dist/services/github/v3/createPullRequest.test.js +0 -377
  99. package/dist/services/github/v3/createStatusComment.d.ts +0 -11
  100. package/dist/services/github/v3/createStatusComment.js +0 -131
  101. package/dist/services/github/v3/createStatusComment.test.d.ts +0 -1
  102. package/dist/services/github/v3/createStatusComment.test.js +0 -409
  103. package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +0 -14
  104. package/dist/services/github/v3/getGithubV3ErrorMessage.js +0 -16
  105. package/dist/services/github/v4/FetchPullRequestId.d.ts +0 -2
  106. package/dist/services/github/v4/FetchPullRequestId.js +0 -36
  107. package/dist/services/github/v4/apiRequestV4.d.ts +0 -31
  108. package/dist/services/github/v4/apiRequestV4.js +0 -71
  109. package/dist/services/github/v4/apiRequestV4.test.d.ts +0 -1
  110. package/dist/services/github/v4/apiRequestV4.test.js +0 -109
  111. package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -2
  112. package/dist/services/github/v4/disablePullRequestAutoMerge.js +0 -32
  113. package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -2
  114. package/dist/services/github/v4/enablePullRequestAutoMerge.js +0 -50
  115. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +0 -1
  116. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
  117. package/dist/services/github/v4/fetchAuthorId.d.ts +0 -10
  118. package/dist/services/github/v4/fetchAuthorId.js +0 -28
  119. package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +0 -1
  120. package/dist/services/github/v4/fetchAuthorId.private.test.js +0 -25
  121. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +0 -1
  122. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -93
  123. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +0 -11
  124. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +0 -58
  125. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +0 -1
  126. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +0 -136
  127. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +0 -11
  128. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +0 -48
  129. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +0 -1
  130. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +0 -118
  131. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +0 -29
  132. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +0 -110
  133. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +0 -1
  134. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +0 -196
  135. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +0 -1
  136. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -157
  137. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +0 -3
  138. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +0 -61
  139. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
  140. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +0 -107
  141. package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +0 -12
  142. package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +0 -69
  143. package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -9
  144. package/dist/services/github/v4/fetchExistingPullRequest.js +0 -64
  145. package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +0 -1
  146. package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -44
  147. package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -2
  148. package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +0 -39
  149. package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +0 -8
  150. package/dist/services/github/v4/fetchRemoteProjectConfig.js +0 -49
  151. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +0 -1
  152. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +0 -49
  153. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +0 -69
  154. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +0 -73
  155. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +0 -1
  156. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -116
  157. package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +0 -16
  158. package/dist/services/github/v4/getOptionsFromGithub/query.js +0 -29
  159. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +0 -29
  160. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +0 -61
  161. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +0 -1
  162. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +0 -72
  163. package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +0 -2
  164. package/dist/services/github/v4/mocks/commitsByAuthorMock.js +0 -176
  165. package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +0 -6
  166. package/dist/services/github/v4/throwOnInvalidAccessToken.js +0 -45
  167. package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +0 -1
  168. package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +0 -87
  169. package/dist/services/logger.d.ts +0 -9
  170. package/dist/services/logger.js +0 -74
  171. package/dist/services/prompt.test.d.ts +0 -1
  172. package/dist/services/prompt.test.js +0 -139
  173. package/dist/services/prompts.d.ts +0 -17
  174. package/dist/services/prompts.js +0 -132
  175. package/dist/services/remoteConfig.d.ts +0 -20
  176. package/dist/services/remoteConfig.js +0 -52
  177. package/dist/services/sequentially.d.ts +0 -1
  178. package/dist/services/sequentially.js +0 -10
  179. package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +0 -16
  180. package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +0 -102
  181. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +0 -1
  182. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +0 -467
  183. package/dist/services/sourceCommit/getMockSourceCommit.d.ts +0 -26
  184. package/dist/services/sourceCommit/getMockSourceCommit.js +0 -103
  185. package/dist/services/sourceCommit/parseSourceCommit.d.ts +0 -108
  186. package/dist/services/sourceCommit/parseSourceCommit.js +0 -123
  187. package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +0 -1
  188. package/dist/services/sourceCommit/parseSourceCommit.test.js +0 -226
  189. package/dist/services/test.d.ts +0 -1
  190. package/dist/services/test.js +0 -23
  191. package/dist/state.d.ts +0 -0
  192. package/dist/state.js +0 -1
  193. package/dist/test/ExecError.d.ts +0 -16
  194. package/dist/test/ExecError.js +0 -15
  195. package/dist/test/e2e/cli/cli.private.test.d.ts +0 -1
  196. package/dist/test/e2e/cli/cli.private.test.js +0 -222
  197. package/dist/test/e2e/cli/interactive-error-handling.private.test.d.ts +0 -1
  198. package/dist/test/e2e/cli/interactive-error-handling.private.test.js +0 -80
  199. package/dist/test/e2e/cli/non-interactive-error-handling.private.test.d.ts +0 -1
  200. package/dist/test/e2e/cli/non-interactive-error-handling.private.test.js +0 -198
  201. package/dist/test/e2e/cli.e2e.private.test.d.ts +0 -1
  202. package/dist/test/e2e/cli.e2e.private.test.js +0 -433
  203. package/dist/test/e2e/module/module.mutation.test.d.ts +0 -1
  204. package/dist/test/e2e/module/module.mutation.test.js +0 -369
  205. package/dist/test/e2e/module.e2e.mutation.test.d.ts +0 -1
  206. package/dist/test/e2e/module.e2e.mutation.test.js +0 -369
  207. package/dist/test/e2e/module.e2e.private.test.d.ts +0 -1
  208. package/dist/test/e2e/module.e2e.private.test.js +0 -369
  209. package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -13
  210. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +0 -243
  211. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
  212. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +0 -320
  213. package/dist/ui/getCommits.d.ts +0 -2
  214. package/dist/ui/getCommits.js +0 -75
  215. package/dist/ui/getCommitsWithoutBackports.d.ts +0 -11
  216. package/dist/ui/getCommitsWithoutBackports.js +0 -68
  217. package/dist/ui/getCommitsWithoutBackports.test.d.ts +0 -1
  218. package/dist/ui/getCommitsWithoutBackports.test.js +0 -335
  219. package/dist/ui/getGitConfigAuthor.d.ts +0 -6
  220. package/dist/ui/getGitConfigAuthor.js +0 -15
  221. package/dist/ui/getTargetBranches.d.ts +0 -5
  222. package/dist/ui/getTargetBranches.js +0 -67
  223. package/dist/ui/getTargetBranches.test.d.ts +0 -1
  224. package/dist/ui/getTargetBranches.test.js +0 -204
  225. package/dist/ui/maybeSetupRepo.d.ts +0 -2
  226. package/dist/ui/maybeSetupRepo.js +0 -53
  227. package/dist/ui/maybeSetupRepo.test.d.ts +0 -1
  228. package/dist/ui/maybeSetupRepo.test.js +0 -238
  229. package/dist/ui/ora.d.ts +0 -2
  230. package/dist/ui/ora.js +0 -21
  231. package/dist/ui/setupRepo.d.ts +0 -2
  232. package/dist/ui/setupRepo.js +0 -56
  233. package/dist/ui/setupRepo.test.d.ts +0 -1
  234. package/dist/ui/setupRepo.test.js +0 -273
  235. package/dist/utils/filterMissingCommits.d.ts +0 -2
  236. package/dist/utils/filterMissingCommits.js +0 -7
  237. package/dist/utils/redact.d.ts +0 -1
  238. package/dist/utils/redact.js +0 -7
@@ -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 getIsMergeCommit(...)
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 getIsMergeCommit(...)
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/configuration.md#fork"
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
- `[<img src="https://img.shields.io/github/pulls/detail/state/${repoOwner}/${repoName}/${result.pullRequestNumber}">](${result.pullRequestUrl})`,
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;
@@ -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
- // commit to create new branch from
19
- // https://github.com/backport-org/repo-with-auto-merge-enabled/commit/1a88d210f90a22e2a06253c5760909833dc820e9
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: 'main',
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
- // causes flaky test runs on CI because parallel builds are racing each other
58
- // might also be an issue with Github's API being slow at updating after a mutation happens
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.skip('enablePullRequestAutoMerge', () => {
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 createBranch(octokit, branchName, COMMIT_SHA);
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);
@@ -42,7 +42,6 @@ async function fetchCommitByPullNumber(options) {
42
42
  });
43
43
  }
44
44
  catch (e) {
45
- //@ts-expect-error
46
45
  res = (0, remoteConfig_1.swallowMissingConfigFileException)(e);
47
46
  }
48
47
  const pullRequestNode = res.repository.pullRequest;
@@ -36,7 +36,6 @@ async function fetchCommitBySha(options) {
36
36
  });
37
37
  }
38
38
  catch (e) {
39
- //@ts-expect-error
40
39
  res = (0, remoteConfig_1.swallowMissingConfigFileException)(e);
41
40
  }
42
41
  const sourceCommit = res.repository.object;
@@ -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, dateSince, dateUntil, } = options;
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:updated-desc repo:backport-org/backport-e2e author:sqren base:master label:non-existing
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, author, } = options;
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
- const authorFilter = options.author ? ` author:${options.author}` : '';
32
- const sourceBranchFilter = prFilter.includes('base:')
33
- ? ''
34
- : ` base:${sourceBranch}`;
35
- const searchQuery = `type:pr is:merged sort:updated-desc repo:${repoOwner}/${repoName}${authorFilter}${sourceBranchFilter} ${prFilter} `;
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
  }>;
@@ -39,6 +39,7 @@ async function getOptionsFromGithub(options) {
39
39
  return {
40
40
  authenticatedUsername: res.viewer.login,
41
41
  sourceBranch: res.repository.defaultBranchRef.name,
42
+ isRepoPrivate: res.repository.isPrivate,
42
43
  ...remoteConfig,
43
44
  };
44
45
  }
@@ -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
  });
@@ -4,6 +4,7 @@ export interface GithubConfigOptionsResponse {
4
4
  login: string;
5
5
  };
6
6
  repository: {
7
+ isPrivate: boolean;
7
8
  illegalBackportBranch: {
8
9
  id: string;
9
10
  } | null;
@@ -16,6 +16,7 @@ exports.query = (0, graphql_tag_1.default) `
16
16
  illegalBackportBranch: ref(qualifiedName: "refs/heads/backport") {
17
17
  id
18
18
  }
19
+ isPrivate
19
20
  defaultBranchRef {
20
21
  name
21
22
  target {
package/dist/lib/ora.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  import oraOriginal from 'ora';
2
2
  export declare function ora(interactive: boolean | undefined, text?: string | undefined): oraOriginal.Ora;
3
+ export declare type Ora = oraOriginal.Ora;
@@ -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;
@@ -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';
@@ -59,6 +59,7 @@ declare type Options = Partial<{
59
59
  targetBranchChoices: TargetBranchChoiceOrString[];
60
60
  targetBranches: string[];
61
61
  targetPRLabels: string[];
62
+ signoff: boolean;
62
63
  }>;
63
64
  export declare type ConfigFileOptions = Options & Partial<{
64
65
  help: boolean;
@@ -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;
@@ -76,13 +76,25 @@ function getOptionsFromCliArgs(processArgs) {
76
76
  description: 'Path to global config',
77
77
  type: 'string',
78
78
  })
79
- .option('since', {
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('until', {
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, since, until,
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,