backport 7.3.6 → 8.1.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 (245) hide show
  1. package/README.md +16 -21
  2. package/dist/backportRun.d.ts +18 -6
  3. package/dist/backportRun.js +70 -50
  4. package/dist/entrypoint.cli.js +4 -8
  5. package/dist/entrypoint.module.d.ts +13 -6
  6. package/dist/entrypoint.module.js +17 -19
  7. package/dist/entrypoint.module.private.test.js +129 -330
  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 +13 -0
  13. package/dist/lib/cherrypickAndCreateTargetPullRequest.js +238 -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 +58 -0
  18. package/dist/lib/env.d.ts +7 -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 +206 -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 +136 -0
  58. package/dist/lib/github/v3/createStatusComment.test.d.ts +1 -0
  59. package/dist/lib/github/v3/createStatusComment.test.js +461 -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/logger.d.ts +9 -0
  125. package/dist/lib/logger.js +74 -0
  126. package/dist/lib/ora.d.ts +2 -0
  127. package/dist/lib/ora.js +21 -0
  128. package/dist/lib/prompt.test.d.ts +1 -0
  129. package/dist/lib/prompt.test.js +139 -0
  130. package/dist/lib/prompts.d.ts +17 -0
  131. package/dist/lib/prompts.js +132 -0
  132. package/dist/lib/remoteConfig.d.ts +20 -0
  133. package/dist/lib/remoteConfig.js +52 -0
  134. package/dist/lib/sequentially.d.ts +1 -0
  135. package/dist/lib/sequentially.js +10 -0
  136. package/dist/lib/setupRepo.d.ts +2 -0
  137. package/dist/lib/setupRepo.js +56 -0
  138. package/dist/lib/setupRepo.test.d.ts +1 -0
  139. package/dist/lib/setupRepo.test.js +278 -0
  140. package/dist/lib/sourceCommit/getExpectedTargetPullRequests.d.ts +16 -0
  141. package/dist/lib/sourceCommit/getExpectedTargetPullRequests.js +102 -0
  142. package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
  143. package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.js +467 -0
  144. package/dist/lib/sourceCommit/getMockSourceCommit.d.ts +26 -0
  145. package/dist/lib/sourceCommit/getMockSourceCommit.js +103 -0
  146. package/dist/lib/sourceCommit/parseSourceCommit.d.ts +108 -0
  147. package/dist/lib/sourceCommit/parseSourceCommit.js +123 -0
  148. package/dist/lib/sourceCommit/parseSourceCommit.test.d.ts +1 -0
  149. package/dist/lib/sourceCommit/parseSourceCommit.test.js +226 -0
  150. package/dist/options/ConfigOptions.d.ts +6 -4
  151. package/dist/options/cliArgs.d.ts +16 -9
  152. package/dist/options/cliArgs.js +54 -28
  153. package/dist/options/cliArgs.test.js +128 -4
  154. package/dist/options/config/config.d.ts +7 -6
  155. package/dist/options/config/config.js +5 -7
  156. package/dist/options/config/config.test.js +0 -1
  157. package/dist/options/config/globalConfig.d.ts +5 -3
  158. package/dist/options/config/globalConfig.js +17 -14
  159. package/dist/options/config/projectConfig.d.ts +2 -2
  160. package/dist/options/config/projectConfig.js +3 -3
  161. package/dist/options/config/projectConfig.test.js +19 -7
  162. package/dist/options/config/readConfigFile.d.ts +9 -7
  163. package/dist/options/config/readConfigFile.js +2 -2
  164. package/dist/options/options.d.ts +44 -9
  165. package/dist/options/options.js +22 -27
  166. package/dist/options/options.test.js +119 -58
  167. package/dist/runSequentially.d.ts +14 -7
  168. package/dist/runSequentially.js +26 -11
  169. package/dist/scripts/postinstall.js +4 -3
  170. package/dist/scripts/postinstall.test.js +6 -2
  171. package/dist/services/BackportError.d.ts +19 -0
  172. package/dist/services/BackportError.js +29 -0
  173. package/dist/services/HandledBackportError.d.ts +19 -0
  174. package/dist/services/HandledBackportError.js +29 -0
  175. package/dist/services/HandledError.d.ts +7 -3
  176. package/dist/services/HandledError.js +13 -13
  177. package/dist/services/child-process-promisified.d.ts +19 -3
  178. package/dist/services/child-process-promisified.js +46 -17
  179. package/dist/services/git.d.ts +6 -7
  180. package/dist/services/git.integration.test.js +381 -65
  181. package/dist/services/git.js +189 -127
  182. package/dist/services/git.private.test.d.ts +1 -0
  183. package/dist/services/git.private.test.js +618 -0
  184. package/dist/services/git.test.js +167 -158
  185. package/dist/services/github/v3/addAssigneesToPullRequest.js +1 -1
  186. package/dist/services/github/v3/addLabelsToPullRequest.js +1 -1
  187. package/dist/services/github/v3/addReviewersToPullRequest.js +2 -1
  188. package/dist/services/github/v3/createPullRequest.js +4 -2
  189. package/dist/services/github/v3/createStatusComment.js +17 -17
  190. package/dist/services/github/v3/createStatusComment.test.js +22 -9
  191. package/dist/services/github/v4/apiRequestV4.js +8 -11
  192. package/dist/services/github/v4/apiRequestV4.test.js +2 -2
  193. package/dist/services/github/v4/enablePullRequestAutoMerge.js +2 -4
  194. package/dist/services/github/v4/fetchAuthorId.private.test.js +3 -6
  195. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +5 -6
  196. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +4 -3
  197. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +10 -9
  198. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -2
  199. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +10 -9
  200. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +4 -3
  201. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +9 -8
  202. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +3 -6
  203. package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +3 -2
  204. package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +3 -6
  205. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +4 -7
  206. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +2 -2
  207. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +2 -2
  208. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +6 -7
  209. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +9 -8
  210. package/dist/services/github/v4/throwOnInvalidAccessToken.js +5 -5
  211. package/dist/services/logger.d.ts +1 -4
  212. package/dist/services/logger.js +14 -19
  213. package/dist/services/test.d.ts +1 -0
  214. package/dist/services/test.js +23 -0
  215. package/dist/state.d.ts +0 -0
  216. package/dist/state.js +1 -0
  217. package/dist/test/e2e/cli/commit-author.private.test.js +4 -4
  218. package/dist/test/e2e/cli/different-merge-strategies.private.test.js +26 -24
  219. package/dist/test/e2e/cli/entrypoint.cli.private.test.d.ts +1 -0
  220. package/dist/test/e2e/cli/entrypoint.cli.private.test.js +450 -0
  221. package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +27 -28
  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.d.ts +1 -0
  226. package/dist/test/e2e/module/entrypoint.module.mutation.test.js +376 -0
  227. package/dist/test/handleUnbackportedPullRequests.private.test.js +12 -10
  228. package/dist/test/sandbox.js +5 -1
  229. package/dist/test/setupFiles/automatic-mocks.js +17 -13
  230. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +11 -7
  231. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +7 -159
  232. package/dist/ui/getCommits.js +2 -2
  233. package/dist/ui/getCommitsWithoutBackports.test.js +5 -1
  234. package/dist/ui/getGitConfigAuthor.js +1 -1
  235. package/dist/ui/getTargetBranches.js +3 -3
  236. package/dist/ui/getTargetBranches.test.js +5 -1
  237. package/dist/ui/ora.d.ts +1 -8
  238. package/dist/ui/setupRepo.js +3 -3
  239. package/dist/ui/setupRepo.test.js +98 -61
  240. package/dist/utils/isErrnoError.d.ts +2 -0
  241. package/dist/utils/isErrnoError.js +7 -0
  242. package/dist/utils/packageVersion.d.ts +1 -1
  243. package/dist/utils/packageVersion.js +1 -1
  244. package/package.json +17 -17
  245. package/yarn.lock +461 -695
@@ -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,111 +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
- // git info missing
221
- if (e.message.includes('Please tell me who you are')) {
222
- throw new HandledError_1.HandledError(e.message);
223
- }
224
- if (e.message.includes(`bad object ${sha}`)) {
225
- throw new HandledError_1.HandledError(`Cherrypick failed because commit "${sha}" was not found`);
226
- }
227
- const isCherryPickError = e.cmd?.includes('cherry-pick') && e.code > 0;
228
- if (isCherryPickError) {
229
- const [conflictingFiles, unstagedFiles] = await Promise.all([
230
- getConflictingFiles(options),
231
- getUnstagedFiles(options),
232
- ]);
233
- if (!(0, lodash_1.isEmpty)(conflictingFiles) || !(0, lodash_1.isEmpty)(unstagedFiles))
234
- 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
+ }
235
264
  }
236
- // re-throw error if there are no conflicts to solve
265
+ // re-throw error if it didn't match the handled cases above
237
266
  throw e;
238
267
  }
239
268
  }
240
269
  exports.cherrypick = cherrypick;
241
270
  async function commitChanges(commit, options) {
242
- const noVerifyFlag = options.noVerify ? ` --no-verify` : '';
271
+ const noVerifyFlag = options.noVerify ? ['--no-verify'] : [];
272
+ const cwd = (0, env_1.getRepoPath)(options);
243
273
  try {
244
- await (0, child_process_promisified_1.exec)(`git commit --no-edit${noVerifyFlag}`, {
245
- cwd: (0, env_1.getRepoPath)(options),
246
- });
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);
247
279
  }
248
280
  catch (e) {
249
- if (e.stdout?.includes('nothing to commit')) {
250
- logger_1.logger.info(`Could not run "git commit". Probably because the changes were manually committed`, e);
251
- return;
252
- }
253
- // manually set the commit message if the inferred commit message is empty
254
- // this can happen if the user runs `git reset HEAD` and thereby aborts the cherrypick process
255
- if (e.stderr?.includes('Aborting commit due to empty commit message')) {
256
- await (0, child_process_promisified_1.exec)(`git commit -m "${commit.sourceCommit.message}" ${noVerifyFlag}`, {
257
- cwd: (0, env_1.getRepoPath)(options),
258
- });
259
- 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
+ }
260
297
  }
261
298
  // rethrow error if it can't be handled
262
299
  throw e;
@@ -266,13 +303,15 @@ exports.commitChanges = commitChanges;
266
303
  async function getConflictingFiles(options) {
267
304
  const repoPath = (0, env_1.getRepoPath)(options);
268
305
  try {
269
- 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);
270
308
  return [];
271
309
  }
272
310
  catch (e) {
273
- 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;
274
313
  if (isConflictError) {
275
- const files = e.stdout
314
+ const files = e.context.stdout
276
315
  .split('\n')
277
316
  .filter((line) => !!line.trim() && !line.startsWith('+') && !line.startsWith('-'))
278
317
  .map((line) => {
@@ -296,9 +335,8 @@ exports.getConflictingFiles = getConflictingFiles;
296
335
  // retrieve the list of files that could not be cleanly merged
297
336
  async function getUnstagedFiles(options) {
298
337
  const repoPath = (0, env_1.getRepoPath)(options);
299
- const res = await (0, child_process_promisified_1.exec)(`git --no-pager diff --name-only`, {
300
- cwd: repoPath,
301
- });
338
+ const cwd = repoPath;
339
+ const res = await (0, child_process_promisified_1.spawnPromise)('git', ['--no-pager', 'diff', '--name-only'], cwd);
302
340
  const files = res.stdout
303
341
  .split('\n')
304
342
  .filter((file) => !!file)
@@ -308,8 +346,9 @@ async function getUnstagedFiles(options) {
308
346
  exports.getUnstagedFiles = getUnstagedFiles;
309
347
  async function getGitConfig({ dir, key, }) {
310
348
  try {
311
- const res = await (0, child_process_promisified_1.exec)(`git config ${key}`, { cwd: dir });
312
- 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();
313
352
  }
314
353
  catch (e) {
315
354
  return;
@@ -322,16 +361,30 @@ exports.getGitConfig = getGitConfig;
322
361
  async function createBackportBranch({ options, targetBranch, backportBranch, }) {
323
362
  const spinner = (0, ora_1.ora)(options.ci, 'Pulling latest changes').start();
324
363
  try {
325
- 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);
326
375
  spinner.succeed();
327
- return res;
328
376
  }
329
377
  catch (e) {
330
378
  spinner.fail();
331
- const isBranchInvalid = e.stderr?.toLowerCase().includes(`couldn't find remote ref`) ||
332
- e.stderr?.toLowerCase().includes(`invalid refspec`);
333
- if (isBranchInvalid) {
334
- 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
+ }
335
388
  }
336
389
  throw e;
337
390
  }
@@ -339,7 +392,10 @@ async function createBackportBranch({ options, targetBranch, backportBranch, })
339
392
  exports.createBackportBranch = createBackportBranch;
340
393
  async function deleteBackportBranch({ options, backportBranch, }) {
341
394
  const spinner = (0, ora_1.ora)(options.ci).start();
342
- 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);
343
399
  spinner.stop();
344
400
  }
345
401
  exports.deleteBackportBranch = deleteBackportBranch;
@@ -354,24 +410,30 @@ async function pushBackportBranch({ options, backportBranch, }) {
354
410
  const repoForkOwner = getRepoForkOwner(options);
355
411
  const spinner = (0, ora_1.ora)(options.ci, `Pushing branch "${repoForkOwner}:${backportBranch}"`).start();
356
412
  try {
357
- 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);
358
415
  spinner.succeed();
359
416
  return res;
360
417
  }
361
418
  catch (e) {
362
419
  spinner.fail();
363
- if (e.stderr?.toLowerCase().includes(`repository not found`)) {
364
- 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}`);
365
427
  }
366
428
  throw e;
367
429
  }
368
430
  }
369
431
  exports.pushBackportBranch = pushBackportBranch;
370
432
  // retrieve path to local repo (cwd) if it matches `repoName` / `repoOwner`
371
- async function getLocalRepoPath(options) {
433
+ async function getLocalSourceRepoPath(options) {
372
434
  const remotes = await getRepoInfoFromGitRemotes({ cwd: options.cwd });
373
435
  const hasMatchingGitRemote = remotes.some((remote) => remote.repoName === options.repoName &&
374
436
  remote.repoOwner === options.repoOwner);
375
437
  return hasMatchingGitRemote ? getGitProjectRootPath(options.cwd) : undefined;
376
438
  }
377
- exports.getLocalRepoPath = getLocalRepoPath;
439
+ exports.getLocalSourceRepoPath = getLocalSourceRepoPath;
@@ -0,0 +1 @@
1
+ export {};