backport 10.2.0 → 11.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (501) hide show
  1. package/bin/backport +1 -1
  2. package/dist/src/backport-run.d.ts +5 -22
  3. package/dist/src/backport-run.js +76 -130
  4. package/dist/src/backport-run.js.map +1 -1
  5. package/dist/src/entrypoint.api.d.ts +18 -22
  6. package/dist/src/entrypoint.api.js +55 -88
  7. package/dist/src/entrypoint.api.js.map +1 -1
  8. package/dist/src/entrypoint.cli.d.ts +1 -1
  9. package/dist/src/entrypoint.cli.js +17 -13
  10. package/dist/src/entrypoint.cli.js.map +1 -1
  11. package/dist/src/graphql/generated/gql.d.ts +1 -1
  12. package/dist/src/graphql/generated/gql.js +4 -38
  13. package/dist/src/graphql/generated/gql.js.map +1 -1
  14. package/dist/src/graphql/generated/graphql.d.ts +2000 -1619
  15. package/dist/src/graphql/generated/graphql.js +659 -581
  16. package/dist/src/graphql/generated/graphql.js.map +1 -1
  17. package/dist/src/graphql/generated/index.d.ts +1 -1
  18. package/dist/src/graphql/generated/index.js +1 -17
  19. package/dist/src/graphql/generated/index.js.map +1 -1
  20. package/dist/src/lib/author.d.ts +2 -2
  21. package/dist/src/lib/author.js +1 -4
  22. package/dist/src/lib/author.js.map +1 -1
  23. package/dist/src/lib/backport-error.d.ts +53 -7
  24. package/dist/src/lib/backport-error.js +39 -15
  25. package/dist/src/lib/backport-error.js.map +1 -1
  26. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/auto-merge-now-or-later.d.ts +1 -1
  27. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/auto-merge-now-or-later.js +19 -23
  28. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/auto-merge-now-or-later.js.map +1 -1
  29. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/cherrypick-and-create-target-pull-request.d.ts +2 -3
  30. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/cherrypick-and-create-target-pull-request.js +60 -57
  31. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/cherrypick-and-create-target-pull-request.js.map +1 -1
  32. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/copy-source-pull-request-reviewers-to-target-pull-request.d.ts +2 -2
  33. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/copy-source-pull-request-reviewers-to-target-pull-request.js +7 -10
  34. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/copy-source-pull-request-reviewers-to-target-pull-request.js.map +1 -1
  35. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-backport-branch-name.d.ts +2 -2
  36. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-backport-branch-name.js +6 -12
  37. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-backport-branch-name.js.map +1 -1
  38. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-commits-without-backports.d.ts +2 -2
  39. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-commits-without-backports.js +10 -16
  40. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-commits-without-backports.js.map +1 -1
  41. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-merge-commit.d.ts +2 -2
  42. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-merge-commit.js +6 -9
  43. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-merge-commit.js.map +1 -1
  44. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-configured-target-pr-labels.d.ts +1 -1
  45. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-configured-target-pr-labels.js +7 -10
  46. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-configured-target-pr-labels.js.map +1 -1
  47. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-source-pr-labels-to-copy.d.ts +2 -2
  48. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-source-pr-labels-to-copy.js +3 -6
  49. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-source-pr-labels-to-copy.js.map +1 -1
  50. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-target-prlabels.d.ts +1 -1
  51. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-target-prlabels.js +7 -10
  52. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-target-prlabels.js.map +1 -1
  53. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/list-conflicting-and-unstaged-files.d.ts +7 -0
  54. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/list-conflicting-and-unstaged-files.js +44 -0
  55. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/list-conflicting-and-unstaged-files.js.map +1 -0
  56. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/wait-for-cherrypick.d.ts +6 -4
  57. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/wait-for-cherrypick.js +63 -86
  58. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/wait-for-cherrypick.js.map +1 -1
  59. package/dist/src/lib/child-process-promisified.d.ts +1 -1
  60. package/dist/src/lib/child-process-promisified.js +27 -48
  61. package/dist/src/lib/child-process-promisified.js.map +1 -1
  62. package/dist/src/lib/env.d.ts +3 -3
  63. package/dist/src/lib/env.js +12 -21
  64. package/dist/src/lib/env.js.map +1 -1
  65. package/dist/src/lib/get-commits.d.ts +2 -2
  66. package/dist/src/lib/get-commits.js +30 -32
  67. package/dist/src/lib/get-commits.js.map +1 -1
  68. package/dist/src/lib/get-source-branch-from-commits.d.ts +1 -1
  69. package/dist/src/lib/get-source-branch-from-commits.js +6 -6
  70. package/dist/src/lib/get-source-branch-from-commits.js.map +1 -1
  71. package/dist/src/lib/get-target-branches.d.ts +3 -3
  72. package/dist/src/lib/get-target-branches.js +20 -20
  73. package/dist/src/lib/get-target-branches.js.map +1 -1
  74. package/dist/src/lib/git/branch.d.ts +12 -0
  75. package/dist/src/lib/git/branch.js +83 -0
  76. package/dist/src/lib/git/branch.js.map +1 -0
  77. package/dist/src/lib/git/cherrypick.d.ts +27 -0
  78. package/dist/src/lib/git/cherrypick.js +106 -0
  79. package/dist/src/lib/git/cherrypick.js.map +1 -0
  80. package/dist/src/lib/git/clone.d.ts +4 -0
  81. package/dist/src/lib/git/clone.js +47 -0
  82. package/dist/src/lib/git/clone.js.map +1 -0
  83. package/dist/src/lib/git/commit.d.ts +19 -0
  84. package/dist/src/lib/git/commit.js +86 -0
  85. package/dist/src/lib/git/commit.js.map +1 -0
  86. package/dist/src/lib/git/config-file-status.d.ts +9 -0
  87. package/dist/src/lib/git/config-file-status.js +37 -0
  88. package/dist/src/lib/git/config-file-status.js.map +1 -0
  89. package/dist/src/lib/git/diff.d.ts +12 -0
  90. package/dist/src/lib/git/diff.js +73 -0
  91. package/dist/src/lib/git/diff.js.map +1 -0
  92. package/dist/src/lib/git/index.d.ts +8 -0
  93. package/dist/src/lib/git/index.js +9 -0
  94. package/dist/src/lib/git/index.js.map +1 -0
  95. package/dist/src/lib/git/push.d.ts +10 -0
  96. package/dist/src/lib/git/push.js +36 -0
  97. package/dist/src/lib/git/push.js.map +1 -0
  98. package/dist/src/lib/git/remote.d.ts +13 -0
  99. package/dist/src/lib/git/remote.js +85 -0
  100. package/dist/src/lib/git/remote.js.map +1 -0
  101. package/dist/src/lib/github/commit-formatters.js +4 -9
  102. package/dist/src/lib/github/commit-formatters.js.map +1 -1
  103. package/dist/src/lib/github/v3/add-assignees-to-pull-request.js +11 -26
  104. package/dist/src/lib/github/v3/add-assignees-to-pull-request.js.map +1 -1
  105. package/dist/src/lib/github/v3/add-labels-to-pull-request.js +11 -26
  106. package/dist/src/lib/github/v3/add-labels-to-pull-request.js.map +1 -1
  107. package/dist/src/lib/github/v3/add-reviewers-to-pull-request.d.ts +10 -2
  108. package/dist/src/lib/github/v3/add-reviewers-to-pull-request.js +12 -32
  109. package/dist/src/lib/github/v3/add-reviewers-to-pull-request.js.map +1 -1
  110. package/dist/src/lib/github/v3/{getPullRequest → create-pull-request}/create-pull-request.d.ts +1 -2
  111. package/dist/src/lib/github/v3/create-pull-request/create-pull-request.js +57 -0
  112. package/dist/src/lib/github/v3/create-pull-request/create-pull-request.js.map +1 -0
  113. package/dist/src/lib/github/v3/{getPullRequest → create-pull-request}/get-pull-request-body.d.ts +5 -3
  114. package/dist/src/lib/github/v3/create-pull-request/get-pull-request-body.js +72 -0
  115. package/dist/src/lib/github/v3/create-pull-request/get-pull-request-body.js.map +1 -0
  116. package/dist/src/lib/github/v3/{getPullRequest → create-pull-request}/get-title.d.ts +2 -2
  117. package/dist/src/lib/github/v3/create-pull-request/get-title.js +27 -0
  118. package/dist/src/lib/github/v3/create-pull-request/get-title.js.map +1 -0
  119. package/dist/src/lib/github/v3/create-status-comment.d.ts +2 -2
  120. package/dist/src/lib/github/v3/create-status-comment.js +54 -84
  121. package/dist/src/lib/github/v3/create-status-comment.js.map +1 -1
  122. package/dist/src/lib/github/v3/get-github-v3-error-message.d.ts +2 -14
  123. package/dist/src/lib/github/v3/get-github-v3-error-message.js +4 -6
  124. package/dist/src/lib/github/v3/get-github-v3-error-message.js.map +1 -1
  125. package/dist/src/lib/github/v3/get-reviewers-from-pull-requests.js +14 -21
  126. package/dist/src/lib/github/v3/get-reviewers-from-pull-requests.js.map +1 -1
  127. package/dist/src/lib/github/v3/index.d.ts +13 -0
  128. package/dist/src/lib/github/v3/index.js +13 -0
  129. package/dist/src/lib/github/v3/index.js.map +1 -0
  130. package/dist/src/lib/github/v3/merge-pull-request.d.ts +1 -1
  131. package/dist/src/lib/github/v3/merge-pull-request.js +5 -13
  132. package/dist/src/lib/github/v3/merge-pull-request.js.map +1 -1
  133. package/dist/src/lib/github/v3/octokit-client.d.ts +10 -0
  134. package/dist/src/lib/github/v3/octokit-client.js +30 -0
  135. package/dist/src/lib/github/v3/octokit-client.js.map +1 -0
  136. package/dist/src/lib/github/v4/client/graphql-client.d.ts +17 -12
  137. package/dist/src/lib/github/v4/client/graphql-client.js +69 -23
  138. package/dist/src/lib/github/v4/client/graphql-client.js.map +1 -1
  139. package/dist/src/lib/github/v4/disable-pull-request-auto-merge.d.ts +1 -1
  140. package/dist/src/lib/github/v4/disable-pull-request-auto-merge.js +12 -12
  141. package/dist/src/lib/github/v4/disable-pull-request-auto-merge.js.map +1 -1
  142. package/dist/src/lib/github/v4/enable-pull-request-auto-merge.d.ts +1 -3
  143. package/dist/src/lib/github/v4/enable-pull-request-auto-merge.js +27 -16
  144. package/dist/src/lib/github/v4/enable-pull-request-auto-merge.js.map +1 -1
  145. package/dist/src/lib/github/v4/fetch-author-id.js +10 -10
  146. package/dist/src/lib/github/v4/fetch-author-id.js.map +1 -1
  147. package/dist/src/lib/github/v4/fetch-existing-pull-request.d.ts +2 -2
  148. package/dist/src/lib/github/v4/fetch-existing-pull-request.js +12 -12
  149. package/dist/src/lib/github/v4/fetch-existing-pull-request.js.map +1 -1
  150. package/dist/src/lib/github/v4/fetch-pull-request-auto-merge-method.d.ts +2 -2
  151. package/dist/src/lib/github/v4/fetch-pull-request-auto-merge-method.js +10 -10
  152. package/dist/src/lib/github/v4/fetch-pull-request-auto-merge-method.js.map +1 -1
  153. package/dist/src/lib/github/v4/{fetch-pull-request-id2.d.ts → fetch-pull-request-id.d.ts} +1 -1
  154. package/dist/src/lib/github/v4/fetch-pull-request-id.js +36 -0
  155. package/dist/src/lib/github/v4/fetch-pull-request-id.js.map +1 -0
  156. package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-pull-number.d.ts +2 -2
  157. package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-pull-number.js +26 -21
  158. package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-pull-number.js.map +1 -1
  159. package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-sha.d.ts +2 -2
  160. package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-sha.js +19 -16
  161. package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-sha.js.map +1 -1
  162. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-by-author.d.ts +2 -2
  163. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-by-author.js +41 -33
  164. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-by-author.js.map +1 -1
  165. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-for-rebase-and-merge-strategy.d.ts +1 -1
  166. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-for-rebase-and-merge-strategy.js +16 -16
  167. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-for-rebase-and-merge-strategy.js.map +1 -1
  168. package/dist/src/lib/github/v4/fetchCommits/fetch-pull-requests-by-search-query.d.ts +1 -1
  169. package/dist/src/lib/github/v4/fetchCommits/fetch-pull-requests-by-search-query.js +24 -22
  170. package/dist/src/lib/github/v4/fetchCommits/fetch-pull-requests-by-search-query.js.map +1 -1
  171. package/dist/src/lib/github/v4/get-invalid-access-token-message.d.ts +1 -1
  172. package/dist/src/lib/github/v4/get-invalid-access-token-message.js +18 -17
  173. package/dist/src/lib/github/v4/get-invalid-access-token-message.js.map +1 -1
  174. package/dist/src/lib/github/v4/get-repo-owner-and-name-from-git-remotes.js +18 -19
  175. package/dist/src/lib/github/v4/get-repo-owner-and-name-from-git-remotes.js.map +1 -1
  176. package/dist/src/lib/github/v4/getOptionsFromGithub/get-options-from-github.d.ts +4 -8
  177. package/dist/src/lib/github/v4/getOptionsFromGithub/get-options-from-github.js +48 -42
  178. package/dist/src/lib/github/v4/getOptionsFromGithub/get-options-from-github.js.map +1 -1
  179. package/dist/src/lib/github/v4/index.d.ts +20 -0
  180. package/dist/src/lib/github/v4/index.js +23 -0
  181. package/dist/src/lib/github/v4/index.js.map +1 -0
  182. package/dist/src/lib/github/v4/mocks/commits-by-author-mock.d.ts +1 -1
  183. package/dist/src/lib/github/v4/mocks/commits-by-author-mock.js +3 -6
  184. package/dist/src/lib/github/v4/mocks/commits-by-author-mock.js.map +1 -1
  185. package/dist/src/lib/github/v4/validate-target-branch.js +13 -14
  186. package/dist/src/lib/github/v4/validate-target-branch.js.map +1 -1
  187. package/dist/src/lib/logger.js +15 -56
  188. package/dist/src/lib/logger.js.map +1 -1
  189. package/dist/src/lib/ora.d.ts +4 -4
  190. package/dist/src/lib/ora.js +5 -12
  191. package/dist/src/lib/ora.js.map +1 -1
  192. package/dist/src/lib/prompts.d.ts +2 -2
  193. package/dist/src/lib/prompts.js +56 -59
  194. package/dist/src/lib/prompts.js.map +1 -1
  195. package/dist/src/lib/register-handlebars-helpers.js +5 -11
  196. package/dist/src/lib/register-handlebars-helpers.js.map +1 -1
  197. package/dist/src/lib/remote-config.d.ts +6 -3
  198. package/dist/src/lib/remote-config.js +14 -14
  199. package/dist/src/lib/remote-config.js.map +1 -1
  200. package/dist/src/lib/run-sequentially.d.ts +11 -14
  201. package/dist/src/lib/run-sequentially.js +27 -52
  202. package/dist/src/lib/run-sequentially.js.map +1 -1
  203. package/dist/src/lib/sequential-helper.d.ts +2 -0
  204. package/dist/src/lib/sequential-helper.js +9 -0
  205. package/dist/src/lib/sequential-helper.js.map +1 -0
  206. package/dist/src/lib/setup-repo.d.ts +1 -1
  207. package/dist/src/lib/setup-repo.js +31 -37
  208. package/dist/src/lib/setup-repo.js.map +1 -1
  209. package/dist/src/lib/sourceCommit/get-mock-source-commit.d.ts +1 -1
  210. package/dist/src/lib/sourceCommit/get-mock-source-commit.js +2 -5
  211. package/dist/src/lib/sourceCommit/get-mock-source-commit.js.map +1 -1
  212. package/dist/src/lib/sourceCommit/get-pull-request-states.d.ts +2 -2
  213. package/dist/src/lib/sourceCommit/get-pull-request-states.js +18 -22
  214. package/dist/src/lib/sourceCommit/get-pull-request-states.js.map +1 -1
  215. package/dist/src/lib/sourceCommit/get-source-pull-request.d.ts +22 -2
  216. package/dist/src/lib/sourceCommit/get-source-pull-request.js +2 -5
  217. package/dist/src/lib/sourceCommit/get-source-pull-request.js.map +1 -1
  218. package/dist/src/lib/sourceCommit/is-pull-request-cross-referenced-event.d.ts +1 -1
  219. package/dist/src/lib/sourceCommit/is-pull-request-cross-referenced-event.js +1 -4
  220. package/dist/src/lib/sourceCommit/is-pull-request-cross-referenced-event.js.map +1 -1
  221. package/dist/src/lib/sourceCommit/parse-source-commit.d.ts +3 -3
  222. package/dist/src/lib/sourceCommit/parse-source-commit.js +17 -21
  223. package/dist/src/lib/sourceCommit/parse-source-commit.js.map +1 -1
  224. package/dist/src/options/cli-args.d.ts +19 -19
  225. package/dist/src/options/cli-args.js +29 -25
  226. package/dist/src/options/cli-args.js.map +1 -1
  227. package/dist/src/options/config/config.d.ts +6 -10
  228. package/dist/src/options/config/config.js +5 -8
  229. package/dist/src/options/config/config.js.map +1 -1
  230. package/dist/src/options/config/global-config.d.ts +1 -1
  231. package/dist/src/options/config/global-config.js +22 -28
  232. package/dist/src/options/config/global-config.js.map +1 -1
  233. package/dist/src/options/config/project-config.d.ts +1 -1
  234. package/dist/src/options/config/project-config.js +7 -13
  235. package/dist/src/options/config/project-config.js.map +1 -1
  236. package/dist/src/options/config/read-config-file.d.ts +1 -1
  237. package/dist/src/options/config/read-config-file.js +16 -20
  238. package/dist/src/options/config/read-config-file.js.map +1 -1
  239. package/dist/src/options/config-options.d.ts +3 -1
  240. package/dist/src/options/config-options.js +1 -2
  241. package/dist/src/options/option-schema.d.ts +189 -0
  242. package/dist/src/options/option-schema.js +123 -0
  243. package/dist/src/options/option-schema.js.map +1 -0
  244. package/dist/src/options/options.d.ts +6 -119
  245. package/dist/src/options/options.js +65 -108
  246. package/dist/src/options/options.js.map +1 -1
  247. package/dist/src/scripts/postinstall.js +10 -13
  248. package/dist/src/scripts/postinstall.js.map +1 -1
  249. package/dist/src/scripts/run-postinstall.js +2 -4
  250. package/dist/src/scripts/run-postinstall.js.map +1 -1
  251. package/dist/src/types/index.d.ts +10 -0
  252. package/dist/src/types/index.js +6 -0
  253. package/dist/src/types/index.js.map +1 -0
  254. package/dist/src/utils/exclude-undefined.js +1 -4
  255. package/dist/src/utils/exclude-undefined.js.map +1 -1
  256. package/dist/src/utils/filter-empty.js +1 -4
  257. package/dist/src/utils/filter-empty.js.map +1 -1
  258. package/dist/src/utils/filter-unmerged-commits.d.ts +1 -1
  259. package/dist/src/utils/filter-unmerged-commits.js +1 -4
  260. package/dist/src/utils/filter-unmerged-commits.js.map +1 -1
  261. package/dist/src/utils/is-errno-error.js +1 -4
  262. package/dist/src/utils/is-errno-error.js.map +1 -1
  263. package/dist/src/utils/package-version.d.ts +1 -1
  264. package/dist/src/utils/package-version.js +20 -9
  265. package/dist/src/utils/package-version.js.map +1 -1
  266. package/package.json +66 -71
  267. package/dist/package.json +0 -125
  268. package/dist/src/entrypoint.module.private.test.d.ts +0 -1
  269. package/dist/src/entrypoint.module.private.test.js +0 -501
  270. package/dist/src/entrypoint.module.private.test.js.map +0 -1
  271. package/dist/src/lib/apm.d.ts +0 -1
  272. package/dist/src/lib/apm.js +0 -33
  273. package/dist/src/lib/apm.js.map +0 -1
  274. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/cherrypick-and-create-target-pull-request.test.d.ts +0 -1
  275. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/cherrypick-and-create-target-pull-request.test.js +0 -371
  276. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/cherrypick-and-create-target-pull-request.test.js.map +0 -1
  277. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-backport-branch-name.test.d.ts +0 -1
  278. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-backport-branch-name.test.js +0 -74
  279. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-backport-branch-name.test.js.map +0 -1
  280. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-commits-without-backports.test.d.ts +0 -1
  281. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-commits-without-backports.test.js +0 -382
  282. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/get-commits-without-backports.test.js.map +0 -1
  283. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-configured-target-pr-labels.test.d.ts +0 -1
  284. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-configured-target-pr-labels.test.js +0 -126
  285. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-configured-target-pr-labels.test.js.map +0 -1
  286. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-source-pr-labels-to-copy.test.d.ts +0 -1
  287. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-source-pr-labels-to-copy.test.js +0 -85
  288. package/dist/src/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels/get-source-pr-labels-to-copy.test.js.map +0 -1
  289. package/dist/src/lib/env.test.d.ts +0 -1
  290. package/dist/src/lib/env.test.js +0 -27
  291. package/dist/src/lib/env.test.js.map +0 -1
  292. package/dist/src/lib/get-target-branches.test.d.ts +0 -1
  293. package/dist/src/lib/get-target-branches.test.js +0 -263
  294. package/dist/src/lib/get-target-branches.test.js.map +0 -1
  295. package/dist/src/lib/git.d.ts +0 -89
  296. package/dist/src/lib/git.js +0 -537
  297. package/dist/src/lib/git.js.map +0 -1
  298. package/dist/src/lib/git.private.test.d.ts +0 -1
  299. package/dist/src/lib/git.private.test.js +0 -619
  300. package/dist/src/lib/git.private.test.js.map +0 -1
  301. package/dist/src/lib/git.test.d.ts +0 -1
  302. package/dist/src/lib/git.test.js +0 -1053
  303. package/dist/src/lib/git.test.js.map +0 -1
  304. package/dist/src/lib/github/commit-formatters.test.d.ts +0 -1
  305. package/dist/src/lib/github/commit-formatters.test.js +0 -12
  306. package/dist/src/lib/github/commit-formatters.test.js.map +0 -1
  307. package/dist/src/lib/github/v3/add-assignees-to-pull-request.test.d.ts +0 -1
  308. package/dist/src/lib/github/v3/add-assignees-to-pull-request.test.js +0 -31
  309. package/dist/src/lib/github/v3/add-assignees-to-pull-request.test.js.map +0 -1
  310. package/dist/src/lib/github/v3/create-status-comment.test.d.ts +0 -1
  311. package/dist/src/lib/github/v3/create-status-comment.test.js +0 -664
  312. package/dist/src/lib/github/v3/create-status-comment.test.js.map +0 -1
  313. package/dist/src/lib/github/v3/get-reviewers-from-pull-requests.ts.private.test.d.ts +0 -1
  314. package/dist/src/lib/github/v3/get-reviewers-from-pull-requests.ts.private.test.js +0 -34
  315. package/dist/src/lib/github/v3/get-reviewers-from-pull-requests.ts.private.test.js.map +0 -1
  316. package/dist/src/lib/github/v3/getPullRequest/create-pull-request.js +0 -67
  317. package/dist/src/lib/github/v3/getPullRequest/create-pull-request.js.map +0 -1
  318. package/dist/src/lib/github/v3/getPullRequest/get-pull-request-body.js +0 -63
  319. package/dist/src/lib/github/v3/getPullRequest/get-pull-request-body.js.map +0 -1
  320. package/dist/src/lib/github/v3/getPullRequest/get-pull-request-body.test.d.ts +0 -1
  321. package/dist/src/lib/github/v3/getPullRequest/get-pull-request-body.test.js +0 -447
  322. package/dist/src/lib/github/v3/getPullRequest/get-pull-request-body.test.js.map +0 -1
  323. package/dist/src/lib/github/v3/getPullRequest/get-title.js +0 -33
  324. package/dist/src/lib/github/v3/getPullRequest/get-title.js.map +0 -1
  325. package/dist/src/lib/github/v3/getPullRequest/get-title.test.d.ts +0 -1
  326. package/dist/src/lib/github/v3/getPullRequest/get-title.test.js +0 -111
  327. package/dist/src/lib/github/v3/getPullRequest/get-title.test.js.map +0 -1
  328. package/dist/src/lib/github/v4/client/graphql-client.private.test.d.ts +0 -1
  329. package/dist/src/lib/github/v4/client/graphql-client.private.test.js +0 -93
  330. package/dist/src/lib/github/v4/client/graphql-client.private.test.js.map +0 -1
  331. package/dist/src/lib/github/v4/client/logging-exchange.d.ts +0 -2
  332. package/dist/src/lib/github/v4/client/logging-exchange.js +0 -21
  333. package/dist/src/lib/github/v4/client/logging-exchange.js.map +0 -1
  334. package/dist/src/lib/github/v4/client/response-meta-interceptor-exchange.d.ts +0 -2
  335. package/dist/src/lib/github/v4/client/response-meta-interceptor-exchange.js +0 -45
  336. package/dist/src/lib/github/v4/client/response-meta-interceptor-exchange.js.map +0 -1
  337. package/dist/src/lib/github/v4/enable-pull-request-auto-merge.mutation.test.d.ts +0 -1
  338. package/dist/src/lib/github/v4/enable-pull-request-auto-merge.mutation.test.js +0 -245
  339. package/dist/src/lib/github/v4/enable-pull-request-auto-merge.mutation.test.js.map +0 -1
  340. package/dist/src/lib/github/v4/fetch-author-id.private.test.d.ts +0 -1
  341. package/dist/src/lib/github/v4/fetch-author-id.private.test.js +0 -26
  342. package/dist/src/lib/github/v4/fetch-author-id.private.test.js.map +0 -1
  343. package/dist/src/lib/github/v4/fetch-existing-pull-request.private.test.d.ts +0 -1
  344. package/dist/src/lib/github/v4/fetch-existing-pull-request.private.test.js +0 -47
  345. package/dist/src/lib/github/v4/fetch-existing-pull-request.private.test.js.map +0 -1
  346. package/dist/src/lib/github/v4/fetch-pull-request-id2.js +0 -33
  347. package/dist/src/lib/github/v4/fetch-pull-request-id2.js.map +0 -1
  348. package/dist/src/lib/github/v4/fetchCommits/all-fetchers.private.test.d.ts +0 -1
  349. package/dist/src/lib/github/v4/fetchCommits/all-fetchers.private.test.js +0 -126
  350. package/dist/src/lib/github/v4/fetchCommits/all-fetchers.private.test.js.map +0 -1
  351. package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-pull-number.private.test.d.ts +0 -1
  352. package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-pull-number.private.test.js +0 -110
  353. package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-pull-number.private.test.js.map +0 -1
  354. package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-sha.private.test.d.ts +0 -1
  355. package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-sha.private.test.js +0 -76
  356. package/dist/src/lib/github/v4/fetchCommits/fetch-commit-by-sha.private.test.js.map +0 -1
  357. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-by-author.private.test.d.ts +0 -1
  358. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-by-author.private.test.js +0 -179
  359. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-by-author.private.test.js.map +0 -1
  360. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-by-author.test.d.ts +0 -1
  361. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-by-author.test.js +0 -168
  362. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-by-author.test.js.map +0 -1
  363. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-for-rebase-and-merge-strategy.private.test.d.ts +0 -1
  364. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-for-rebase-and-merge-strategy.private.test.js +0 -30
  365. package/dist/src/lib/github/v4/fetchCommits/fetch-commits-for-rebase-and-merge-strategy.private.test.js.map +0 -1
  366. package/dist/src/lib/github/v4/fetchCommits/fetch-pull-request-by-search-query.private.test.d.ts +0 -1
  367. package/dist/src/lib/github/v4/fetchCommits/fetch-pull-request-by-search-query.private.test.js +0 -150
  368. package/dist/src/lib/github/v4/fetchCommits/fetch-pull-request-by-search-query.private.test.js.map +0 -1
  369. package/dist/src/lib/github/v4/get-invalid-access-token-message.test.d.ts +0 -1
  370. package/dist/src/lib/github/v4/get-invalid-access-token-message.test.js +0 -99
  371. package/dist/src/lib/github/v4/get-invalid-access-token-message.test.js.map +0 -1
  372. package/dist/src/lib/github/v4/get-repo-owner-and-name-from-git-remotes.private.test.d.ts +0 -1
  373. package/dist/src/lib/github/v4/get-repo-owner-and-name-from-git-remotes.private.test.js +0 -50
  374. package/dist/src/lib/github/v4/get-repo-owner-and-name-from-git-remotes.private.test.js.map +0 -1
  375. package/dist/src/lib/github/v4/getOptionsFromGithub/get-options-from-github.private.test.d.ts +0 -1
  376. package/dist/src/lib/github/v4/getOptionsFromGithub/get-options-from-github.private.test.js +0 -119
  377. package/dist/src/lib/github/v4/getOptionsFromGithub/get-options-from-github.private.test.js.map +0 -1
  378. package/dist/src/lib/github/v4/validate-target-branch.private.test.d.ts +0 -1
  379. package/dist/src/lib/github/v4/validate-target-branch.private.test.js +0 -24
  380. package/dist/src/lib/github/v4/validate-target-branch.private.test.js.map +0 -1
  381. package/dist/src/lib/prompt.test.d.ts +0 -1
  382. package/dist/src/lib/prompt.test.js +0 -181
  383. package/dist/src/lib/prompt.test.js.map +0 -1
  384. package/dist/src/lib/sequentially.d.ts +0 -1
  385. package/dist/src/lib/sequentially.js +0 -11
  386. package/dist/src/lib/sequentially.js.map +0 -1
  387. package/dist/src/lib/setup-repo.test.d.ts +0 -1
  388. package/dist/src/lib/setup-repo.test.js +0 -283
  389. package/dist/src/lib/setup-repo.test.js.map +0 -1
  390. package/dist/src/lib/sourceCommit/get-pull-request-states.test.d.ts +0 -1
  391. package/dist/src/lib/sourceCommit/get-pull-request-states.test.js +0 -706
  392. package/dist/src/lib/sourceCommit/get-pull-request-states.test.js.map +0 -1
  393. package/dist/src/lib/sourceCommit/parse-source-commit.test.d.ts +0 -1
  394. package/dist/src/lib/sourceCommit/parse-source-commit.test.js +0 -295
  395. package/dist/src/lib/sourceCommit/parse-source-commit.test.js.map +0 -1
  396. package/dist/src/options/cli-args.test.d.ts +0 -1
  397. package/dist/src/options/cli-args.test.js +0 -307
  398. package/dist/src/options/cli-args.test.js.map +0 -1
  399. package/dist/src/options/config/config.test.d.ts +0 -1
  400. package/dist/src/options/config/config.test.js +0 -32
  401. package/dist/src/options/config/config.test.js.map +0 -1
  402. package/dist/src/options/config/global-config.test.d.ts +0 -1
  403. package/dist/src/options/config/global-config.test.js +0 -62
  404. package/dist/src/options/config/global-config.test.js.map +0 -1
  405. package/dist/src/options/config/project-config.test.d.ts +0 -1
  406. package/dist/src/options/config/project-config.test.js +0 -110
  407. package/dist/src/options/config/project-config.test.js.map +0 -1
  408. package/dist/src/options/options.test.d.ts +0 -1
  409. package/dist/src/options/options.test.js +0 -505
  410. package/dist/src/options/options.test.js.map +0 -1
  411. package/dist/src/scripts/binary.integration.test.d.ts +0 -1
  412. package/dist/src/scripts/binary.integration.test.js +0 -87
  413. package/dist/src/scripts/binary.integration.test.js.map +0 -1
  414. package/dist/src/scripts/postinstall.integration.test.d.ts +0 -1
  415. package/dist/src/scripts/postinstall.integration.test.js +0 -92
  416. package/dist/src/scripts/postinstall.integration.test.js.map +0 -1
  417. package/dist/src/scripts/postinstall.test.d.ts +0 -1
  418. package/dist/src/scripts/postinstall.test.js +0 -68
  419. package/dist/src/scripts/postinstall.test.js.map +0 -1
  420. package/dist/src/test/child-process-helper.d.ts +0 -7
  421. package/dist/src/test/child-process-helper.js +0 -19
  422. package/dist/src/test/child-process-helper.js.map +0 -1
  423. package/dist/src/test/e2e/cli/binary.private.test.d.ts +0 -1
  424. package/dist/src/test/e2e/cli/binary.private.test.js +0 -53
  425. package/dist/src/test/e2e/cli/binary.private.test.js.map +0 -1
  426. package/dist/src/test/e2e/cli/commit-author.private.test.d.ts +0 -1
  427. package/dist/src/test/e2e/cli/commit-author.private.test.js +0 -79
  428. package/dist/src/test/e2e/cli/commit-author.private.test.js.map +0 -1
  429. package/dist/src/test/e2e/cli/copy-reviewers-to-target-pull-request.private.test.d.ts +0 -1
  430. package/dist/src/test/e2e/cli/copy-reviewers-to-target-pull-request.private.test.js +0 -63
  431. package/dist/src/test/e2e/cli/copy-reviewers-to-target-pull-request.private.test.js.map +0 -1
  432. package/dist/src/test/e2e/cli/date-filters.private.test.d.ts +0 -1
  433. package/dist/src/test/e2e/cli/date-filters.private.test.js +0 -56
  434. package/dist/src/test/e2e/cli/date-filters.private.test.js.map +0 -1
  435. package/dist/src/test/e2e/cli/different-merge-strategies.private.test.d.ts +0 -1
  436. package/dist/src/test/e2e/cli/different-merge-strategies.private.test.js +0 -260
  437. package/dist/src/test/e2e/cli/different-merge-strategies.private.test.js.map +0 -1
  438. package/dist/src/test/e2e/cli/entrypoint.cli.private.test.d.ts +0 -1
  439. package/dist/src/test/e2e/cli/entrypoint.cli.private.test.js +0 -228
  440. package/dist/src/test/e2e/cli/entrypoint.cli.private.test.js.map +0 -1
  441. package/dist/src/test/e2e/cli/error-handling-interactive-mode.private.test.d.ts +0 -1
  442. package/dist/src/test/e2e/cli/error-handling-interactive-mode.private.test.js +0 -91
  443. package/dist/src/test/e2e/cli/error-handling-interactive-mode.private.test.js.map +0 -1
  444. package/dist/src/test/e2e/cli/error-handling-non-interactive-mode.private.test.d.ts +0 -1
  445. package/dist/src/test/e2e/cli/error-handling-non-interactive-mode.private.test.js +0 -203
  446. package/dist/src/test/e2e/cli/error-handling-non-interactive-mode.private.test.js.map +0 -1
  447. package/dist/src/test/e2e/cli/gracefully-handles-corrupt-repo.private.test.d.ts +0 -1
  448. package/dist/src/test/e2e/cli/gracefully-handles-corrupt-repo.private.test.js +0 -57
  449. package/dist/src/test/e2e/cli/gracefully-handles-corrupt-repo.private.test.js.map +0 -1
  450. package/dist/src/test/e2e/cli/repo-with-backportrc-removed.private.test.d.ts +0 -1
  451. package/dist/src/test/e2e/cli/repo-with-backportrc-removed.private.test.js +0 -51
  452. package/dist/src/test/e2e/cli/repo-with-backportrc-removed.private.test.js.map +0 -1
  453. package/dist/src/test/e2e/cli/repo-with-changing-branch-label-mapping.private.test.d.ts +0 -1
  454. package/dist/src/test/e2e/cli/repo-with-changing-branch-label-mapping.private.test.js +0 -98
  455. package/dist/src/test/e2e/cli/repo-with-changing-branch-label-mapping.private.test.js.map +0 -1
  456. package/dist/src/test/e2e/cli/repo-with-programatically-added-commits.mutation.test.d.ts +0 -1
  457. package/dist/src/test/e2e/cli/repo-with-programatically-added-commits.mutation.test.js +0 -114
  458. package/dist/src/test/e2e/cli/repo-with-programatically-added-commits.mutation.test.js.map +0 -1
  459. package/dist/src/test/e2e/cli/run-backport-via-cli.d.ts +0 -21
  460. package/dist/src/test/e2e/cli/run-backport-via-cli.js +0 -104
  461. package/dist/src/test/e2e/cli/run-backport-via-cli.js.map +0 -1
  462. package/dist/src/test/e2e/cli/test-that-repo-can-be-cloned.private.test.d.ts +0 -1
  463. package/dist/src/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +0 -91
  464. package/dist/src/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js.map +0 -1
  465. package/dist/src/test/e2e/module/entrypoint.module.mutation.test.d.ts +0 -1
  466. package/dist/src/test/e2e/module/entrypoint.module.mutation.test.js +0 -378
  467. package/dist/src/test/e2e/module/entrypoint.module.mutation.test.js.map +0 -1
  468. package/dist/src/test/handle-unbackported-pull-requests.private.test.d.ts +0 -1
  469. package/dist/src/test/handle-unbackported-pull-requests.private.test.js +0 -71
  470. package/dist/src/test/handle-unbackported-pull-requests.private.test.js.map +0 -1
  471. package/dist/src/test/mock-config-files.d.ts +0 -5
  472. package/dist/src/test/mock-config-files.js +0 -21
  473. package/dist/src/test/mock-config-files.js.map +0 -1
  474. package/dist/src/test/nock-helpers.d.ts +0 -18
  475. package/dist/src/test/nock-helpers.js +0 -33
  476. package/dist/src/test/nock-helpers.js.map +0 -1
  477. package/dist/src/test/private/get-dev-access-token.d.ts +0 -2
  478. package/dist/src/test/private/get-dev-access-token.js +0 -12
  479. package/dist/src/test/private/get-dev-access-token.js.map +0 -1
  480. package/dist/src/test/replace-string-and-linebreaks.d.ts +0 -6
  481. package/dist/src/test/replace-string-and-linebreaks.js +0 -14
  482. package/dist/src/test/replace-string-and-linebreaks.js.map +0 -1
  483. package/dist/src/test/sandbox.d.ts +0 -6
  484. package/dist/src/test/sandbox.js +0 -63
  485. package/dist/src/test/sandbox.js.map +0 -1
  486. package/dist/src/test/setupFiles/automatic-mocks.d.ts +0 -1
  487. package/dist/src/test/setupFiles/automatic-mocks.js +0 -79
  488. package/dist/src/test/setupFiles/automatic-mocks.js.map +0 -1
  489. package/dist/src/test/setupFiles/jest-retry.d.ts +0 -0
  490. package/dist/src/test/setupFiles/jest-retry.js +0 -3
  491. package/dist/src/test/setupFiles/jest-retry.js.map +0 -1
  492. package/dist/src/test/setupFiles/nock-cleanup.d.ts +0 -1
  493. package/dist/src/test/setupFiles/nock-cleanup.js +0 -16
  494. package/dist/src/test/setupFiles/nock-cleanup.js.map +0 -1
  495. package/dist/src/utils/exclude-undefined.test.d.ts +0 -1
  496. package/dist/src/utils/exclude-undefined.test.js +0 -25
  497. package/dist/src/utils/exclude-undefined.test.js.map +0 -1
  498. package/dist/src/utils/maybe.d.ts +0 -1
  499. package/dist/src/utils/maybe.js +0 -7
  500. package/dist/src/utils/maybe.js.map +0 -1
  501. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,1053 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- const os_1 = __importDefault(require("os"));
40
- const childProcess = __importStar(require("./child-process-promisified"));
41
- const git_1 = require("./git");
42
- beforeEach(() => {
43
- jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
44
- });
45
- afterEach(() => {
46
- jest.restoreAllMocks();
47
- });
48
- const commitAuthor = { name: 'Soren L', email: 'soren@mail.dk' };
49
- describe('getUnstagedFiles', () => {
50
- it('should split lines and remove empty', async () => {
51
- jest.spyOn(childProcess, 'spawnPromise').mockResolvedValueOnce({
52
- stdout: 'conflicting-file.txt\nconflicting-file2.txt\n',
53
- stderr: '',
54
- code: 0,
55
- cmdArgs: [],
56
- });
57
- const options = {
58
- repoOwner: 'elastic',
59
- repoName: 'kibana',
60
- };
61
- await expect((0, git_1.getUnstagedFiles)(options)).resolves.toEqual([
62
- '/myHomeDir/.backport/repositories/elastic/kibana/conflicting-file.txt',
63
- '/myHomeDir/.backport/repositories/elastic/kibana/conflicting-file2.txt',
64
- ]);
65
- });
66
- it('should not error on empty', async () => {
67
- jest.spyOn(childProcess, 'spawnPromise').mockResolvedValueOnce({
68
- stdout: '',
69
- stderr: '',
70
- code: 0,
71
- cmdArgs: [],
72
- });
73
- const options = {
74
- repoOwner: 'elastic',
75
- repoName: 'kibana',
76
- };
77
- await expect((0, git_1.getUnstagedFiles)(options)).resolves.toEqual([]);
78
- });
79
- });
80
- describe('getStagedFiles', () => {
81
- it('should split lines and remove empty', async () => {
82
- jest.spyOn(childProcess, 'spawnPromise').mockResolvedValueOnce({
83
- stdout: 'staged-file.txt\nstaged-file2.txt\n',
84
- stderr: '',
85
- code: 0,
86
- cmdArgs: [],
87
- });
88
- const options = {
89
- repoOwner: 'elastic',
90
- repoName: 'kibana',
91
- };
92
- await expect((0, git_1.getStagedFiles)(options)).resolves.toEqual([
93
- '/myHomeDir/.backport/repositories/elastic/kibana/staged-file.txt',
94
- '/myHomeDir/.backport/repositories/elastic/kibana/staged-file2.txt',
95
- ]);
96
- });
97
- it('should not error on empty', async () => {
98
- jest.spyOn(childProcess, 'spawnPromise').mockResolvedValueOnce({
99
- stdout: '',
100
- stderr: '',
101
- code: 0,
102
- cmdArgs: [],
103
- });
104
- const options = {
105
- repoOwner: 'elastic',
106
- repoName: 'kibana',
107
- };
108
- await expect((0, git_1.getStagedFiles)(options)).resolves.toEqual([]);
109
- });
110
- });
111
- describe('getLocalConfigFileCommitDate', () => {
112
- it('returns a timestamp the file exists', async () => {
113
- const res = {
114
- stdout: 'Wed Dec 16 10:10:39 2020 -0800\n',
115
- stderr: '',
116
- code: 0,
117
- cmdArgs: [],
118
- };
119
- jest.spyOn(childProcess, 'spawnPromise').mockResolvedValue(res);
120
- expect(await (0, git_1.getLocalConfigFileCommitDate)({ cwd: 'foo/bar' })).toEqual(1608142239000);
121
- });
122
- it('returns empty when file does not exists', async () => {
123
- const res = { stdout: '', stderr: '', code: 0, cmdArgs: [] };
124
- jest.spyOn(childProcess, 'spawnPromise').mockResolvedValue(res);
125
- expect(await (0, git_1.getLocalConfigFileCommitDate)({ cwd: 'foo/bar' })).toEqual(undefined);
126
- });
127
- it('handles errors', async () => {
128
- const err = {
129
- killed: false,
130
- code: 128,
131
- signal: null,
132
- cmd: 'any command...',
133
- stdout: '',
134
- stderr: 'any error',
135
- };
136
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
137
- expect(await (0, git_1.getLocalConfigFileCommitDate)({ cwd: 'foo/bar' })).toEqual(undefined);
138
- });
139
- });
140
- describe('isLocalConfigFileUntracked', () => {
141
- it('returns "false" if file does not exist', async () => {
142
- const res = { stdout: '', stderr: '', code: 0, cmdArgs: [] };
143
- jest.spyOn(childProcess, 'spawnPromise').mockResolvedValue(res);
144
- expect(await (0, git_1.isLocalConfigFileUntracked)({ cwd: 'foo/bar' })).toEqual(false);
145
- });
146
- it('returns "true" if file is untracked', async () => {
147
- const res = {
148
- stdout: '.backportrc.json\n',
149
- stderr: '',
150
- code: 0,
151
- cmdArgs: [],
152
- };
153
- jest.spyOn(childProcess, 'spawnPromise').mockResolvedValue(res);
154
- expect(await (0, git_1.isLocalConfigFileUntracked)({ cwd: 'foo/bar' })).toEqual(true);
155
- });
156
- it('handles errors', async () => {
157
- const err = {
158
- killed: false,
159
- code: 128,
160
- signal: null,
161
- cmd: 'any command...',
162
- stdout: '',
163
- stderr: 'any error',
164
- };
165
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
166
- expect(await (0, git_1.isLocalConfigFileUntracked)({ cwd: 'foo/bar' })).toEqual(undefined);
167
- });
168
- });
169
- describe('isLocalConfigFileModified', () => {
170
- it('returns "false" if file does not exist', async () => {
171
- const res = { stdout: '', stderr: '', code: 0, cmdArgs: [] };
172
- jest.spyOn(childProcess, 'spawnPromise').mockResolvedValue(res);
173
- expect(await (0, git_1.isLocalConfigFileModified)({ cwd: 'foo/bar' })).toEqual(false);
174
- });
175
- it('returns "false" if file is untracked', async () => {
176
- const res = { stdout: '', stderr: '', code: 0, cmdArgs: [] };
177
- jest.spyOn(childProcess, 'spawnPromise').mockResolvedValue(res);
178
- expect(await (0, git_1.isLocalConfigFileModified)({ cwd: 'foo/bar' })).toEqual(false);
179
- });
180
- it('returns "true" if file is staged', async () => {
181
- const res = {
182
- stdout: '.backportrc.json\n',
183
- stderr: '',
184
- code: 0,
185
- cmdArgs: [],
186
- };
187
- jest.spyOn(childProcess, 'spawnPromise').mockResolvedValue(res);
188
- expect(await (0, git_1.isLocalConfigFileModified)({ cwd: 'foo/bar' })).toEqual(true);
189
- });
190
- it('handles errors', async () => {
191
- const err = {
192
- killed: false,
193
- code: 128,
194
- signal: null,
195
- cmd: 'any command...',
196
- stdout: '',
197
- stderr: 'any error',
198
- };
199
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
200
- expect(await (0, git_1.isLocalConfigFileModified)({ cwd: 'foo/bar' })).toBe(false);
201
- });
202
- });
203
- describe('getRepoInfoFromGitRemotes', () => {
204
- it('returns repoName and repoOwner ssh remotes', async () => {
205
- const res = {
206
- stdout: 'john.doe\tgit@github.com:john.doe/kibana (fetch)\n' +
207
- 'john.doe\tgit@github.com:john.doe/kibana (push)\n' +
208
- 'elastic\tgit@github.com:elastic/kibana.git (fetch)\n' +
209
- 'elastic\tgit@github.com:elastic/kibana.git (push)\n' +
210
- 'peter\tgit@github.com:peter/kibana (fetch)\n' +
211
- 'peter\tgit@github.com:peter/kibana (push)\n' +
212
- 'sorenlouv\tgit@github.com:sorenlouv/kibana.git (fetch)\n' +
213
- 'sorenlouv\tgit@github.com:sorenlouv/kibana.git (push)\n',
214
- stderr: '',
215
- code: 0,
216
- cmdArgs: [],
217
- };
218
- jest.spyOn(childProcess, 'spawnPromise').mockResolvedValue(res);
219
- expect(await (0, git_1.getRepoInfoFromGitRemotes)({ cwd: 'foo/bar' })).toEqual([
220
- { repoName: 'kibana', repoOwner: 'john.doe' },
221
- { repoName: 'kibana', repoOwner: 'elastic' },
222
- { repoName: 'kibana', repoOwner: 'peter' },
223
- { repoName: 'kibana', repoOwner: 'sorenlouv' },
224
- ]);
225
- });
226
- it('returns repoName and repoOwner https remotes', async () => {
227
- jest.spyOn(childProcess, 'spawnPromise').mockResolvedValue({
228
- stdout: 'origin\thttps://github.com/shay/elasticsearch.git (fetch)\n' +
229
- 'origin\thttps://github.com/shay/elasticsearch.git (push)\n',
230
- stderr: '',
231
- code: 0,
232
- cmdArgs: [],
233
- });
234
- expect(await (0, git_1.getRepoInfoFromGitRemotes)({ cwd: 'foo/bar' })).toEqual([
235
- { repoName: 'elasticsearch', repoOwner: 'shay' },
236
- ]);
237
- });
238
- it('returns undefined when no remotes exist', async () => {
239
- const res = { stdout: '', stderr: '', code: 0, cmdArgs: [] };
240
- jest.spyOn(childProcess, 'spawnPromise').mockResolvedValue(res);
241
- expect(await (0, git_1.getRepoInfoFromGitRemotes)({ cwd: 'foo/bar' })).toEqual([]);
242
- });
243
- it('handles errors', async () => {
244
- const err = {
245
- killed: false,
246
- code: 128,
247
- signal: null,
248
- cmd: 'git ls-files .backportrc.js* --exclude-standard --others',
249
- stdout: '',
250
- stderr: 'fatal: not a git repository (or any of the parent directories): .git\n',
251
- };
252
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
253
- expect(await (0, git_1.getRepoInfoFromGitRemotes)({ cwd: 'foo/bar' })).toEqual([]);
254
- });
255
- });
256
- describe('getConflictingFiles', () => {
257
- it('should split by linebreak and remove empty and duplicate items', async () => {
258
- const err = new childProcess.SpawnError({
259
- code: 2,
260
- cmdArgs: ['--no-pager', 'diff', '--check'],
261
- stdout: 'conflicting-file.txt:1: leftover conflict marker\nconflicting-file.txt:3: leftover conflict marker\nconflicting-file.txt:5: leftover conflict marker\n',
262
- stderr: '',
263
- });
264
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
265
- const options = {
266
- repoOwner: 'elastic',
267
- repoName: 'kibana',
268
- };
269
- expect(await (0, git_1.getConflictingFiles)(options)).toEqual([
270
- {
271
- absolute: '/myHomeDir/.backport/repositories/elastic/kibana/conflicting-file.txt',
272
- relative: 'conflicting-file.txt',
273
- },
274
- ]);
275
- });
276
- });
277
- describe('createBackportBranch', () => {
278
- const options = {
279
- repoOwner: 'elastic',
280
- repoName: 'kibana',
281
- };
282
- const sourceBranch = 'main';
283
- const targetBranch = '4.x';
284
- const backportBranch = 'backport/4.x/commit-72f94e76';
285
- it(`should handle "couldn't find remote ref" error`, async () => {
286
- expect.assertions(1);
287
- const err = new childProcess.SpawnError({
288
- code: 128,
289
- cmdArgs: [],
290
- stdout: 'HEAD is now at 72f94e7 Create "conflicting-file.txt" in master\n',
291
- stderr: "fatal: couldn't find remote ref 4.x\n",
292
- });
293
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
294
- await expect((0, git_1.createBackportBranch)({
295
- options,
296
- sourceBranch,
297
- targetBranch,
298
- backportBranch,
299
- })).rejects.toThrowErrorMatchingInlineSnapshot(`"The branch "4.x" is invalid or doesn't exist"`);
300
- });
301
- it('should throw "Invalid refspec" error', async () => {
302
- expect.assertions(1);
303
- const err = new childProcess.SpawnError({
304
- code: 128,
305
- cmdArgs: [],
306
- stdout: '',
307
- stderr: "fatal: Invalid refspec 'https://github.com/elastic/kibana.git'\n",
308
- });
309
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
310
- await expect((0, git_1.createBackportBranch)({
311
- options,
312
- sourceBranch,
313
- targetBranch,
314
- backportBranch,
315
- })).rejects.toThrowErrorMatchingInlineSnapshot(`"The remote "'https://github.com/elastic/kibana.git'" is invalid or doesn't exist"`);
316
- });
317
- it('should throw "is not a commit" error', async () => {
318
- expect.assertions(1);
319
- const err = new childProcess.SpawnError({
320
- code: 128,
321
- cmdArgs: [],
322
- stdout: '',
323
- stderr: "fatal: 'origin/remote-branch-name' is not a commit and a branch 'local-branch-name' cannot be created from it",
324
- });
325
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
326
- await expect((0, git_1.createBackportBranch)({
327
- options,
328
- sourceBranch,
329
- targetBranch,
330
- backportBranch,
331
- })).rejects.toThrowErrorMatchingInlineSnapshot(`"The branch "origin/remote-branch-name'" is invalid or doesn't exist"`);
332
- });
333
- it('should rethrow normal error', async () => {
334
- expect.assertions(1);
335
- const err = new Error('just a normal error');
336
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
337
- expect.assertions(1);
338
- await expect((0, git_1.createBackportBranch)({
339
- options,
340
- sourceBranch,
341
- targetBranch,
342
- backportBranch,
343
- })).rejects.toThrowErrorMatchingInlineSnapshot(`"just a normal error"`);
344
- });
345
- });
346
- describe('deleteRemote', () => {
347
- const remoteName = 'my-remote';
348
- const options = {
349
- repoOwner: 'elastic',
350
- repoName: 'kibana',
351
- };
352
- it('should swallow "no such remote" error on git before 2.30.0', async () => {
353
- const err = new childProcess.SpawnError({
354
- code: 128,
355
- cmdArgs: [],
356
- stdout: '',
357
- stderr: "fatal: No such remote: 'my-remote'\n",
358
- });
359
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
360
- await expect(await (0, git_1.deleteRemote)(options, remoteName)).toBe(undefined);
361
- });
362
- it('should swallow "no such remote" error on git 2.30.0 or later', async () => {
363
- const err = new childProcess.SpawnError({
364
- code: 2,
365
- cmdArgs: [],
366
- stdout: '',
367
- stderr: "fatal: No such remote: 'my-remote'\n",
368
- });
369
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
370
- await expect(await (0, git_1.deleteRemote)(options, remoteName)).toBe(undefined);
371
- });
372
- it('should swallow "no such remote" error on git 2.30.0+, even if it is not in English', async () => {
373
- const err = new childProcess.SpawnError({
374
- code: 2, // returned only by git 2.30.0 or later, earlier versions returned 128
375
- cmdArgs: [],
376
- stdout: '',
377
- stderr: "Fehler: Remote-Repository nicht gefunden: 'my-remote'\n",
378
- });
379
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
380
- await expect(await (0, git_1.deleteRemote)(options, remoteName)).toBe(undefined);
381
- });
382
- it('should rethrow normal error', async () => {
383
- const err = new Error('just a normal error');
384
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
385
- expect.assertions(1);
386
- await expect((0, git_1.deleteRemote)(options, remoteName)).rejects.toThrowErrorMatchingInlineSnapshot(`"just a normal error"`);
387
- });
388
- });
389
- describe('cherrypick', () => {
390
- const options = {
391
- repoOwner: 'elastic',
392
- repoName: 'kibana',
393
- };
394
- it('should return `needsResolving: false` when no errors are encountered', async () => {
395
- jest
396
- .spyOn(childProcess, 'spawnPromise')
397
- .mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }); // mock `git cherrypick`
398
- expect(await (0, git_1.cherrypick)({
399
- options,
400
- sha: 'abcd',
401
- commitAuthor,
402
- })).toEqual({
403
- conflictingFiles: [],
404
- unstagedFiles: [],
405
- needsResolving: false,
406
- });
407
- });
408
- it('should use mainline option when specified', async () => {
409
- const spawnSpy = jest
410
- .spyOn(childProcess, 'spawnPromise')
411
- .mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }); // mock `git cherrypick`
412
- await (0, git_1.cherrypick)({
413
- options: { ...options, mainline: 1 },
414
- sha: 'abcd',
415
- commitAuthor,
416
- });
417
- const args = spawnSpy.mock.calls[0];
418
- expect(args).toEqual([
419
- 'git',
420
- [
421
- '-c',
422
- 'user.name="Soren L"',
423
- '-c',
424
- 'user.email="soren@mail.dk"',
425
- 'cherry-pick',
426
- '--mainline',
427
- '1',
428
- '-x',
429
- 'abcd',
430
- ],
431
- '/myHomeDir/.backport/repositories/elastic/kibana',
432
- ]);
433
- });
434
- it('should use signoff option when specified', async () => {
435
- const spawnSpy = jest
436
- .spyOn(childProcess, 'spawnPromise')
437
- .mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] }); // mock `git cherrypick`
438
- await (0, git_1.cherrypick)({
439
- options: { ...options, signoff: true },
440
- sha: 'abcd',
441
- commitAuthor,
442
- });
443
- const args = spawnSpy.mock.calls[0];
444
- expect(args).toEqual([
445
- 'git',
446
- [
447
- '-c',
448
- 'user.name="Soren L"',
449
- '-c',
450
- 'user.email="soren@mail.dk"',
451
- 'cherry-pick',
452
- '-x',
453
- '--signoff',
454
- 'abcd',
455
- ],
456
- '/myHomeDir/.backport/repositories/elastic/kibana',
457
- ]);
458
- });
459
- it('should return `needsResolving: true` upon cherrypick error', async () => {
460
- jest
461
- .spyOn(childProcess, 'spawnPromise')
462
- // mock `git cherrypick`
463
- .mockRejectedValueOnce(new childProcess.SpawnError({
464
- code: 128,
465
- cmdArgs: ['cherry-pick', '-x', 'abcd'],
466
- stdout: '',
467
- stderr: '',
468
- }))
469
- // mock getConflictingFiles
470
- .mockRejectedValueOnce(new childProcess.SpawnError({
471
- code: 2,
472
- cmdArgs: ['--no-pager', 'diff', '--check'],
473
- stdout: 'conflicting-file.txt:1: leftover conflict marker\nconflicting-file.txt:3: leftover conflict marker\nconflicting-file.txt:5: leftover conflict marker\n',
474
- stderr: '',
475
- }))
476
- // mock getUnstagedFiles
477
- .mockResolvedValueOnce({ stdout: '', stderr: '', code: 0, cmdArgs: [] })
478
- // mock getStagedFiles
479
- .mockResolvedValueOnce({ stdout: '', stderr: '', code: 0, cmdArgs: [] });
480
- expect(await (0, git_1.cherrypick)({
481
- options,
482
- sha: 'abcd',
483
- commitAuthor,
484
- })).toEqual({
485
- conflictingFiles: [
486
- {
487
- absolute: '/myHomeDir/.backport/repositories/elastic/kibana/conflicting-file.txt',
488
- relative: 'conflicting-file.txt',
489
- },
490
- ],
491
- needsResolving: true,
492
- unstagedFiles: [],
493
- });
494
- });
495
- it('should let the user know about the "--mainline" argument when cherry-picking a merge commit without specifying it', async () => {
496
- jest
497
- .spyOn(childProcess, 'spawnPromise')
498
- // mock cherry pick command
499
- .mockRejectedValueOnce(new childProcess.SpawnError({
500
- code: 128,
501
- cmdArgs: ['cherry-pick', '381c7b604110257437a289b1f1742685eb8d79c5'],
502
- stdout: '',
503
- stderr: 'error: commit 381c7b604110257437a289b1f1742685eb8d79c5 is a merge but no -m option was given.\nfatal: cherry-pick failed\n',
504
- }));
505
- await expect((0, git_1.cherrypick)({
506
- options,
507
- sha: 'abcd',
508
- commitAuthor,
509
- })).rejects
510
- .toThrow(`Cherrypick failed because the selected commit was a merge commit. Please try again by specifying the parent with the \`mainline\` argument:
511
-
512
- > backport --mainline
513
-
514
- or:
515
-
516
- > backport --mainline <parent-number>
517
-
518
- Or refer to the git documentation for more information: https://git-scm.com/docs/git-cherry-pick#Documentation/git-cherry-pick.txt---mainlineparent-number`);
519
- });
520
- it('should gracefully handle empty commits', async () => {
521
- jest
522
- .spyOn(childProcess, 'spawnPromise')
523
- // mock cherry pick command
524
- .mockRejectedValueOnce(new childProcess.SpawnError({
525
- code: 1,
526
- cmdArgs: ['cherry-pick', 'fe6b13b83cc010f722548cd5a0a8c2d5341a20dd'],
527
- stdout: 'On branch backport/7.x/pr-58692\nYou are currently cherry-picking commit fe6b13b83cc.\n\nnothing to commit, working tree clean\n',
528
- stderr: "The previous cherry-pick is now empty, possibly due to conflict resolution.\nIf you wish to commit it anyway, use:\n\n git commit --allow-empty\n\nOtherwise, please use 'git cherry-pick --skip'\n",
529
- }));
530
- await expect((0, git_1.cherrypick)({
531
- options,
532
- sha: 'abcd',
533
- commitAuthor,
534
- })).rejects.toThrow(`Cherrypick failed because the selected commit (abcd) is empty. Did you already backport this commit?`);
535
- });
536
- it('should re-throw non-cherrypick errors', async () => {
537
- jest
538
- .spyOn(childProcess, 'spawnPromise')
539
- // mock cherry pick command
540
- .mockRejectedValueOnce(new Error('non-cherrypick error'))
541
- // getConflictingFiles
542
- .mockResolvedValueOnce({ stdout: '', stderr: '', code: 0, cmdArgs: [] })
543
- // getUnstagedFiles
544
- .mockResolvedValueOnce({ stdout: '', stderr: '', code: 0, cmdArgs: [] });
545
- await expect((0, git_1.cherrypick)({
546
- options,
547
- sha: 'abcd',
548
- commitAuthor,
549
- })).rejects.toThrowErrorMatchingInlineSnapshot(`"non-cherrypick error"`);
550
- });
551
- it('should return needsResolve:false when rerere.enabled + rerere.autoUpdate and all files are staged', async () => {
552
- const spawnSpy = jest.spyOn(childProcess, 'spawnPromise');
553
- spawnSpy.mockImplementation(async (cmd, args) => {
554
- if (args.includes('cherry-pick')) {
555
- throw new childProcess.SpawnError({
556
- code: 1,
557
- cmdArgs: ['cherry-pick', '-x', 'abcd'],
558
- stdout: '',
559
- stderr: 'error: could not apply abc1234... some commit message',
560
- });
561
- }
562
- const isDiff = args.includes('--no-pager') && args.includes('diff');
563
- // Mock getConflictingFiles (git diff --check) - no conflicts found
564
- if (isDiff && args.includes('--check')) {
565
- return { stdout: '', stderr: '', code: 0, cmdArgs: args };
566
- }
567
- // Mock getUnstagedFiles (git diff --name-only) - no unstaged files
568
- if (isDiff &&
569
- args.includes('--name-only') &&
570
- !args.includes('--cached')) {
571
- return { stdout: '', stderr: '', code: 0, cmdArgs: args };
572
- }
573
- // Mock getStagedFiles (git diff --name-only --cached) - has staged files
574
- if (isDiff && args.includes('--name-only') && args.includes('--cached')) {
575
- return {
576
- stdout: 'resolved-file.txt\nother-file.js',
577
- stderr: '',
578
- code: 0,
579
- cmdArgs: args,
580
- };
581
- }
582
- // Mock rerere config - enabled with autoUpdate
583
- if (args.includes('config') && args.includes('rerere.enabled')) {
584
- return { stdout: 'true\n', stderr: '', code: 0, cmdArgs: args };
585
- }
586
- if (args.includes('config') && args.includes('rerere.autoUpdate')) {
587
- return { stdout: 'true\n', stderr: '', code: 0, cmdArgs: args };
588
- }
589
- throw new Error(`Unexpected git command: ${cmd} ${args.join(' ')}`);
590
- });
591
- expect(await (0, git_1.cherrypick)({
592
- options,
593
- sha: 'abcd',
594
- commitAuthor,
595
- })).toEqual({
596
- conflictingFiles: [],
597
- unstagedFiles: [],
598
- needsResolving: false,
599
- });
600
- });
601
- it('should return needsResolving:true when rerere.enabled && autoUpdate && mixed staged + unstaged', async () => {
602
- const base = '/myHomeDir/.backport/repositories/elastic/kibana';
603
- const spawnSpy = jest.spyOn(childProcess, 'spawnPromise');
604
- spawnSpy.mockImplementation(async (cmd, args) => {
605
- if (args.includes('cherry-pick')) {
606
- throw new childProcess.SpawnError({
607
- code: 1,
608
- cmdArgs: ['cherry-pick', '-x', 'abcd'],
609
- stdout: '',
610
- stderr: 'error: could not apply abc1234... some commit message',
611
- });
612
- }
613
- const isDiff = args.includes('--no-pager') && args.includes('diff');
614
- // getConflictingFiles: none
615
- if (isDiff && args.includes('--check')) {
616
- return { stdout: '', stderr: '', code: 0, cmdArgs: args };
617
- }
618
- // getUnstagedFiles: has one unstaged file
619
- if (isDiff &&
620
- args.includes('--name-only') &&
621
- !args.includes('--cached')) {
622
- return { stdout: 'u1\n', stderr: '', code: 0, cmdArgs: args };
623
- }
624
- // getStagedFiles: has staged file(s)
625
- if (isDiff && args.includes('--name-only') && args.includes('--cached')) {
626
- return { stdout: 's1\n', stderr: '', code: 0, cmdArgs: args };
627
- }
628
- // rerere.enabled=true, rerere.autoUpdate=true
629
- if (args.includes('config') && args.includes('rerere.enabled')) {
630
- return { stdout: 'true\n', stderr: '', code: 0, cmdArgs: args };
631
- }
632
- if (args.includes('config') && args.includes('rerere.autoUpdate')) {
633
- return { stdout: 'true\n', stderr: '', code: 0, cmdArgs: args };
634
- }
635
- throw new Error(`Unexpected git command: ${cmd} ${args.join(' ')}`);
636
- });
637
- await expect((0, git_1.cherrypick)({ options, sha: 'abcd', commitAuthor })).resolves.toEqual({
638
- conflictingFiles: [],
639
- unstagedFiles: [`${base}/u1`],
640
- needsResolving: true,
641
- });
642
- });
643
- it('should return needsResolving:true when rerere.enabled && !autoUpdate and unstaged present (no conflicts)', async () => {
644
- const base = '/myHomeDir/.backport/repositories/elastic/kibana';
645
- const spawnSpy = jest.spyOn(childProcess, 'spawnPromise');
646
- spawnSpy.mockImplementation(async (cmd, args) => {
647
- if (args.includes('cherry-pick')) {
648
- throw new childProcess.SpawnError({
649
- code: 1,
650
- cmdArgs: ['cherry-pick', '-x', 'abcd'],
651
- stdout: '',
652
- stderr: 'error: could not apply abc1234... some commit message',
653
- });
654
- }
655
- const isDiff = args.includes('--no-pager') && args.includes('diff');
656
- // getConflictingFiles: clean (no conflicts found)
657
- if (isDiff && args.includes('--check')) {
658
- return { stdout: '', stderr: '', code: 0, cmdArgs: args };
659
- }
660
- // getUnstagedFiles: has unstaged paths
661
- if (isDiff &&
662
- args.includes('--name-only') &&
663
- !args.includes('--cached')) {
664
- return { stdout: 'a.txt\nb.md\n', stderr: '', code: 0, cmdArgs: args };
665
- }
666
- // getStagedFiles: none staged
667
- if (isDiff && args.includes('--name-only') && args.includes('--cached')) {
668
- return { stdout: '', stderr: '', code: 0, cmdArgs: args };
669
- }
670
- // rerere.enabled=true, rerere.autoUpdate=false
671
- if (args.includes('config') && args.includes('rerere.enabled')) {
672
- return { stdout: 'true\n', stderr: '', code: 0, cmdArgs: args };
673
- }
674
- if (args.includes('config') && args.includes('rerere.autoUpdate')) {
675
- return { stdout: 'false\n', stderr: '', code: 0, cmdArgs: args };
676
- }
677
- throw new Error(`Unexpected git command: ${cmd} ${args.join(' ')}`);
678
- });
679
- await expect((0, git_1.cherrypick)({ options, sha: 'abcd', commitAuthor })).resolves.toEqual({
680
- conflictingFiles: [],
681
- unstagedFiles: [`${base}/a.txt`, `${base}/b.md`],
682
- needsResolving: true,
683
- });
684
- });
685
- it('should rethrow cherry-pick error when rerere.enabled && autoUpdate && no staged and no unstaged files (no conflicts)', async () => {
686
- const spawnSpy = jest.spyOn(childProcess, 'spawnPromise');
687
- spawnSpy.mockImplementation(async (cmd, args) => {
688
- if (args.includes('cherry-pick')) {
689
- throw new childProcess.SpawnError({
690
- code: 1,
691
- cmdArgs: ['cherry-pick', '-x', 'abcd'],
692
- stdout: '',
693
- stderr: 'error: could not apply abc1234... some commit message',
694
- });
695
- }
696
- const isDiff = args.includes('--no-pager') && args.includes('diff');
697
- // getConflictingFiles: clean
698
- if (isDiff && args.includes('--check')) {
699
- return { stdout: '', stderr: '', code: 0, cmdArgs: args };
700
- }
701
- // getUnstagedFiles: none
702
- if (isDiff &&
703
- args.includes('--name-only') &&
704
- !args.includes('--cached')) {
705
- return { stdout: '', stderr: '', code: 0, cmdArgs: args };
706
- }
707
- // getStagedFiles: none
708
- if (isDiff && args.includes('--name-only') && args.includes('--cached')) {
709
- return { stdout: '', stderr: '', code: 0, cmdArgs: args };
710
- }
711
- // rerere.enabled=true, rerere.autoUpdate=true
712
- if (args.includes('config') && args.includes('rerere.enabled')) {
713
- return { stdout: 'true\n', stderr: '', code: 0, cmdArgs: args };
714
- }
715
- if (args.includes('config') && args.includes('rerere.autoUpdate')) {
716
- return { stdout: 'true\n', stderr: '', code: 0, cmdArgs: args };
717
- }
718
- throw new Error(`Unexpected git command: ${cmd} ${args.join(' ')}`);
719
- });
720
- await expect((0, git_1.cherrypick)({ options, sha: 'abcd', commitAuthor })).rejects.toThrow(/could not apply/);
721
- });
722
- it('should return needsResolving:true when rerere.enabled && !autoUpdate with mixed staged and unstaged', async () => {
723
- const base = '/myHomeDir/.backport/repositories/elastic/kibana';
724
- const spawnSpy = jest.spyOn(childProcess, 'spawnPromise');
725
- spawnSpy.mockImplementation(async (cmd, args) => {
726
- if (args.includes('cherry-pick')) {
727
- throw new childProcess.SpawnError({
728
- code: 1,
729
- cmdArgs: ['cherry-pick', '-x', 'abcd'],
730
- stdout: '',
731
- stderr: 'error: could not apply abc1234... some commit message',
732
- });
733
- }
734
- const isDiff = args.includes('--no-pager') && args.includes('diff');
735
- // getConflictingFiles: clean
736
- if (isDiff && args.includes('--check')) {
737
- return { stdout: '', stderr: '', code: 0, cmdArgs: args };
738
- }
739
- // getUnstagedFiles: has entries
740
- if (isDiff &&
741
- args.includes('--name-only') &&
742
- !args.includes('--cached')) {
743
- return { stdout: 'u1\nu2\n', stderr: '', code: 0, cmdArgs: args };
744
- }
745
- // getStagedFiles: also has entries (mixed state)
746
- if (isDiff && args.includes('--name-only') && args.includes('--cached')) {
747
- return { stdout: 's1\n', stderr: '', code: 0, cmdArgs: args };
748
- }
749
- // rerere.enabled=true, rerere.autoUpdate=false
750
- if (args.includes('config') && args.includes('rerere.enabled')) {
751
- return { stdout: 'true\n', stderr: '', code: 0, cmdArgs: args };
752
- }
753
- if (args.includes('config') && args.includes('rerere.autoUpdate')) {
754
- return { stdout: 'false\n', stderr: '', code: 0, cmdArgs: args };
755
- }
756
- throw new Error(`Unexpected git command: ${cmd} ${args.join(' ')}`);
757
- });
758
- await expect((0, git_1.cherrypick)({ options, sha: 'abcd', commitAuthor })).resolves.toEqual({
759
- conflictingFiles: [],
760
- unstagedFiles: [`${base}/u1`, `${base}/u2`],
761
- needsResolving: true,
762
- });
763
- });
764
- it('should return needsResolving:true when conflicts are present (regardless of rerere)', async () => {
765
- const base = '/myHomeDir/.backport/repositories/elastic/kibana';
766
- const spawnSpy = jest.spyOn(childProcess, 'spawnPromise');
767
- spawnSpy.mockImplementation(async (cmd, args) => {
768
- if (args.includes('cherry-pick')) {
769
- throw new childProcess.SpawnError({
770
- code: 1,
771
- cmdArgs: ['cherry-pick', '-x', 'abcd'],
772
- stdout: '',
773
- stderr: 'error: could not apply abc1234... some commit message',
774
- });
775
- }
776
- const isDiff = args.includes('--no-pager') && args.includes('diff');
777
- // getConflictingFiles: has entries
778
- if (isDiff && args.includes('--check')) {
779
- throw new childProcess.SpawnError({
780
- code: 2,
781
- cmdArgs: args,
782
- stdout: 'left.txt:1: leftover conflict marker\n',
783
- stderr: '',
784
- });
785
- }
786
- // getUnstagedFiles: none
787
- if (isDiff &&
788
- args.includes('--name-only') &&
789
- !args.includes('--cached')) {
790
- return { stdout: '', stderr: '', code: 0, cmdArgs: args };
791
- }
792
- // getStagedFiles: none
793
- if (isDiff && args.includes('--name-only') && args.includes('--cached')) {
794
- return { stdout: '', stderr: '', code: 0, cmdArgs: args };
795
- }
796
- // rerere.enabled=true, rerere.autoUpdate=true
797
- if (args.includes('config') && args.includes('rerere.enabled')) {
798
- return { stdout: 'true\n', stderr: '', code: 0, cmdArgs: args };
799
- }
800
- if (args.includes('config') && args.includes('rerere.autoUpdate')) {
801
- return { stdout: 'true\n', stderr: '', code: 0, cmdArgs: args };
802
- }
803
- throw new Error(`Unexpected git command: ${cmd} ${args.join(' ')}`);
804
- });
805
- await expect((0, git_1.cherrypick)({ options, sha: 'abcd', commitAuthor })).resolves.toEqual({
806
- conflictingFiles: [
807
- { absolute: `${base}/left.txt`, relative: 'left.txt' },
808
- ],
809
- unstagedFiles: [],
810
- needsResolving: true,
811
- });
812
- });
813
- it('should return needsResolving:true and unstaged present (regardless of rerere)', async () => {
814
- const base = '/myHomeDir/.backport/repositories/elastic/kibana';
815
- const spawnSpy = jest.spyOn(childProcess, 'spawnPromise');
816
- spawnSpy.mockImplementation(async (cmd, args) => {
817
- if (args.includes('cherry-pick')) {
818
- throw new childProcess.SpawnError({
819
- code: 1,
820
- cmdArgs: ['cherry-pick', '-x', 'abcd'],
821
- stdout: '',
822
- stderr: 'error: could not apply abc1234... some commit message',
823
- });
824
- }
825
- const isDiff = args.includes('--no-pager') && args.includes('diff');
826
- // getConflictingFiles: clean
827
- if (isDiff && args.includes('--check')) {
828
- return { stdout: '', stderr: '', code: 0, cmdArgs: args };
829
- }
830
- // getUnstagedFiles: has entries
831
- if (isDiff &&
832
- args.includes('--name-only') &&
833
- !args.includes('--cached')) {
834
- return { stdout: 'x\n', stderr: '', code: 0, cmdArgs: args };
835
- }
836
- // getStagedFiles: not needed but return none
837
- if (isDiff && args.includes('--name-only') && args.includes('--cached')) {
838
- return { stdout: '', stderr: '', code: 0, cmdArgs: args };
839
- }
840
- // rerere.enabled=false; rerere.autoUpdate=false
841
- if (args.includes('config') && args.includes('rerere.enabled')) {
842
- return { stdout: 'true\n', stderr: '', code: 0, cmdArgs: args };
843
- }
844
- if (args.includes('config') && args.includes('rerere.autoUpdate')) {
845
- return { stdout: 'true\n', stderr: '', code: 0, cmdArgs: args };
846
- }
847
- throw new Error(`Unexpected git command: ${cmd} ${args.join(' ')}`);
848
- });
849
- await expect((0, git_1.cherrypick)({ options, sha: 'abcd', commitAuthor })).resolves.toEqual({
850
- conflictingFiles: [],
851
- unstagedFiles: [`${base}/x`],
852
- needsResolving: true,
853
- });
854
- });
855
- });
856
- describe('getRerereConfig', () => {
857
- const options = {
858
- repoOwner: 'elastic',
859
- repoName: 'kibana',
860
- };
861
- it('parses booleans from git config canonical output', async () => {
862
- const spy = jest.spyOn(childProcess, 'spawnPromise');
863
- // rerere.enabled -> true
864
- spy.mockResolvedValueOnce({
865
- stdout: 'true\n',
866
- stderr: '',
867
- code: 0,
868
- cmdArgs: [],
869
- });
870
- // rerere.autoUpdate -> false
871
- spy.mockResolvedValueOnce({
872
- stdout: 'false\n',
873
- stderr: '',
874
- code: 0,
875
- cmdArgs: [],
876
- });
877
- const cfg = await (0, git_1.getRerereConfig)(options);
878
- expect(cfg).toEqual({ enabled: true, autoUpdate: false });
879
- });
880
- it('returns false when keys are missing or unreadable', async () => {
881
- const spy = jest.spyOn(childProcess, 'spawnPromise');
882
- // Simulate missing keys by rejecting
883
- spy.mockRejectedValueOnce(new Error('not found'));
884
- spy.mockRejectedValueOnce(new Error('not found'));
885
- const cfg = await (0, git_1.getRerereConfig)(options);
886
- expect(cfg).toEqual({ enabled: false, autoUpdate: false });
887
- });
888
- });
889
- describe('commitChanges', () => {
890
- const options = {
891
- repoOwner: 'elastic',
892
- repoName: 'kibana',
893
- };
894
- const commit = {
895
- author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
896
- suggestedTargetBranches: [],
897
- sourceCommit: {
898
- branchLabelMapping: {},
899
- message: 'The original commit message',
900
- committedDate: '2020',
901
- sha: 'abc',
902
- },
903
- sourceBranch: 'master',
904
- targetPullRequestStates: [],
905
- };
906
- it('should return when changes committed successfully', async () => {
907
- jest
908
- .spyOn(childProcess, 'spawnPromise')
909
- .mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] });
910
- await expect(await (0, git_1.commitChanges)({ commit, commitAuthor, options })).toBe(undefined);
911
- });
912
- it('should swallow error if changes have already been committed manaully', async () => {
913
- const err = new childProcess.SpawnError({
914
- code: 1,
915
- cmdArgs: ['commit', '--no-edit'],
916
- stdout: 'On branch backport/7.x/commit-913afb3b\nnothing to commit, working tree clean\n',
917
- stderr: '',
918
- });
919
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
920
- await expect(await (0, git_1.commitChanges)({ commit, commitAuthor, options })).toBe(undefined);
921
- });
922
- describe('when commit fails due to empty message', () => {
923
- let spy;
924
- let res;
925
- beforeEach(async () => {
926
- const err = new childProcess.SpawnError({
927
- code: 1,
928
- cmdArgs: ['commit', '--no-edit', '--no-verify'],
929
- stdout: '',
930
- stderr: 'Aborting commit due to empty commit message.\n',
931
- });
932
- spy = jest
933
- .spyOn(childProcess, 'spawnPromise')
934
- .mockRejectedValueOnce(err)
935
- .mockResolvedValueOnce({
936
- stderr: '',
937
- stdout: '',
938
- code: 0,
939
- cmdArgs: [],
940
- });
941
- res = await (0, git_1.commitChanges)({ commit, commitAuthor, options });
942
- });
943
- it('should manually set the commit message', () => {
944
- expect(spy).toHaveBeenCalledTimes(2);
945
- expect(spy.mock.calls[0]).toEqual([
946
- 'git',
947
- [
948
- '-c',
949
- 'user.name="Soren L"',
950
- '-c',
951
- 'user.email="soren@mail.dk"',
952
- 'commit',
953
- '--no-edit',
954
- ],
955
- expect.any(String),
956
- ]);
957
- expect(spy.mock.calls[1]).toEqual([
958
- 'git',
959
- [
960
- '-c',
961
- 'user.name="Soren L"',
962
- '-c',
963
- 'user.email="soren@mail.dk"',
964
- 'commit',
965
- '--message=The original commit message',
966
- ],
967
- expect.any(String),
968
- ]);
969
- });
970
- it('should handle the error and resolve successfully', async () => {
971
- await expect(res).toBe(undefined);
972
- });
973
- });
974
- it('should re-throw other errors', async () => {
975
- const err = new Error('another error');
976
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(err);
977
- expect.assertions(1);
978
- await expect((0, git_1.commitChanges)({ commit, commitAuthor, options })).rejects.toThrowErrorMatchingInlineSnapshot(`"another error"`);
979
- });
980
- });
981
- describe('addRemote', () => {
982
- const options = {
983
- accessToken: 'myAccessToken',
984
- repoOwner: 'elastic',
985
- repoName: 'kibana',
986
- gitHostname: 'github.com',
987
- };
988
- it('add correct origin remote', async () => {
989
- const spy = jest
990
- .spyOn(childProcess, 'spawnPromise')
991
- .mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] });
992
- await (0, git_1.addRemote)(options, 'elastic');
993
- return expect(spy).toHaveBeenCalledWith('git', [
994
- 'remote',
995
- 'add',
996
- 'elastic',
997
- 'https://x-access-token:myAccessToken@github.com/elastic/kibana.git',
998
- ], '/myHomeDir/.backport/repositories/elastic/kibana');
999
- });
1000
- it('add correct user remote', async () => {
1001
- const spy = jest
1002
- .spyOn(childProcess, 'spawnPromise')
1003
- .mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] });
1004
- await (0, git_1.addRemote)(options, 'sorenlouv');
1005
- return expect(spy).toHaveBeenCalledWith('git', [
1006
- 'remote',
1007
- 'add',
1008
- 'sorenlouv',
1009
- 'https://x-access-token:myAccessToken@github.com/sorenlouv/kibana.git',
1010
- ], '/myHomeDir/.backport/repositories/elastic/kibana');
1011
- });
1012
- it('allows custom github url', async () => {
1013
- const spy = jest
1014
- .spyOn(childProcess, 'spawnPromise')
1015
- .mockResolvedValueOnce({ stderr: '', stdout: '', code: 0, cmdArgs: [] });
1016
- await (0, git_1.addRemote)({ ...options, gitHostname: 'github.my-company.com' }, 'sorenlouv');
1017
- return expect(spy).toHaveBeenCalledWith('git', [
1018
- 'remote',
1019
- 'add',
1020
- 'sorenlouv',
1021
- 'https://x-access-token:myAccessToken@github.my-company.com/sorenlouv/kibana.git',
1022
- ], '/myHomeDir/.backport/repositories/elastic/kibana');
1023
- });
1024
- });
1025
- describe('pushBackportBranch', () => {
1026
- const options = {
1027
- authenticatedUsername: 'sqren_authenticated',
1028
- fork: true,
1029
- repoForkOwner: 'the_fork_owner',
1030
- repoName: 'kibana',
1031
- repoOwner: 'elastic',
1032
- };
1033
- const backportBranch = 'backport/7.x/pr-2';
1034
- it('should handle missing fork error', async () => {
1035
- jest.spyOn(childProcess, 'spawnPromise').mockRejectedValueOnce(new childProcess.SpawnError({
1036
- code: 128,
1037
- cmdArgs: [
1038
- 'push',
1039
- 'sorenlouv',
1040
- 'backport/7.x/pr-2:backport/7.x/pr-2',
1041
- '--force',
1042
- ],
1043
- stdout: '',
1044
- stderr: "remote: Repository not found.\nfatal: repository 'https://github.com/sorenlouv/kibana.git/' not found\n",
1045
- }));
1046
- await expect((0, git_1.pushBackportBranch)({ options, backportBranch })).rejects
1047
- .toThrowErrorMatchingInlineSnapshot(`
1048
- "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".
1049
- Read more about fork mode in the docs: https://github.com/sorenlouv/backport/blob/main/docs/config-file-options.md#fork"
1050
- `);
1051
- });
1052
- });
1053
- //# sourceMappingURL=git.test.js.map