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
@@ -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;
@@ -50,6 +51,8 @@ export declare function getOptions({ optionsFromCliArgs, optionsFromModule, }: {
50
51
  cherrypickRef: boolean;
51
52
  projectConfigFile?: string | undefined;
52
53
  globalConfigFile?: string | undefined;
54
+ dateSince: string | null;
55
+ dateUntil: string | null;
53
56
  details: boolean;
54
57
  dryRun?: boolean | undefined;
55
58
  editor?: string | undefined;
@@ -61,6 +64,7 @@ export declare function getOptions({ optionsFromCliArgs, optionsFromModule, }: {
61
64
  gitAuthorEmail?: string | undefined;
62
65
  ls?: boolean | undefined;
63
66
  mainline?: number | undefined;
67
+ signoff: boolean;
64
68
  maxNumber: number;
65
69
  multipleBranches: boolean;
66
70
  multipleCommits: boolean;
@@ -74,8 +78,6 @@ export declare function getOptions({ optionsFromCliArgs, optionsFromModule, }: {
74
78
  sha?: string | string[] | undefined;
75
79
  resetAuthor: boolean;
76
80
  sourceBranch: string;
77
- dateSince: string | null;
78
- dateUntil: string | null;
79
81
  commitPaths: string[];
80
82
  reviewers: string[];
81
83
  sourcePRLabels: string[];
@@ -101,4 +103,5 @@ export declare function getOptions({ optionsFromCliArgs, optionsFromModule, }: {
101
103
  branches?: TargetBranchChoiceOrString[] | undefined;
102
104
  labels?: string[] | undefined;
103
105
  authenticatedUsername: string;
106
+ isRepoPrivate: boolean;
104
107
  }>;
@@ -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/configuration.md#project-config-backportrcjson';
12
- const GLOBAL_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson';
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)({
@@ -126,7 +127,6 @@ function throwForRequiredOptions(options) {
126
127
  'githubApiBaseUrlV4',
127
128
  'logFilePath',
128
129
  'prDescription',
129
- 'prFilter',
130
130
  'projectConfigFile',
131
131
  'prTitle',
132
132
  'repoForkOwner',
@@ -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/configuration.md#global-config-backportconfigjson"
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/configuration.md#project-config-backportrcjson"
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/configuration.md#global-config-backportconfigjson"
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/configuration.md#project-config-backportrcjson"
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 () => {
@@ -199,6 +199,7 @@ describe('getOptions', () => {
199
199
  gitHostname: 'github.com',
200
200
  githubApiBaseUrlV4: 'http://localhost/graphql',
201
201
  interactive: true,
202
+ isRepoPrivate: false,
202
203
  maxNumber: 10,
203
204
  multipleBranches: true,
204
205
  multipleCommits: false,
@@ -211,6 +212,7 @@ describe('getOptions', () => {
211
212
  repoOwner: 'elastic',
212
213
  resetAuthor: false,
213
214
  reviewers: [],
215
+ signoff: false,
214
216
  sourceBranch: 'default-branch-from-github',
215
217
  sourcePRLabels: [],
216
218
  targetBranchChoices: ['7.9', '8.0'],
@@ -397,6 +399,7 @@ function mockGithubConfigOptions({ viewerLogin = 'DO_NOT_USE-sqren', defaultBran
397
399
  login: viewerLogin,
398
400
  },
399
401
  repository: {
402
+ isPrivate: false,
400
403
  illegalBackportBranch: hasBackportBranch ? { id: 'foo' } : null,
401
404
  defaultBranchRef: {
402
405
  name: defaultBranchRef,
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const getDevAccessToken_1 = require("../../private/getDevAccessToken");
4
+ const runBackportViaCli_1 = require("./runBackportViaCli");
5
+ const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
6
+ jest.setTimeout(15000);
7
+ describe('date filters (dateSince, dateUntil)', () => {
8
+ it(`filters commits by "since" and "until"`, async () => {
9
+ const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
10
+ '--branch=7.x',
11
+ '--repo=backport-org/backport-e2e',
12
+ `--accessToken=${accessToken}`,
13
+ '--since=2020-08-15T10:00:00.000Z',
14
+ '--until=2020-08-15T10:30:00.000Z',
15
+ ], { waitForString: 'Select commit' });
16
+ expect(output).toMatchInlineSnapshot(`
17
+ "? Select commit (Use arrow keys)
18
+ ❯ 1. Bump to 8.0.0
19
+ 2. Add package.json
20
+ 3. Update .backportrc.json
21
+ 4. Create .backportrc.json"
22
+ `);
23
+ });
24
+ it('combined with --pr-filter', async () => {
25
+ const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
26
+ '--branch=7.x',
27
+ '--repo=elastic/kibana',
28
+ `--accessToken=${accessToken}`,
29
+ `--author=sqren`,
30
+ '--since=2021-09-20',
31
+ '--until=2021-10-01',
32
+ ], { waitForString: 'Select commit' });
33
+ const { output: outputFromPrFilter } = await (0, runBackportViaCli_1.runBackportViaCli)([
34
+ '--branch=7.x',
35
+ '--repo=elastic/kibana',
36
+ `--accessToken=${accessToken}`,
37
+ `--pr-filter="author:sqren"`,
38
+ '--since=2021-09-20',
39
+ '--until=2021-10-01',
40
+ '--source-branch=master',
41
+ ], { waitForString: 'Select commit' });
42
+ expect(output).toMatchInlineSnapshot(`
43
+ "? Select commit (Use arrow keys)
44
+ ❯ 1. [APM] Add link to officials docs for APM UI settings (#113396) 7.x"
45
+ `);
46
+ expect(output).toEqual(outputFromPrFilter);
47
+ });
48
+ });
@@ -1,10 +1,15 @@
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");
5
9
  const sandbox_1 = require("../../sandbox");
6
10
  const runBackportViaCli_1 = require("./runBackportViaCli");
7
11
  const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
12
+ jest.setTimeout(40000);
8
13
  describe('different-merge-strategies', () => {
9
14
  it('list all commits regardless how they were merged', async () => {
10
15
  const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
@@ -33,7 +38,7 @@ describe('different-merge-strategies', () => {
33
38
  16.Initial commit"
34
39
  `);
35
40
  });
36
- describe('when selecting a merge commit', () => {
41
+ describe('when selecting a merge commit with eight commits', () => {
37
42
  let output;
38
43
  let sandboxPath;
39
44
  beforeAll(async () => {
@@ -58,8 +63,22 @@ describe('different-merge-strategies', () => {
58
63
  Backporting to 7.x:
59
64
  - Pulling latest changes
60
65
  ✔ Pulling latest changes
61
- - Cherry-picking: Merge pull request #9 from backport-org/many-merge-commits
62
- ✔ Cherry-picking: Merge pull request #9 from backport-org/many-merge-commits
66
+ - Cherry-picking: Merge strategy: First of many merges
67
+ ✔ Cherry-picking: Merge strategy: First of many merges
68
+ - Cherry-picking: Merge strategy: Second of many merges
69
+ ✔ Cherry-picking: Merge strategy: Second of many merges
70
+ - Cherry-picking: Merge strategy: Third of many merges
71
+ ✔ Cherry-picking: Merge strategy: Third of many merges
72
+ - Cherry-picking: Merge strategy: Fourth of many merges
73
+ ✔ Cherry-picking: Merge strategy: Fourth of many merges
74
+ - Cherry-picking: Merge strategy: Fifth of many merges
75
+ ✔ Cherry-picking: Merge strategy: Fifth of many merges
76
+ - Cherry-picking: Merge strategy: Sixth of many merges
77
+ ✔ Cherry-picking: Merge strategy: Sixth of many merges
78
+ - Cherry-picking: Merge strategy: Seventh of many merges
79
+ ✔ Cherry-picking: Merge strategy: Seventh of many merges
80
+ - Cherry-picking: Merge strategy: Eighth of many merges
81
+ ✔ Cherry-picking: Merge strategy: Eighth of many merges
63
82
  ✔ Dry run complete"
64
83
  `);
65
84
  });
@@ -78,7 +97,7 @@ describe('different-merge-strategies', () => {
78
97
  ]);
79
98
  });
80
99
  });
81
- describe('when selecting anoter merge commit', () => {
100
+ describe('when selecting a merge commit with two commits', () => {
82
101
  let sandboxPath;
83
102
  beforeAll(async () => {
84
103
  sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
@@ -101,6 +120,103 @@ describe('different-merge-strategies', () => {
101
120
  ]);
102
121
  });
103
122
  });
123
+ describe('when selecting a merge commit with eight commits and a conflict occurs', () => {
124
+ let sandboxPath;
125
+ let output;
126
+ beforeAll(async () => {
127
+ sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
128
+ await (0, sandbox_1.resetSandbox)(sandboxPath);
129
+ const proc = await (0, runBackportViaCli_1.runBackportViaCli)([
130
+ '--branch=7.1',
131
+ '--repo=backport-org/different-merge-strategies',
132
+ `--accessToken=${accessToken}`,
133
+ `--dir=${sandboxPath}`,
134
+ '--pr=9',
135
+ '--dry-run',
136
+ ], {
137
+ keepAlive: true,
138
+ timeoutSeconds: 5,
139
+ showOra: true,
140
+ waitForString: 'Press ENTER when the conflicts are resolved and files are staged',
141
+ });
142
+ await (0, child_process_promisified_1.exec)(`git status`, { cwd: sandboxPath });
143
+ 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`);
144
+ await (0, child_process_promisified_1.exec)(`git add -A`, { cwd: sandboxPath });
145
+ const res = await proc.keypress('enter', {
146
+ showOra: true,
147
+ timeoutSeconds: 5,
148
+ });
149
+ output = res.output.replaceAll(sandboxPath, '');
150
+ });
151
+ it('has the right output', async () => {
152
+ function stripSandboxPath(str) {
153
+ const regex = sandboxPath
154
+ .split('')
155
+ .map((s) => `${s}\\s?`)
156
+ .join('');
157
+ return str.replace(new RegExp(regex, 'g'), '<SANDBOX_PATH>');
158
+ }
159
+ expect(stripSandboxPath(output)).toMatchInlineSnapshot(`
160
+ "- Initializing...
161
+ ? Select pull request Merge pull request #9 from backport-org/many-merge-commits
162
+ ✔ 100% Cloning repository from github.com (one-time operation)
163
+
164
+ Backporting to 7.1:
165
+ - Pulling latest changes
166
+ ✔ Pulling latest changes
167
+ - Cherry-picking: Merge strategy: First of many merges
168
+ ✖ Cherry-picking: Merge strategy: First of many merges
169
+
170
+ The commit could not be backported due to conflicts
171
+
172
+ Please fix the conflicts in
173
+ ? Fix the following conflicts manually:
174
+
175
+ Conflicting files:
176
+ - <SANDBOX_PATH>/new-file-added-with-many-merge-commits.txt
177
+
178
+
179
+ Press ENTER when the conflicts are resolved and files are staged (Y/n) ? Fix the following conflicts manually:
180
+
181
+ Conflicting files:
182
+ - <SANDBOX_PATH>/new-file-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', {
@@ -65,8 +65,8 @@ describe('entrypoint cli', () => {
65
65
  [boolean]
66
66
  --projectConfigFile, --config Path to project config [string]
67
67
  --globalConfigFile Path to global config [string]
68
- --since ISO-8601 date for filtering commits [string]
69
- --until ISO-8601 date for filtering commits [string]
68
+ --dateSince, --since ISO-8601 date for filtering commits [string]
69
+ --dateUntil, --until ISO-8601 date for filtering commits [string]
70
70
  --dir Path to temporary backport repo [string]
71
71
  --details Show details about each commit [boolean]
72
72
  --dryRun Run backport locally without pushing to Github [boolean]
@@ -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]
@@ -159,22 +161,6 @@ describe('entrypoint cli', () => {
159
161
  6. Merge pull request #1 from backport-org/add-heart-emoji"
160
162
  `);
161
163
  });
162
- it(`filters commits by "since" and "until"`, async () => {
163
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
164
- '--branch=7.x',
165
- '--repo=backport-org/backport-e2e',
166
- `--accessToken=${accessToken}`,
167
- '--since=2020-08-15T10:00:00.000Z',
168
- '--until=2020-08-15T10:30:00.000Z',
169
- ], { waitForString: 'Select commit' });
170
- expect(output).toMatchInlineSnapshot(`
171
- "? Select commit (Use arrow keys)
172
- ❯ 1. Bump to 8.0.0
173
- 2. Add package.json
174
- 3. Update .backportrc.json
175
- 4. Create .backportrc.json"
176
- `);
177
- });
178
164
  it(`lists commits from 7.x`, async () => {
179
165
  const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
180
166
  '--branch=7.x',
@@ -4,6 +4,7 @@ const getDevAccessToken_1 = require("../../private/getDevAccessToken");
4
4
  const sandbox_1 = require("../../sandbox");
5
5
  const runBackportViaCli_1 = require("./runBackportViaCli");
6
6
  const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
7
+ jest.setTimeout(15000);
7
8
  describe('interactive error handling', () => {
8
9
  it('when branch is missing', async () => {
9
10
  const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
@@ -14,7 +15,7 @@ describe('interactive error handling', () => {
14
15
  expect(output).toMatchInlineSnapshot(`
15
16
  "Please specify a target branch: \\"--branch 6.1\\".
16
17
 
17
- Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
18
+ Read more: https://github.com/sqren/backport/blob/main/docs/config-file-options.md#project-config-backportrcjson"
18
19
  `);
19
20
  });
20
21
  it('when supplying invalid argument', async () => {
@@ -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/configuration.md#global-config-backportconfigjson"
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/configuration.md#project-config-backportrcjson"
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 () => {
@@ -9,7 +9,7 @@ describe('repo-with-backportrc-removed (missing .backportrc.json config file)',
9
9
  '--branch=production',
10
10
  '--repo=backport-org/repo-with-backportrc-removed',
11
11
  `--accessToken=${accessToken}`,
12
- ], { waitForString: 'Select commit' });
12
+ ], { waitForString: 'Select commit', timeoutSeconds: 4 });
13
13
  expect(output).toMatchInlineSnapshot(`
14
14
  "? Select commit (Use arrow keys)
15
15
  ❯ 1. Rename README.me to README.md
@@ -31,7 +31,7 @@ describe('repo-with-backportrc-removed (missing .backportrc.json config file)',
31
31
  ], {
32
32
  showOra: true,
33
33
  });
34
- expect(output).toContain('Cherry-picking: Merge pull request #1 from backport-org/add-readme');
34
+ expect(output).toContain('Cherry-picking: Create README.me');
35
35
  });
36
36
  it('backport by commit sha', async () => {
37
37
  const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
@@ -1,9 +1,15 @@
1
- export declare function runBackportViaCli(backportArgs: string[], { timeoutSeconds, showOra, waitForString, cwd, }?: {
1
+ declare type RunBackportOptions = {
2
2
  timeoutSeconds?: number;
3
3
  showOra?: boolean;
4
4
  waitForString?: string;
5
5
  cwd?: string;
6
- }): Promise<{
6
+ keepAlive?: boolean;
7
+ };
8
+ export declare function runBackportViaCli(backportArgs: string[], runBackportOptions?: RunBackportOptions): Promise<{
7
9
  output: string;
8
10
  code: number | null;
11
+ keypress: (keyCode: "up" | "down" | "enter", runBackportOptions?: RunBackportOptions | undefined) => Promise<{
12
+ output: string;
13
+ }>;
9
14
  }>;
15
+ export {};
@@ -9,10 +9,11 @@ const path_1 = __importDefault(require("path"));
9
9
  const lodash_1 = require("lodash");
10
10
  const strip_ansi_1 = __importDefault(require("strip-ansi"));
11
11
  const sandbox_1 = require("../../sandbox");
12
+ const tsNodeBinary = path_1.default.resolve('./node_modules/.bin/ts-node');
13
+ const entrypointFile = path_1.default.resolve('./src/entrypoint.cli.ts');
12
14
  jest.setTimeout(15000);
13
- function runBackportViaCli(backportArgs, { timeoutSeconds = 3, showOra, waitForString, cwd, } = {}) {
14
- const tsNodeBinary = path_1.default.resolve('./node_modules/.bin/ts-node');
15
- const entrypointFile = path_1.default.resolve('./src/entrypoint.cli.ts');
15
+ function runBackportViaCli(backportArgs, runBackportOptions = {}) {
16
+ const chunks = '';
16
17
  const randomString = Math.random().toString(36).slice(2);
17
18
  const sandboxPath = (0, sandbox_1.getSandboxPath)({
18
19
  filename: __filename,
@@ -28,30 +29,52 @@ function runBackportViaCli(backportArgs, { timeoutSeconds = 3, showOra, waitForS
28
29
  : [`--dir=${sandboxPath}`]),
29
30
  ...backportArgs,
30
31
  ];
31
- const proc = (0, child_process_1.spawn)(tsNodeBinary, cmdArgs, { cwd });
32
+ const proc = (0, child_process_1.spawn)(tsNodeBinary, cmdArgs, { cwd: runBackportOptions.cwd });
33
+ return getPromise(proc, runBackportOptions, cmdArgs, chunks);
34
+ }
35
+ exports.runBackportViaCli = runBackportViaCli;
36
+ const keyCodeMap = {
37
+ down: '\x1B\x5B\x42',
38
+ up: '\x1B\x5B\x41',
39
+ enter: '\x0D',
40
+ };
41
+ function getPromise(proc, runBackportOptions, cmdArgs, chunks) {
42
+ if (proc.killed) {
43
+ throw new Error('Process is already killed. Did you forget `keepAlive: true`?');
44
+ }
45
+ const { timeoutSeconds = 3, waitForString, showOra, keepAlive, } = runBackportOptions;
32
46
  return new Promise((resolve, reject) => {
33
- let data = '';
34
47
  const postponeTimeout = (0, lodash_1.debounce)(() => {
35
- const formattedData = formatData(data);
48
+ const formattedChunks = formatChunk(chunks);
36
49
  const cmd = [tsNodeBinary, ...cmdArgs].join(' ');
37
50
  reject(waitForString
38
- ? `Expectation '${waitForString}' not found within ${timeoutSeconds} second in:\n\n${formattedData}\n\nCommand: ${cmd}`
39
- : `Timeout. Received:\n${formattedData}\n\nCommand: ${cmd}`);
40
- }, timeoutSeconds * 1000, { maxWait: 15000 });
41
- function formatData(data) {
51
+ ? `Expectation '${waitForString}' not found within ${timeoutSeconds} second in:\n\n${formattedChunks}\n\nCommand: ${cmd}`
52
+ : `Process did not complete within ${timeoutSeconds} seconds. Received:\n${formattedChunks}\n\nCommand: ${cmd}`);
53
+ }, timeoutSeconds * 1000, { maxWait: 10000 });
54
+ function formatChunk(data) {
42
55
  return (0, strip_ansi_1.default)(data.toString()).trim();
43
56
  }
57
+ function keypress(keyCode, runBackportOptions = {}) {
58
+ const p = getPromise(proc, runBackportOptions, cmdArgs, chunks);
59
+ proc.stdin.write(keyCodeMap[keyCode]);
60
+ return p;
61
+ }
44
62
  const onChunk = (chunk) => {
45
- data += chunk;
46
- const output = formatData(data);
47
- if (waitForString && output.includes(waitForString)) {
63
+ chunks += chunk;
64
+ const formattedChunk = formatChunk(chunk);
65
+ if (waitForString && formattedChunk.includes(waitForString)) {
48
66
  postponeTimeout.cancel();
49
- resolve({ output, code: null });
67
+ resolve({ output: formatChunk(chunks), code: null, keypress });
50
68
  }
51
69
  };
52
70
  proc.on('exit', (code) => {
53
71
  postponeTimeout.cancel();
54
- resolve({ output: formatData(data), code });
72
+ if (waitForString) {
73
+ reject(`runBackportViaCli exited before finding: ${waitForString}. Output: `);
74
+ }
75
+ else {
76
+ resolve({ output: formatChunk(chunks), code, keypress });
77
+ }
55
78
  });
56
79
  proc.stdout.on('data', (chunk) => {
57
80
  postponeTimeout();
@@ -68,7 +91,14 @@ function runBackportViaCli(backportArgs, { timeoutSeconds = 3, showOra, waitForS
68
91
  reject(`runBackportViaCli failed with: ${err}`);
69
92
  });
70
93
  }).finally(() => {
71
- proc.kill();
94
+ if (!keepAlive) {
95
+ proc.kill();
96
+ }
97
+ else {
98
+ proc.removeAllListeners('exit');
99
+ proc.stdout.removeAllListeners('data');
100
+ proc.stderr.removeAllListeners('data');
101
+ proc.removeAllListeners('errors');
102
+ }
72
103
  });
73
104
  }
74
- exports.runBackportViaCli = runBackportViaCli;
@@ -5,6 +5,7 @@ const getDevAccessToken_1 = require("../../private/getDevAccessToken");
5
5
  const sandbox_1 = require("../../sandbox");
6
6
  const runBackportViaCli_1 = require("./runBackportViaCli");
7
7
  const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
8
+ jest.setTimeout(15000);
8
9
  describe('test-that-repo-can-be-cloned', () => {
9
10
  describe('when local repo does not exist', () => {
10
11
  let sandboxPath;
@@ -8,7 +8,7 @@ const sandbox_1 = require("../../sandbox");
8
8
  jest.unmock('find-up');
9
9
  jest.unmock('del');
10
10
  jest.unmock('make-dir');
11
- jest.setTimeout(10000);
11
+ jest.setTimeout(15000);
12
12
  const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
13
13
  const octokit = new rest_1.Octokit({ auth: accessToken });
14
14
  const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
@@ -5,7 +5,7 @@ const getDevAccessToken_1 = require("./private/getDevAccessToken");
5
5
  const sandbox_1 = require("./sandbox");
6
6
  const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
7
7
  jest.unmock('find-up');
8
- jest.setTimeout(15000);
8
+ jest.setTimeout(20000);
9
9
  describe('Handle unbackported pull requests', () => {
10
10
  it('shows missing backports for PR number 8', async () => {
11
11
  const commits = await (0, entrypoint_module_1.getCommits)({
@@ -1 +1 @@
1
- export declare const PACKAGE_VERSION = "8.3.0";
1
+ export declare const PACKAGE_VERSION = "8.4.1";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PACKAGE_VERSION = void 0;
4
- exports.PACKAGE_VERSION = '8.3.0';
4
+ exports.PACKAGE_VERSION = '8.4.1';