backport 7.4.0 → 8.2.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 (244) hide show
  1. package/README.md +15 -16
  2. package/dist/backportRun.d.ts +12 -6
  3. package/dist/backportRun.js +64 -62
  4. package/dist/entrypoint.cli.js +4 -8
  5. package/dist/entrypoint.module.d.ts +13 -6
  6. package/dist/entrypoint.module.js +14 -20
  7. package/dist/entrypoint.module.private.test.js +47 -346
  8. package/dist/errors/BackportError.d.ts +19 -0
  9. package/dist/errors/BackportError.js +29 -0
  10. package/dist/lib/BackportError.d.ts +19 -0
  11. package/dist/lib/BackportError.js +29 -0
  12. package/dist/lib/cherrypickAndCreateTargetPullRequest.d.ts +11 -0
  13. package/dist/lib/cherrypickAndCreateTargetPullRequest.js +242 -0
  14. package/dist/lib/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
  15. package/dist/lib/cherrypickAndCreateTargetPullRequest.test.js +321 -0
  16. package/dist/lib/child-process-promisified.d.ts +25 -0
  17. package/dist/lib/child-process-promisified.js +60 -0
  18. package/dist/lib/env.d.ts +9 -0
  19. package/dist/lib/env.js +33 -0
  20. package/dist/lib/env.test.d.ts +1 -0
  21. package/dist/lib/env.test.js +26 -0
  22. package/dist/lib/getCommits.d.ts +2 -0
  23. package/dist/lib/getCommits.js +75 -0
  24. package/dist/lib/getCommitsWithoutBackports.d.ts +11 -0
  25. package/dist/lib/getCommitsWithoutBackports.js +68 -0
  26. package/dist/lib/getCommitsWithoutBackports.test.d.ts +1 -0
  27. package/dist/lib/getCommitsWithoutBackports.test.js +335 -0
  28. package/dist/lib/getGitConfigAuthor.d.ts +6 -0
  29. package/dist/lib/getGitConfigAuthor.js +15 -0
  30. package/dist/lib/getTargetBranches.d.ts +5 -0
  31. package/dist/lib/getTargetBranches.js +67 -0
  32. package/dist/lib/getTargetBranches.test.d.ts +1 -0
  33. package/dist/lib/getTargetBranches.test.js +210 -0
  34. package/dist/lib/git.d.ts +77 -0
  35. package/dist/lib/git.js +439 -0
  36. package/dist/lib/git.private.test.d.ts +1 -0
  37. package/dist/lib/git.private.test.js +618 -0
  38. package/dist/lib/git.test.d.ts +1 -0
  39. package/dist/lib/git.test.js +580 -0
  40. package/dist/lib/github/commitFormatters.d.ts +3 -0
  41. package/dist/lib/github/commitFormatters.js +17 -0
  42. package/dist/lib/github/commitFormatters.test.d.ts +1 -0
  43. package/dist/lib/github/commitFormatters.test.js +11 -0
  44. package/dist/lib/github/v3/addAssigneesToPullRequest.d.ts +2 -0
  45. package/dist/lib/github/v3/addAssigneesToPullRequest.js +32 -0
  46. package/dist/lib/github/v3/addAssigneesToPullRequest.test.d.ts +1 -0
  47. package/dist/lib/github/v3/addAssigneesToPullRequest.test.js +27 -0
  48. package/dist/lib/github/v3/addLabelsToPullRequest.d.ts +2 -0
  49. package/dist/lib/github/v3/addLabelsToPullRequest.js +30 -0
  50. package/dist/lib/github/v3/addReviewersToPullRequest.d.ts +2 -0
  51. package/dist/lib/github/v3/addReviewersToPullRequest.js +32 -0
  52. package/dist/lib/github/v3/createPullRequest.d.ts +29 -0
  53. package/dist/lib/github/v3/createPullRequest.js +91 -0
  54. package/dist/lib/github/v3/createPullRequest.test.d.ts +1 -0
  55. package/dist/lib/github/v3/createPullRequest.test.js +377 -0
  56. package/dist/lib/github/v3/createStatusComment.d.ts +11 -0
  57. package/dist/lib/github/v3/createStatusComment.js +138 -0
  58. package/dist/lib/github/v3/createStatusComment.test.d.ts +1 -0
  59. package/dist/lib/github/v3/createStatusComment.test.js +566 -0
  60. package/dist/lib/github/v3/getGithubV3ErrorMessage.d.ts +14 -0
  61. package/dist/lib/github/v3/getGithubV3ErrorMessage.js +16 -0
  62. package/dist/lib/github/v4/FetchPullRequestId.d.ts +2 -0
  63. package/dist/lib/github/v4/FetchPullRequestId.js +36 -0
  64. package/dist/lib/github/v4/apiRequestV4.d.ts +31 -0
  65. package/dist/lib/github/v4/apiRequestV4.js +71 -0
  66. package/dist/lib/github/v4/apiRequestV4.test.d.ts +1 -0
  67. package/dist/lib/github/v4/apiRequestV4.test.js +109 -0
  68. package/dist/lib/github/v4/disablePullRequestAutoMerge.d.ts +2 -0
  69. package/dist/lib/github/v4/disablePullRequestAutoMerge.js +32 -0
  70. package/dist/lib/github/v4/enablePullRequestAutoMerge.d.ts +2 -0
  71. package/dist/lib/github/v4/enablePullRequestAutoMerge.js +50 -0
  72. package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
  73. package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.js +112 -0
  74. package/dist/lib/github/v4/fetchAuthorId.d.ts +10 -0
  75. package/dist/lib/github/v4/fetchAuthorId.js +28 -0
  76. package/dist/lib/github/v4/fetchAuthorId.private.test.d.ts +1 -0
  77. package/dist/lib/github/v4/fetchAuthorId.private.test.js +25 -0
  78. package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.d.ts +1 -0
  79. package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +93 -0
  80. package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +11 -0
  81. package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.js +58 -0
  82. package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
  83. package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +136 -0
  84. package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.d.ts +11 -0
  85. package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.js +48 -0
  86. package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
  87. package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.js +118 -0
  88. package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +29 -0
  89. package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.js +110 -0
  90. package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
  91. package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +196 -0
  92. package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
  93. package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +157 -0
  94. package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
  95. package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +107 -0
  96. package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +12 -0
  97. package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +69 -0
  98. package/dist/lib/github/v4/fetchExistingPullRequest.d.ts +9 -0
  99. package/dist/lib/github/v4/fetchExistingPullRequest.js +64 -0
  100. package/dist/lib/github/v4/fetchExistingPullRequest.private.test.d.ts +1 -0
  101. package/dist/lib/github/v4/fetchExistingPullRequest.private.test.js +44 -0
  102. package/dist/lib/github/v4/fetchPullRequestAutoMergeMethod.d.ts +2 -0
  103. package/dist/lib/github/v4/fetchPullRequestAutoMergeMethod.js +39 -0
  104. package/dist/lib/github/v4/fetchRemoteProjectConfig.d.ts +8 -0
  105. package/dist/lib/github/v4/fetchRemoteProjectConfig.js +49 -0
  106. package/dist/lib/github/v4/fetchRemoteProjectConfig.private.test.d.ts +1 -0
  107. package/dist/lib/github/v4/fetchRemoteProjectConfig.private.test.js +49 -0
  108. package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +72 -0
  109. package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +78 -0
  110. package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
  111. package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +116 -0
  112. package/dist/lib/github/v4/getOptionsFromGithub/query.d.ts +16 -0
  113. package/dist/lib/github/v4/getOptionsFromGithub/query.js +29 -0
  114. package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
  115. package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.js +61 -0
  116. package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +1 -0
  117. package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +72 -0
  118. package/dist/lib/github/v4/mocks/commitsByAuthorMock.d.ts +2 -0
  119. package/dist/lib/github/v4/mocks/commitsByAuthorMock.js +176 -0
  120. package/dist/lib/github/v4/throwOnInvalidAccessToken.d.ts +7 -0
  121. package/dist/lib/github/v4/throwOnInvalidAccessToken.js +45 -0
  122. package/dist/lib/github/v4/throwOnInvalidAccessToken.test.d.ts +1 -0
  123. package/dist/lib/github/v4/throwOnInvalidAccessToken.test.js +87 -0
  124. package/dist/lib/github/v4/validateTargetBranches.d.ts +14 -0
  125. package/dist/lib/github/v4/validateTargetBranches.js +46 -0
  126. package/dist/lib/github/v4/validateTargetBranches.private.test.d.ts +1 -0
  127. package/dist/lib/github/v4/validateTargetBranches.private.test.js +51 -0
  128. package/dist/lib/logger.d.ts +11 -0
  129. package/dist/lib/logger.js +80 -0
  130. package/dist/lib/ora.d.ts +2 -0
  131. package/dist/lib/ora.js +21 -0
  132. package/dist/lib/prompt.test.d.ts +1 -0
  133. package/dist/lib/prompt.test.js +139 -0
  134. package/dist/lib/prompts.d.ts +17 -0
  135. package/dist/lib/prompts.js +132 -0
  136. package/dist/lib/remoteConfig.d.ts +20 -0
  137. package/dist/lib/remoteConfig.js +52 -0
  138. package/dist/lib/sequentially.d.ts +1 -0
  139. package/dist/lib/sequentially.js +10 -0
  140. package/dist/lib/setupRepo.d.ts +2 -0
  141. package/dist/lib/setupRepo.js +56 -0
  142. package/dist/lib/setupRepo.test.d.ts +1 -0
  143. package/dist/lib/setupRepo.test.js +278 -0
  144. package/dist/lib/sourceCommit/getExpectedTargetPullRequests.d.ts +16 -0
  145. package/dist/lib/sourceCommit/getExpectedTargetPullRequests.js +102 -0
  146. package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
  147. package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.js +467 -0
  148. package/dist/lib/sourceCommit/getMockSourceCommit.d.ts +26 -0
  149. package/dist/lib/sourceCommit/getMockSourceCommit.js +103 -0
  150. package/dist/lib/sourceCommit/parseSourceCommit.d.ts +108 -0
  151. package/dist/lib/sourceCommit/parseSourceCommit.js +123 -0
  152. package/dist/lib/sourceCommit/parseSourceCommit.test.d.ts +1 -0
  153. package/dist/lib/sourceCommit/parseSourceCommit.test.js +226 -0
  154. package/dist/options/ConfigOptions.d.ts +4 -2
  155. package/dist/options/cliArgs.d.ts +14 -6
  156. package/dist/options/cliArgs.js +50 -22
  157. package/dist/options/cliArgs.test.js +128 -4
  158. package/dist/options/config/config.d.ts +5 -4
  159. package/dist/options/config/config.js +3 -5
  160. package/dist/options/config/config.test.js +0 -1
  161. package/dist/options/config/globalConfig.d.ts +5 -3
  162. package/dist/options/config/globalConfig.js +17 -14
  163. package/dist/options/config/readConfigFile.d.ts +5 -3
  164. package/dist/options/config/readConfigFile.js +2 -2
  165. package/dist/options/options.d.ts +41 -5
  166. package/dist/options/options.js +24 -24
  167. package/dist/options/options.test.js +117 -55
  168. package/dist/runSequentially.d.ts +14 -9
  169. package/dist/runSequentially.js +27 -12
  170. package/dist/scripts/postinstall.js +4 -3
  171. package/dist/scripts/postinstall.test.js +6 -2
  172. package/dist/services/BackportError.d.ts +19 -0
  173. package/dist/services/BackportError.js +29 -0
  174. package/dist/services/HandledBackportError.d.ts +19 -0
  175. package/dist/services/HandledBackportError.js +29 -0
  176. package/dist/services/HandledError.d.ts +2 -2
  177. package/dist/services/HandledError.js +7 -7
  178. package/dist/services/child-process-promisified.d.ts +19 -3
  179. package/dist/services/child-process-promisified.js +46 -17
  180. package/dist/services/git.d.ts +6 -7
  181. package/dist/services/git.integration.test.js +381 -65
  182. package/dist/services/git.js +189 -123
  183. package/dist/services/git.private.test.d.ts +1 -0
  184. package/dist/services/git.private.test.js +618 -0
  185. package/dist/services/git.test.js +167 -124
  186. package/dist/services/github/v3/addAssigneesToPullRequest.js +1 -1
  187. package/dist/services/github/v3/addLabelsToPullRequest.js +1 -1
  188. package/dist/services/github/v3/addReviewersToPullRequest.js +2 -1
  189. package/dist/services/github/v3/createPullRequest.js +4 -2
  190. package/dist/services/github/v3/createStatusComment.js +16 -17
  191. package/dist/services/github/v3/createStatusComment.test.js +20 -9
  192. package/dist/services/github/v4/apiRequestV4.js +2 -2
  193. package/dist/services/github/v4/apiRequestV4.test.js +2 -2
  194. package/dist/services/github/v4/enablePullRequestAutoMerge.js +2 -4
  195. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +4 -3
  196. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +5 -1
  197. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -2
  198. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +5 -1
  199. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +4 -3
  200. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +5 -1
  201. package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +3 -2
  202. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +2 -2
  203. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +5 -1
  204. package/dist/services/github/v4/throwOnInvalidAccessToken.js +5 -5
  205. package/dist/services/logger.js +5 -1
  206. package/dist/services/test.d.ts +1 -0
  207. package/dist/services/test.js +23 -0
  208. package/dist/state.d.ts +0 -0
  209. package/dist/state.js +1 -0
  210. package/dist/test/e2e/cli/commit-author.private.test.js +4 -4
  211. package/dist/test/e2e/cli/different-merge-strategies.private.test.js +27 -25
  212. package/dist/test/e2e/cli/entrypoint.cli.private.test.js +53 -75
  213. package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.d.ts +1 -0
  214. package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.js +80 -0
  215. package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.d.ts +1 -0
  216. package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.js +199 -0
  217. package/dist/test/e2e/cli/interactive-error-handling.private.test.d.ts +1 -0
  218. package/dist/test/e2e/cli/interactive-error-handling.private.test.js +80 -0
  219. package/dist/test/e2e/cli/non-interactive-error-handling.private.test.d.ts +1 -0
  220. package/dist/test/e2e/cli/non-interactive-error-handling.private.test.js +198 -0
  221. package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +28 -29
  222. package/dist/test/e2e/cli/runBackportViaCli.d.ts +6 -2
  223. package/dist/test/e2e/cli/runBackportViaCli.js +44 -23
  224. package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +22 -14
  225. package/dist/test/e2e/module/entrypoint.module.mutation.test.js +28 -21
  226. package/dist/test/handleUnbackportedPullRequests.private.test.js +11 -8
  227. package/dist/test/sandbox.js +5 -1
  228. package/dist/test/setupFiles/automatic-mocks.js +6 -2
  229. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +4 -4
  230. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +7 -159
  231. package/dist/ui/getCommits.js +2 -2
  232. package/dist/ui/getCommitsWithoutBackports.test.js +5 -1
  233. package/dist/ui/getGitConfigAuthor.js +1 -1
  234. package/dist/ui/getTargetBranches.js +3 -3
  235. package/dist/ui/getTargetBranches.test.js +5 -1
  236. package/dist/ui/ora.d.ts +1 -8
  237. package/dist/ui/setupRepo.js +3 -3
  238. package/dist/ui/setupRepo.test.js +98 -61
  239. package/dist/utils/isErrnoError.d.ts +2 -0
  240. package/dist/utils/isErrnoError.js +7 -0
  241. package/dist/utils/packageVersion.d.ts +1 -1
  242. package/dist/utils/packageVersion.js +1 -1
  243. package/package.json +19 -19
  244. package/yarn.lock +472 -701
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLocalRepoPath = exports.pushBackportBranch = exports.getRepoForkOwner = exports.deleteBackportBranch = exports.createBackportBranch = exports.getGitConfig = exports.getUnstagedFiles = exports.getConflictingFiles = exports.commitChanges = exports.cherrypick = exports.getCommitsInMergeCommit = exports.getIsMergeCommit = exports.fetchBranch = exports.addRemote = exports.deleteRemote = exports.getIsCommitInBranch = exports.getGitProjectRootPath = exports.getRepoInfoFromGitRemotes = exports.isLocalConfigFileModified = exports.isLocalConfigFileUntracked = exports.getLocalConfigFileCommitDate = exports.cloneRepo = exports.getRemoteUrl = void 0;
3
+ exports.getLocalSourceRepoPath = exports.pushBackportBranch = exports.getRepoForkOwner = exports.deleteBackportBranch = exports.createBackportBranch = exports.getGitConfig = exports.getUnstagedFiles = exports.getConflictingFiles = exports.commitChanges = exports.cherrypick = exports.getCommitsInMergeCommit = exports.getIsMergeCommit = exports.fetchBranch = exports.addRemote = exports.deleteRemote = exports.getIsCommitInBranch = exports.getGitProjectRootPath = exports.getRepoInfoFromGitRemotes = exports.isLocalConfigFileModified = exports.isLocalConfigFileUntracked = exports.getLocalConfigFileCommitDate = exports.cloneRepo = exports.getRemoteUrl = void 0;
4
4
  const path_1 = require("path");
5
5
  const lodash_1 = require("lodash");
6
6
  const ora_1 = require("../ui/ora");
7
7
  const filterEmpty_1 = require("../utils/filterEmpty");
8
- const HandledError_1 = require("./HandledError");
8
+ const BackportError_1 = require("./BackportError");
9
9
  const child_process_promisified_1 = require("./child-process-promisified");
10
10
  const env_1 = require("./env");
11
11
  const commitFormatters_1 = require("./github/commitFormatters");
@@ -16,37 +16,47 @@ function getRemoteUrl({ repoName, accessToken, gitHostname = 'github.com' }, rep
16
16
  exports.getRemoteUrl = getRemoteUrl;
17
17
  async function cloneRepo({ sourcePath, targetPath }, onProgress) {
18
18
  return new Promise((resolve, reject) => {
19
- const execProcess = (0, child_process_promisified_1.execAsCallback)(`git clone ${sourcePath} ${targetPath} --progress`, { maxBuffer: 100 * 1024 * 1024 }, (error) => {
20
- return error ? reject(error) : resolve();
21
- });
19
+ const subprocess = (0, child_process_promisified_1.spawnOriginal)('git', [
20
+ 'clone',
21
+ sourcePath,
22
+ targetPath,
23
+ '--progress',
24
+ ]);
22
25
  const progress = {
23
26
  fileUpdate: 0,
24
27
  objectReceive: 0,
25
28
  };
26
- if (execProcess.stderr) {
27
- execProcess.stderr.on('data', (data) => {
28
- logger_1.logger.verbose(data);
29
- const [, objectReceiveProgress] = data.toString().match(/^Receiving objects:\s+(\d+)%/) || [];
30
- if (objectReceiveProgress) {
31
- progress.objectReceive = parseInt(objectReceiveProgress, 10);
32
- }
33
- const [, fileUpdateProgress] = data.toString().match(/^Updating files:\s+(\d+)%/) || [];
34
- if (fileUpdateProgress) {
35
- progress.objectReceive = 100;
36
- progress.fileUpdate = parseInt(fileUpdateProgress, 10);
37
- }
38
- const progressSum = Math.round(progress.fileUpdate * 0.1 + progress.objectReceive * 0.9);
39
- if (progressSum > 0) {
40
- onProgress(progressSum);
41
- }
42
- });
43
- }
29
+ subprocess.on('error', (err) => reject(err));
30
+ subprocess.stderr.on('data', (data) => {
31
+ logger_1.logger.verbose(data);
32
+ const [, objectReceiveProgress] = data.toString().match(/^Receiving objects:\s+(\d+)%/) || [];
33
+ if (objectReceiveProgress) {
34
+ progress.objectReceive = parseInt(objectReceiveProgress, 10);
35
+ }
36
+ const [, fileUpdateProgress] = data.toString().match(/^Updating files:\s+(\d+)%/) || [];
37
+ if (fileUpdateProgress) {
38
+ progress.objectReceive = 100;
39
+ progress.fileUpdate = parseInt(fileUpdateProgress, 10);
40
+ }
41
+ const progressSum = Math.round(progress.fileUpdate * 0.1 + progress.objectReceive * 0.9);
42
+ if (progressSum > 0) {
43
+ onProgress(progressSum);
44
+ }
45
+ });
46
+ subprocess.on('close', (code) => {
47
+ if (code === 0 || code === null) {
48
+ resolve();
49
+ }
50
+ else {
51
+ reject(new Error(`Git clone failed with exit code: ${code}`));
52
+ }
53
+ });
44
54
  });
45
55
  }
46
56
  exports.cloneRepo = cloneRepo;
47
57
  async function getLocalConfigFileCommitDate({ cwd }) {
48
58
  try {
49
- const { stdout } = await (0, child_process_promisified_1.exec)('git --no-pager log -1 --format=%cd .backportrc.js*', { cwd });
59
+ const { stdout } = await (0, child_process_promisified_1.spawnPromise)('git', ['--no-pager', 'log', '-1', '--format=%cd', '.backportrc.json'], cwd);
50
60
  const timestamp = Date.parse(stdout);
51
61
  if (timestamp > 0) {
52
62
  return timestamp;
@@ -60,7 +70,7 @@ exports.getLocalConfigFileCommitDate = getLocalConfigFileCommitDate;
60
70
  async function isLocalConfigFileUntracked({ cwd }) {
61
71
  try {
62
72
  // list untracked files
63
- const { stdout } = await (0, child_process_promisified_1.exec)('git ls-files .backportrc.js* --exclude-standard --others', { cwd });
73
+ const { stdout } = await (0, child_process_promisified_1.spawnPromise)('git', ['ls-files', '.backportrc.json', '--exclude-standard', '--others'], cwd);
64
74
  return !!stdout;
65
75
  }
66
76
  catch (e) {
@@ -70,17 +80,17 @@ async function isLocalConfigFileUntracked({ cwd }) {
70
80
  exports.isLocalConfigFileUntracked = isLocalConfigFileUntracked;
71
81
  async function isLocalConfigFileModified({ cwd }) {
72
82
  try {
73
- const { stdout } = await (0, child_process_promisified_1.exec)('git --no-pager diff HEAD --name-only .backportrc.js*', { cwd });
83
+ const { stdout } = await (0, child_process_promisified_1.spawnPromise)('git', ['--no-pager', 'diff', 'HEAD', '--name-only', '.backportrc.json'], cwd);
74
84
  return !!stdout;
75
85
  }
76
86
  catch (e) {
77
- return;
87
+ return false;
78
88
  }
79
89
  }
80
90
  exports.isLocalConfigFileModified = isLocalConfigFileModified;
81
91
  async function getRepoInfoFromGitRemotes({ cwd }) {
82
92
  try {
83
- const { stdout } = await (0, child_process_promisified_1.exec)('git remote --verbose', { cwd });
93
+ const { stdout } = await (0, child_process_promisified_1.spawnPromise)('git', ['remote', '--verbose'], cwd);
84
94
  const remotes = stdout
85
95
  .split('\n')
86
96
  .map((line) => {
@@ -100,9 +110,8 @@ async function getRepoInfoFromGitRemotes({ cwd }) {
100
110
  exports.getRepoInfoFromGitRemotes = getRepoInfoFromGitRemotes;
101
111
  async function getGitProjectRootPath(dir) {
102
112
  try {
103
- const { stdout } = await (0, child_process_promisified_1.exec)('git rev-parse --show-toplevel', {
104
- cwd: dir,
105
- });
113
+ const cwd = dir;
114
+ const { stdout } = await (0, child_process_promisified_1.spawnPromise)('git', ['rev-parse', '--show-toplevel'], cwd);
106
115
  return stdout.trim();
107
116
  }
108
117
  catch (e) {
@@ -113,37 +122,45 @@ async function getGitProjectRootPath(dir) {
113
122
  exports.getGitProjectRootPath = getGitProjectRootPath;
114
123
  async function getIsCommitInBranch(options, commitSha) {
115
124
  try {
116
- await (0, child_process_promisified_1.exec)(`git merge-base --is-ancestor ${commitSha} HEAD`, {
117
- cwd: (0, env_1.getRepoPath)(options),
118
- });
125
+ const cwd = (0, env_1.getRepoPath)(options);
126
+ await (0, child_process_promisified_1.spawnPromise)('git', ['merge-base', '--is-ancestor', commitSha, 'HEAD'], cwd);
119
127
  return true;
120
128
  }
121
129
  catch (e) {
122
- const isExecError = e.cmd && e.code > 0;
123
- // re-throw if error is not an exec related error
124
- if (!isExecError) {
125
- throw e;
130
+ const isSpawnError = e instanceof child_process_promisified_1.SpawnError;
131
+ if (isSpawnError) {
132
+ const commitNotInBranch = e.context.code === 1 && e.context.stderr === '';
133
+ const commitNotExist = e.context.code === 128 &&
134
+ e.context.stderr.includes('Not a valid object name');
135
+ if (commitNotInBranch || commitNotExist) {
136
+ return false;
137
+ }
126
138
  }
127
- return false;
139
+ throw e;
128
140
  }
129
141
  }
130
142
  exports.getIsCommitInBranch = getIsCommitInBranch;
131
143
  async function deleteRemote(options, remoteName) {
132
144
  try {
133
- await (0, child_process_promisified_1.exec)(`git remote rm ${remoteName}`, { cwd: (0, env_1.getRepoPath)(options) });
145
+ const cwd = (0, env_1.getRepoPath)(options);
146
+ await (0, child_process_promisified_1.spawnPromise)('git', ['remote', 'rm', remoteName], cwd);
134
147
  }
135
148
  catch (e) {
136
- const isExecError = e.cmd && e.code > 0;
137
- // re-throw if error is not an exec related error
138
- if (!isExecError) {
139
- throw e;
149
+ const isSpawnError = e instanceof child_process_promisified_1.SpawnError;
150
+ if (isSpawnError &&
151
+ e.context.code > 0 &&
152
+ e.context.stderr.includes('No such remote')) {
153
+ return;
140
154
  }
155
+ // re-throw
156
+ throw e;
141
157
  }
142
158
  }
143
159
  exports.deleteRemote = deleteRemote;
144
160
  async function addRemote(options, remoteName) {
145
161
  try {
146
- await (0, child_process_promisified_1.exec)(`git remote add ${remoteName} ${getRemoteUrl(options, remoteName)}`, { cwd: (0, env_1.getRepoPath)(options) });
162
+ const cwd = (0, env_1.getRepoPath)(options);
163
+ await (0, child_process_promisified_1.spawnPromise)('git', ['remote', 'add', remoteName, getRemoteUrl(options, remoteName)], cwd);
147
164
  }
148
165
  catch (e) {
149
166
  // note: swallowing error
@@ -152,107 +169,131 @@ async function addRemote(options, remoteName) {
152
169
  }
153
170
  exports.addRemote = addRemote;
154
171
  async function fetchBranch(options, branch) {
155
- await (0, child_process_promisified_1.exec)(`git fetch ${options.repoOwner} ${branch}:${branch} --force`, {
156
- cwd: (0, env_1.getRepoPath)(options),
157
- });
172
+ const cwd = (0, env_1.getRepoPath)(options);
173
+ await (0, child_process_promisified_1.spawnPromise)('git', ['fetch', options.repoOwner, `${branch}:${branch}`, '--force'], cwd);
158
174
  }
159
175
  exports.fetchBranch = fetchBranch;
160
176
  async function getIsMergeCommit(options, sha) {
161
- const res = await (0, child_process_promisified_1.exec)(`git rev-list -1 --merges ${sha}~1..${sha}`, {
162
- cwd: (0, env_1.getRepoPath)(options),
163
- });
177
+ const cwd = (0, env_1.getRepoPath)(options);
178
+ const res = await (0, child_process_promisified_1.spawnPromise)('git', ['rev-list', '-1', '--merges', `${sha}~1..${sha}`], cwd);
164
179
  return res.stdout !== '';
165
180
  }
166
181
  exports.getIsMergeCommit = getIsMergeCommit;
167
182
  async function getCommitsInMergeCommit(options, sha) {
168
183
  try {
169
- const res = await (0, child_process_promisified_1.exec)(`git --no-pager log ${sha}^1..${sha}^2 --pretty=format:"%H"`, {
170
- cwd: (0, env_1.getRepoPath)(options),
171
- });
184
+ const cwd = (0, env_1.getRepoPath)(options);
185
+ const res = await (0, child_process_promisified_1.spawnPromise)('git', ['--no-pager', 'log', `${sha}^1..${sha}^2`, '--pretty=format:%H'], cwd);
172
186
  return res.stdout.split('\n');
173
187
  }
174
188
  catch (e) {
189
+ const isSpawnError = e instanceof child_process_promisified_1.SpawnError;
175
190
  // swallow error
176
- if (e.code === 128) {
191
+ if (isSpawnError && e.context.code === 128) {
177
192
  return [];
178
193
  }
179
194
  throw e;
180
195
  }
181
196
  }
182
197
  exports.getCommitsInMergeCommit = getCommitsInMergeCommit;
183
- async function cherrypick({ options, sha, mergedTargetPullRequest, commitAuthor, }) {
184
- const mainlinArg = options.mainline != undefined ? ` --mainline ${options.mainline}` : '';
185
- const cherrypickRefArg = options.cherrypickRef === false ? '' : ' -x';
186
- let shaOrRange = sha;
198
+ async function getShaOrRange(options, sha) {
187
199
  if (!options.mainline) {
188
200
  try {
189
201
  const isMergeCommit = await getIsMergeCommit(options, sha);
190
202
  if (isMergeCommit) {
191
203
  const shas = await getCommitsInMergeCommit(options, sha);
192
- shaOrRange = `${(0, lodash_1.last)(shas)}^..${(0, lodash_1.first)(shas)}`;
204
+ return `${(0, lodash_1.last)(shas)}^..${(0, lodash_1.first)(shas)}`;
193
205
  }
194
206
  }
195
207
  catch (e) {
196
- // swallow error if it's a known error
197
- // exit 128 will happen for many things, among others when the cherrypicked commit is empty
198
- if (e.code !== 128) {
208
+ const isSpawnError = e instanceof child_process_promisified_1.SpawnError;
209
+ // swallow error if it's a 128 exit code
210
+ // exit 128 happens when the cherrypicked commit is empty which is handled below
211
+ // (128 also applies to many other types of errors)
212
+ if (!isSpawnError || e.context.code !== 128) {
199
213
  throw e;
200
214
  }
201
215
  }
202
216
  }
203
- const cmd = `git -c user.name="${commitAuthor.name}" -c user.email="${commitAuthor.email}" cherry-pick${cherrypickRefArg}${mainlinArg} ${shaOrRange}`;
217
+ return sha;
218
+ }
219
+ async function cherrypick({ options, sha, mergedTargetPullRequest, commitAuthor, }) {
220
+ const shaOrRange = await getShaOrRange(options, sha);
221
+ const cmdArgs = [
222
+ '-c',
223
+ `user.name="${commitAuthor.name}"`,
224
+ '-c',
225
+ `user.email="${commitAuthor.email}"`,
226
+ `cherry-pick`,
227
+ ...(options.mainline != undefined
228
+ ? ['--mainline', `${options.mainline}`]
229
+ : []),
230
+ ...(options.cherrypickRef === false ? [] : ['-x']),
231
+ shaOrRange,
232
+ ];
204
233
  try {
205
- await (0, child_process_promisified_1.exec)(cmd, { cwd: (0, env_1.getRepoPath)(options) });
234
+ const cwd = (0, env_1.getRepoPath)(options);
235
+ await (0, child_process_promisified_1.spawnPromise)('git', cmdArgs, cwd);
206
236
  return { conflictingFiles: [], unstagedFiles: [], needsResolving: false };
207
237
  }
208
238
  catch (e) {
209
- // missing `mainline` option
210
- if (e.message.includes('is a merge but no -m option was given')) {
211
- throw new HandledError_1.HandledError('Cherrypick failed because the selected commit was a merge commit. Please try again by specifying the parent with the `mainline` argument:\n\n> backport --mainline\n\nor:\n\n> backport --mainline <parent-number>\n\nOr refer to the git documentation for more information: https://git-scm.com/docs/git-cherry-pick#Documentation/git-cherry-pick.txt---mainlineparent-number');
212
- }
213
- // commit was already backported
214
- if (e.message.includes('The previous cherry-pick is now empty')) {
215
- const shortSha = (0, commitFormatters_1.getShortSha)(sha);
216
- throw new HandledError_1.HandledError(`Cherrypick failed because the selected commit (${shortSha}) is empty. ${mergedTargetPullRequest?.url
217
- ? `It looks like the commit was already backported in ${mergedTargetPullRequest.url}`
218
- : 'Did you already backport this commit? '}`);
219
- }
220
- if (e.message.includes(`bad object ${sha}`)) {
221
- throw new HandledError_1.HandledError(`Cherrypick failed because commit "${sha}" was not found`);
222
- }
223
- const isCherryPickError = e.cmd?.includes('cherry-pick') && e.code > 0;
224
- if (isCherryPickError) {
225
- const [conflictingFiles, unstagedFiles] = await Promise.all([
226
- getConflictingFiles(options),
227
- getUnstagedFiles(options),
228
- ]);
229
- if (!(0, lodash_1.isEmpty)(conflictingFiles) || !(0, lodash_1.isEmpty)(unstagedFiles))
230
- return { conflictingFiles, unstagedFiles, needsResolving: true };
239
+ const isSpawnError = e instanceof child_process_promisified_1.SpawnError;
240
+ if (isSpawnError) {
241
+ // missing `mainline` option
242
+ if (e.message.includes('is a merge but no -m option was given')) {
243
+ throw new BackportError_1.BackportError('Cherrypick failed because the selected commit was a merge commit. Please try again by specifying the parent with the `mainline` argument:\n\n> backport --mainline\n\nor:\n\n> backport --mainline <parent-number>\n\nOr refer to the git documentation for more information: https://git-scm.com/docs/git-cherry-pick#Documentation/git-cherry-pick.txt---mainlineparent-number');
244
+ }
245
+ // commit was already backported
246
+ if (e.message.includes('The previous cherry-pick is now empty')) {
247
+ const shortSha = (0, commitFormatters_1.getShortSha)(sha);
248
+ throw new BackportError_1.BackportError(`Cherrypick failed because the selected commit (${shortSha}) is empty. ${mergedTargetPullRequest?.url
249
+ ? `It looks like the commit was already backported in ${mergedTargetPullRequest.url}`
250
+ : 'Did you already backport this commit? '}`);
251
+ }
252
+ if (e.message.includes(`bad object ${sha}`)) {
253
+ throw new BackportError_1.BackportError(`Cherrypick failed because commit "${sha}" was not found`);
254
+ }
255
+ const isCherryPickError = e.context.cmdArgs.includes('cherry-pick') && e.context.code > 0;
256
+ if (isCherryPickError) {
257
+ const [conflictingFiles, unstagedFiles] = await Promise.all([
258
+ getConflictingFiles(options),
259
+ getUnstagedFiles(options),
260
+ ]);
261
+ if (!(0, lodash_1.isEmpty)(conflictingFiles) || !(0, lodash_1.isEmpty)(unstagedFiles))
262
+ return { conflictingFiles, unstagedFiles, needsResolving: true };
263
+ }
231
264
  }
232
- // re-throw error if there are no conflicts to solve
265
+ // re-throw error if it didn't match the handled cases above
233
266
  throw e;
234
267
  }
235
268
  }
236
269
  exports.cherrypick = cherrypick;
237
270
  async function commitChanges(commit, options) {
238
- const noVerifyFlag = options.noVerify ? ` --no-verify` : '';
271
+ const noVerifyFlag = options.noVerify ? ['--no-verify'] : [];
272
+ const cwd = (0, env_1.getRepoPath)(options);
239
273
  try {
240
- await (0, child_process_promisified_1.exec)(`git commit --no-edit${noVerifyFlag}`, {
241
- cwd: (0, env_1.getRepoPath)(options),
242
- });
274
+ await (0, child_process_promisified_1.spawnPromise)('git', [
275
+ 'commit',
276
+ '--no-edit',
277
+ ...noVerifyFlag, // bypass pre-commit and commit-msg hooks
278
+ ], cwd);
243
279
  }
244
280
  catch (e) {
245
- if (e.stdout?.includes('nothing to commit')) {
246
- logger_1.logger.info(`Could not run "git commit". Probably because the changes were manually committed`, e);
247
- return;
248
- }
249
- // manually set the commit message if the inferred commit message is empty
250
- // this can happen if the user runs `git reset HEAD` and thereby aborts the cherrypick process
251
- if (e.stderr?.includes('Aborting commit due to empty commit message')) {
252
- await (0, child_process_promisified_1.exec)(`git commit -m "${commit.sourceCommit.message}" ${noVerifyFlag}`, {
253
- cwd: (0, env_1.getRepoPath)(options),
254
- });
255
- return;
281
+ const isSpawnError = e instanceof child_process_promisified_1.SpawnError;
282
+ if (isSpawnError) {
283
+ if (e.context.stdout.includes('nothing to commit')) {
284
+ logger_1.logger.info(`Could not run "git commit". Probably because the changes were manually committed`, e);
285
+ return;
286
+ }
287
+ // manually set the commit message if the inferred commit message is empty
288
+ // this can happen if the user runs `git reset HEAD` and thereby aborts the cherrypick process
289
+ if (e.context.stderr.includes('Aborting commit due to empty commit message')) {
290
+ await (0, child_process_promisified_1.spawnPromise)('git', [
291
+ 'commit',
292
+ `--message=${commit.sourceCommit.message}`,
293
+ ...noVerifyFlag, // bypass pre-commit and commit-msg hooks
294
+ ], cwd);
295
+ return;
296
+ }
256
297
  }
257
298
  // rethrow error if it can't be handled
258
299
  throw e;
@@ -262,13 +303,15 @@ exports.commitChanges = commitChanges;
262
303
  async function getConflictingFiles(options) {
263
304
  const repoPath = (0, env_1.getRepoPath)(options);
264
305
  try {
265
- await (0, child_process_promisified_1.exec)(`git --no-pager diff --check`, { cwd: repoPath });
306
+ const cwd = repoPath;
307
+ await (0, child_process_promisified_1.spawnPromise)('git', ['--no-pager', 'diff', '--check'], cwd);
266
308
  return [];
267
309
  }
268
310
  catch (e) {
269
- const isConflictError = e.cmd && e.code === 2;
311
+ const isSpawnError = e instanceof child_process_promisified_1.SpawnError;
312
+ const isConflictError = isSpawnError && e.context.code === 2;
270
313
  if (isConflictError) {
271
- const files = e.stdout
314
+ const files = e.context.stdout
272
315
  .split('\n')
273
316
  .filter((line) => !!line.trim() && !line.startsWith('+') && !line.startsWith('-'))
274
317
  .map((line) => {
@@ -292,9 +335,8 @@ exports.getConflictingFiles = getConflictingFiles;
292
335
  // retrieve the list of files that could not be cleanly merged
293
336
  async function getUnstagedFiles(options) {
294
337
  const repoPath = (0, env_1.getRepoPath)(options);
295
- const res = await (0, child_process_promisified_1.exec)(`git --no-pager diff --name-only`, {
296
- cwd: repoPath,
297
- });
338
+ const cwd = repoPath;
339
+ const res = await (0, child_process_promisified_1.spawnPromise)('git', ['--no-pager', 'diff', '--name-only'], cwd);
298
340
  const files = res.stdout
299
341
  .split('\n')
300
342
  .filter((file) => !!file)
@@ -304,8 +346,9 @@ async function getUnstagedFiles(options) {
304
346
  exports.getUnstagedFiles = getUnstagedFiles;
305
347
  async function getGitConfig({ dir, key, }) {
306
348
  try {
307
- const res = await (0, child_process_promisified_1.exec)(`git config ${key}`, { cwd: dir });
308
- return res.stdout;
349
+ const cwd = dir;
350
+ const res = await (0, child_process_promisified_1.spawnPromise)('git', ['config', key], cwd);
351
+ return res.stdout.trim();
309
352
  }
310
353
  catch (e) {
311
354
  return;
@@ -318,16 +361,30 @@ exports.getGitConfig = getGitConfig;
318
361
  async function createBackportBranch({ options, targetBranch, backportBranch, }) {
319
362
  const spinner = (0, ora_1.ora)(options.ci, 'Pulling latest changes').start();
320
363
  try {
321
- const res = await (0, child_process_promisified_1.exec)(`git reset --hard && git clean -d --force && git fetch ${options.repoOwner} ${targetBranch} && git checkout -B ${backportBranch} ${options.repoOwner}/${targetBranch} --no-track`, { cwd: (0, env_1.getRepoPath)(options) });
364
+ const cwd = (0, env_1.getRepoPath)(options);
365
+ await (0, child_process_promisified_1.spawnPromise)('git', ['reset', '--hard'], cwd);
366
+ await (0, child_process_promisified_1.spawnPromise)('git', ['clean', '-d', '--force'], cwd);
367
+ await (0, child_process_promisified_1.spawnPromise)('git', ['fetch', options.repoOwner, targetBranch], cwd);
368
+ await (0, child_process_promisified_1.spawnPromise)('git', [
369
+ 'checkout',
370
+ '-B',
371
+ backportBranch,
372
+ `${options.repoOwner}/${targetBranch}`,
373
+ '--no-track',
374
+ ], cwd);
322
375
  spinner.succeed();
323
- return res;
324
376
  }
325
377
  catch (e) {
326
378
  spinner.fail();
327
- const isBranchInvalid = e.stderr?.toLowerCase().includes(`couldn't find remote ref`) ||
328
- e.stderr?.toLowerCase().includes(`invalid refspec`);
329
- if (isBranchInvalid) {
330
- throw new HandledError_1.HandledError(`The branch "${targetBranch}" is invalid or doesn't exist`);
379
+ if (e instanceof child_process_promisified_1.SpawnError) {
380
+ const isBranchInvalid = e.context.stderr.toLowerCase().includes(`couldn't find remote ref`) ||
381
+ e.context.stderr.toLowerCase().includes(`invalid refspec`) ||
382
+ e.context.stderr
383
+ .toLowerCase()
384
+ .includes(`is not a commit and a branch '${backportBranch}' cannot be created from it`);
385
+ if (isBranchInvalid) {
386
+ throw new BackportError_1.BackportError(`The branch "${targetBranch}" is invalid or doesn't exist`);
387
+ }
331
388
  }
332
389
  throw e;
333
390
  }
@@ -335,7 +392,10 @@ async function createBackportBranch({ options, targetBranch, backportBranch, })
335
392
  exports.createBackportBranch = createBackportBranch;
336
393
  async function deleteBackportBranch({ options, backportBranch, }) {
337
394
  const spinner = (0, ora_1.ora)(options.ci).start();
338
- await (0, child_process_promisified_1.exec)(`git reset --hard && git checkout ${options.sourceBranch} && git branch -D ${backportBranch}`, { cwd: (0, env_1.getRepoPath)(options) });
395
+ const cwd = (0, env_1.getRepoPath)(options);
396
+ await (0, child_process_promisified_1.spawnPromise)('git', ['reset', '--hard'], cwd);
397
+ await (0, child_process_promisified_1.spawnPromise)('git', ['checkout', options.sourceBranch], cwd);
398
+ await (0, child_process_promisified_1.spawnPromise)('git', ['branch', '--delete', '--force', backportBranch], cwd);
339
399
  spinner.stop();
340
400
  }
341
401
  exports.deleteBackportBranch = deleteBackportBranch;
@@ -350,24 +410,30 @@ async function pushBackportBranch({ options, backportBranch, }) {
350
410
  const repoForkOwner = getRepoForkOwner(options);
351
411
  const spinner = (0, ora_1.ora)(options.ci, `Pushing branch "${repoForkOwner}:${backportBranch}"`).start();
352
412
  try {
353
- const res = await (0, child_process_promisified_1.exec)(`git push ${repoForkOwner} ${backportBranch}:${backportBranch} --force`, { cwd: (0, env_1.getRepoPath)(options) });
413
+ const cwd = (0, env_1.getRepoPath)(options);
414
+ const res = await (0, child_process_promisified_1.spawnPromise)('git', ['push', repoForkOwner, `${backportBranch}:${backportBranch}`, '--force'], cwd);
354
415
  spinner.succeed();
355
416
  return res;
356
417
  }
357
418
  catch (e) {
358
419
  spinner.fail();
359
- if (e.stderr?.toLowerCase().includes(`repository not found`)) {
360
- throw new HandledError_1.HandledError(`Error pushing to https://github.com/${repoForkOwner}/${options.repoName}. Repository does not exist. Either fork the source repository (https://github.com/${options.repoOwner}/${options.repoName}) or disable fork mode "--no-fork". Read more about "fork mode" in the docs: https://github.com/sqren/backport/blob/3a182b17e0e7237c12915895aea9d71f49eb2886/docs/configuration.md#fork`);
420
+ if (e instanceof child_process_promisified_1.SpawnError &&
421
+ e.context.stderr.toLowerCase().includes(`repository not found`)) {
422
+ throw new BackportError_1.BackportError(`Error pushing to https://github.com/${repoForkOwner}/${options.repoName}. Repository does not exist. Either fork the repository (https://github.com/${options.repoOwner}/${options.repoName}) or disable fork mode via "--no-fork".\nRead more about fork mode in the docs: https://github.com/sqren/backport/blob/main/docs/configuration.md#fork`);
423
+ }
424
+ if (e instanceof child_process_promisified_1.SpawnError &&
425
+ e.context.stderr.includes(`could not read Username for`)) {
426
+ throw new BackportError_1.BackportError(`Invalid credentials: ${e.message}`);
361
427
  }
362
428
  throw e;
363
429
  }
364
430
  }
365
431
  exports.pushBackportBranch = pushBackportBranch;
366
432
  // retrieve path to local repo (cwd) if it matches `repoName` / `repoOwner`
367
- async function getLocalRepoPath(options) {
433
+ async function getLocalSourceRepoPath(options) {
368
434
  const remotes = await getRepoInfoFromGitRemotes({ cwd: options.cwd });
369
435
  const hasMatchingGitRemote = remotes.some((remote) => remote.repoName === options.repoName &&
370
436
  remote.repoOwner === options.repoOwner);
371
437
  return hasMatchingGitRemote ? getGitProjectRootPath(options.cwd) : undefined;
372
438
  }
373
- exports.getLocalRepoPath = getLocalRepoPath;
439
+ exports.getLocalSourceRepoPath = getLocalSourceRepoPath;
@@ -0,0 +1 @@
1
+ export {};