backport 8.0.0 → 8.3.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +4 -4
  2. package/dist/backportRun.d.ts +5 -4
  3. package/dist/backportRun.js +42 -48
  4. package/dist/entrypoint.cli.js +3 -7
  5. package/dist/entrypoint.module.d.ts +7 -5
  6. package/dist/entrypoint.module.js +11 -9
  7. package/dist/entrypoint.module.private.test.js +25 -4
  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 +9 -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 +12 -9
  156. package/dist/options/cliArgs.js +34 -19
  157. package/dist/options/cliArgs.test.js +126 -2
  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 +3 -1
  162. package/dist/options/config/globalConfig.js +5 -5
  163. package/dist/options/config/readConfigFile.d.ts +6 -4
  164. package/dist/options/config/readConfigFile.js +2 -2
  165. package/dist/options/options.d.ts +40 -4
  166. package/dist/options/options.js +20 -24
  167. package/dist/options/options.test.js +112 -54
  168. package/dist/runSequentially.d.ts +10 -9
  169. package/dist/runSequentially.js +7 -8
  170. package/dist/scripts/postinstall.js +3 -3
  171. package/dist/scripts/postinstall.test.js +1 -1
  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 +1 -1
  177. package/dist/services/HandledError.js +5 -5
  178. package/dist/services/git.js +7 -7
  179. package/dist/services/github/v3/createPullRequest.js +2 -2
  180. package/dist/services/github/v3/createStatusComment.js +2 -2
  181. package/dist/services/github/v3/createStatusComment.test.js +5 -4
  182. package/dist/services/github/v4/apiRequestV4.js +2 -2
  183. package/dist/services/github/v4/apiRequestV4.test.js +2 -2
  184. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +3 -3
  185. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +2 -2
  186. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +3 -3
  187. package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +2 -2
  188. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +2 -2
  189. package/dist/services/github/v4/throwOnInvalidAccessToken.js +5 -5
  190. package/dist/state.d.ts +0 -0
  191. package/dist/state.js +1 -0
  192. package/dist/test/e2e/cli/commit-author.private.test.js +4 -4
  193. package/dist/test/e2e/cli/different-merge-strategies.private.test.js +27 -25
  194. package/dist/test/e2e/cli/entrypoint.cli.private.test.js +46 -250
  195. package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.d.ts +1 -0
  196. package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.js +80 -0
  197. package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.d.ts +1 -0
  198. package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.js +199 -0
  199. package/dist/test/e2e/cli/interactive-error-handling.private.test.d.ts +1 -0
  200. package/dist/test/e2e/cli/interactive-error-handling.private.test.js +80 -0
  201. package/dist/test/e2e/cli/non-interactive-error-handling.private.test.d.ts +1 -0
  202. package/dist/test/e2e/cli/non-interactive-error-handling.private.test.js +198 -0
  203. package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +13 -15
  204. package/dist/test/e2e/cli/runBackportViaCli.d.ts +5 -2
  205. package/dist/test/e2e/cli/runBackportViaCli.js +42 -29
  206. package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +22 -14
  207. package/dist/test/e2e/module/entrypoint.module.mutation.test.js +2 -2
  208. package/dist/test/handleUnbackportedPullRequests.private.test.js +3 -2
  209. package/dist/test/setupFiles/automatic-mocks.js +1 -1
  210. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +3 -3
  211. package/dist/ui/getCommits.js +2 -2
  212. package/dist/ui/getTargetBranches.js +3 -3
  213. package/dist/ui/setupRepo.js +2 -2
  214. package/dist/utils/packageVersion.d.ts +1 -1
  215. package/dist/utils/packageVersion.js +1 -1
  216. package/package.json +14 -14
  217. package/yarn.lock +125 -73
@@ -29,8 +29,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const promises_1 = __importDefault(require("fs/promises"));
30
30
  const os_1 = __importDefault(require("os"));
31
31
  const nock_1 = __importDefault(require("nock"));
32
- const git = __importStar(require("../services/git"));
33
- const logger = __importStar(require("../services/logger"));
32
+ const git = __importStar(require("../lib/git"));
33
+ const logger = __importStar(require("../lib/logger"));
34
34
  const mockConfigFiles_1 = require("../test/mockConfigFiles");
35
35
  const nockHelpers_1 = require("../test/nockHelpers");
36
36
  const options_1 = require("./options");
@@ -64,29 +64,23 @@ describe('getOptions', () => {
64
64
  projectConfig: defaultConfigs.projectConfig,
65
65
  globalConfig: { accessToken: undefined },
66
66
  });
67
- await expect(() => (0, options_1.getOptions)([], {})).rejects
68
- .toThrowErrorMatchingInlineSnapshot(`
67
+ await expect(() => (0, options_1.getOptions)({
68
+ optionsFromCliArgs: {},
69
+ optionsFromModule: {},
70
+ })).rejects.toThrowErrorMatchingInlineSnapshot(`
69
71
  "Please update your config file: \\"/myHomeDir/.backport/config.json\\".
70
72
  It must contain a valid \\"accessToken\\".
71
73
 
72
74
  Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
73
75
  `);
74
76
  });
75
- it('when accessToken is missing with --ci', async () => {
76
- (0, mockConfigFiles_1.mockConfigFiles)({
77
- projectConfig: defaultConfigs.projectConfig,
78
- globalConfig: { accessToken: undefined },
79
- });
80
- await expect(() => (0, options_1.getOptions)([], { ci: true })).rejects.toThrowErrorMatchingInlineSnapshot(`"Access token missing. It must be explicitly supplied when using \\"--ci\\" option. Example: --access-token very-secret"`);
81
- });
82
77
  it('when `targetBranches`, `targetBranchChoices` and `branchLabelMapping` are all empty', async () => {
83
78
  mockProjectConfig({
84
79
  targetBranches: undefined,
85
80
  targetBranchChoices: undefined,
86
81
  branchLabelMapping: undefined,
87
82
  });
88
- await expect(() => (0, options_1.getOptions)([], {})).rejects
89
- .toThrowErrorMatchingInlineSnapshot(`
83
+ await expect(() => (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowErrorMatchingInlineSnapshot(`
90
84
  "Please specify a target branch: \\"--branch 6.1\\".
91
85
 
92
86
  Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
@@ -94,14 +88,22 @@ describe('getOptions', () => {
94
88
  });
95
89
  describe('whe option is an empty string', () => {
96
90
  it('throws for "username"', async () => {
97
- await expect(() => (0, options_1.getOptions)([], { repoForkOwner: '', author: 'sqren' })).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"repoForkOwner\\" cannot be empty!"`);
91
+ await expect(() => (0, options_1.getOptions)({
92
+ optionsFromCliArgs: {},
93
+ optionsFromModule: { repoForkOwner: '', author: 'sqren' },
94
+ })).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"repoForkOwner\\" cannot be empty!"`);
98
95
  });
99
96
  it('throws for "author"', async () => {
100
- await expect(() => (0, options_1.getOptions)([], { author: '' })).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"author\\" cannot be empty!"`);
97
+ await expect(() => (0, options_1.getOptions)({
98
+ optionsFromCliArgs: {},
99
+ optionsFromModule: { author: '' },
100
+ })).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"author\\" cannot be empty!"`);
101
101
  });
102
102
  it('throws for "accessToken"', async () => {
103
- await expect(() => (0, options_1.getOptions)([], { accessToken: '' })).rejects
104
- .toThrowErrorMatchingInlineSnapshot(`
103
+ await expect(() => (0, options_1.getOptions)({
104
+ optionsFromCliArgs: {},
105
+ optionsFromModule: { accessToken: '' },
106
+ })).rejects.toThrowErrorMatchingInlineSnapshot(`
105
107
  "Please update your config file: \\"/myHomeDir/.backport/config.json\\".
106
108
  It must contain a valid \\"accessToken\\".
107
109
 
@@ -115,8 +117,7 @@ describe('getOptions', () => {
115
117
  });
116
118
  it('should throw if there are no remotes', async () => {
117
119
  jest.spyOn(git, 'getRepoInfoFromGitRemotes').mockResolvedValue([]);
118
- await expect(() => (0, options_1.getOptions)([], {})).rejects
119
- .toThrowErrorMatchingInlineSnapshot(`
120
+ await expect(() => (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowErrorMatchingInlineSnapshot(`
120
121
  "Please specify a repository: \\"--repo elastic/kibana\\".
121
122
 
122
123
  Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
@@ -131,7 +132,10 @@ describe('getOptions', () => {
131
132
  jest
132
133
  .spyOn(git, 'getRepoInfoFromGitRemotes')
133
134
  .mockResolvedValue([{ repoName: 'kibana', repoOwner: 'sqren' }]);
134
- const options = await (0, options_1.getOptions)([], {});
135
+ const options = await (0, options_1.getOptions)({
136
+ optionsFromCliArgs: {},
137
+ optionsFromModule: {},
138
+ });
135
139
  expect(options.repoName).toBe('kibana');
136
140
  expect(options.repoOwner).toBe('elastic');
137
141
  });
@@ -139,7 +143,10 @@ describe('getOptions', () => {
139
143
  });
140
144
  it('reads options from remote config', async () => {
141
145
  mockGithubConfigOptions({ hasRemoteConfig: true });
142
- const options = await (0, options_1.getOptions)([], {});
146
+ const options = await (0, options_1.getOptions)({
147
+ optionsFromCliArgs: {},
148
+ optionsFromModule: {},
149
+ });
143
150
  expect(options.branchLabelMapping).toEqual({
144
151
  '^v8.2.0$': 'option-from-remote',
145
152
  });
@@ -147,17 +154,20 @@ describe('getOptions', () => {
147
154
  });
148
155
  it('should ensure that "backport" branch does not exist', async () => {
149
156
  mockGithubConfigOptions({ hasBackportBranch: true });
150
- await expect((0, options_1.getOptions)([], {})).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
157
+ await expect((0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
151
158
  });
152
159
  it('should merge config options and module options', async () => {
153
160
  mockGithubConfigOptions({});
154
161
  const myFn = async () => true;
155
- const options = await (0, options_1.getOptions)([], { autoFixConflicts: myFn });
162
+ const options = await (0, options_1.getOptions)({
163
+ optionsFromCliArgs: {},
164
+ optionsFromModule: { autoFixConflicts: myFn },
165
+ });
156
166
  expect(options.autoFixConflicts).toBe(myFn);
157
167
  });
158
168
  it('should call setAccessToken', async () => {
159
169
  mockGithubConfigOptions({});
160
- await (0, options_1.getOptions)([], {});
170
+ await (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} });
161
171
  expect(logger.setAccessToken).toHaveBeenCalledTimes(1);
162
172
  });
163
173
  it('should return options', async () => {
@@ -165,7 +175,10 @@ describe('getOptions', () => {
165
175
  viewerLogin: 'john.diller',
166
176
  defaultBranchRef: 'default-branch-from-github',
167
177
  });
168
- const options = await (0, options_1.getOptions)([], {});
178
+ const options = await (0, options_1.getOptions)({
179
+ optionsFromCliArgs: {},
180
+ optionsFromModule: {},
181
+ });
169
182
  expect(options).toEqual({
170
183
  accessToken: 'abc',
171
184
  assignees: [],
@@ -176,7 +189,6 @@ describe('getOptions', () => {
176
189
  autoMergeMethod: 'merge',
177
190
  backportBinary: 'backport',
178
191
  cherrypickRef: true,
179
- ci: false,
180
192
  commitPaths: [],
181
193
  cwd: expect.any(String),
182
194
  dateSince: null,
@@ -186,11 +198,14 @@ describe('getOptions', () => {
186
198
  fork: true,
187
199
  gitHostname: 'github.com',
188
200
  githubApiBaseUrlV4: 'http://localhost/graphql',
201
+ interactive: true,
189
202
  maxNumber: 10,
190
203
  multipleBranches: true,
191
204
  multipleCommits: false,
192
205
  noVerify: true,
193
- publishStatusComment: true,
206
+ publishStatusCommentOnAbort: false,
207
+ publishStatusCommentOnSuccess: true,
208
+ publishStatusCommentOnFailure: false,
194
209
  repoForkOwner: 'john.diller',
195
210
  repoName: 'kibana',
196
211
  repoOwner: 'elastic',
@@ -208,11 +223,17 @@ describe('getOptions', () => {
208
223
  mockGithubConfigOptions({ defaultBranchRef: 'some-default-branch' });
209
224
  });
210
225
  it('uses the `defaultBranchRef` as default', async () => {
211
- const options = await (0, options_1.getOptions)([], {});
226
+ const options = await (0, options_1.getOptions)({
227
+ optionsFromCliArgs: {},
228
+ optionsFromModule: {},
229
+ });
212
230
  expect(options.sourceBranch).toBe('some-default-branch');
213
231
  });
214
232
  it('uses the sourceBranch given via cli instead of `defaultBranchRef`', async () => {
215
- const options = await (0, options_1.getOptions)(['--source-branch', 'cli-source-branch'], {});
233
+ const options = await (0, options_1.getOptions)({
234
+ optionsFromCliArgs: { sourceBranch: 'cli-source-branch' },
235
+ optionsFromModule: {},
236
+ });
216
237
  expect(options.sourceBranch).toBe('cli-source-branch');
217
238
  });
218
239
  });
@@ -221,16 +242,25 @@ describe('getOptions', () => {
221
242
  mockGithubConfigOptions({});
222
243
  });
223
244
  it('is enabled by default', async () => {
224
- const { fork } = await (0, options_1.getOptions)([], {});
245
+ const { fork } = await (0, options_1.getOptions)({
246
+ optionsFromCliArgs: {},
247
+ optionsFromModule: {},
248
+ });
225
249
  expect(fork).toBe(true);
226
250
  });
227
- it('can be disabled via `--no-fork` flag', async () => {
228
- const { fork } = await (0, options_1.getOptions)(['--no-fork'], {});
251
+ it('can be disabled via cli', async () => {
252
+ const { fork } = await (0, options_1.getOptions)({
253
+ optionsFromCliArgs: { fork: false },
254
+ optionsFromModule: {},
255
+ });
229
256
  expect(fork).toBe(false);
230
257
  });
231
258
  it('can be disabled via config file', async () => {
232
259
  mockProjectConfig({ fork: false });
233
- const { fork } = await (0, options_1.getOptions)([], {});
260
+ const { fork } = await (0, options_1.getOptions)({
261
+ optionsFromCliArgs: {},
262
+ optionsFromModule: {},
263
+ });
234
264
  expect(fork).toBe(false);
235
265
  });
236
266
  });
@@ -238,13 +268,19 @@ describe('getOptions', () => {
238
268
  beforeEach(() => {
239
269
  mockGithubConfigOptions({});
240
270
  });
241
- it('can be set via `--reviewer` flag', async () => {
242
- const { reviewers } = await (0, options_1.getOptions)(['--reviewer', 'peter'], {});
271
+ it('can be set via cli', async () => {
272
+ const { reviewers } = await (0, options_1.getOptions)({
273
+ optionsFromCliArgs: { reviewers: ['peter'] },
274
+ optionsFromModule: {},
275
+ });
243
276
  expect(reviewers).toEqual(['peter']);
244
277
  });
245
278
  it('can be set via config file', async () => {
246
279
  mockProjectConfig({ reviewers: ['john'] });
247
- const { reviewers } = await (0, options_1.getOptions)([], {});
280
+ const { reviewers } = await (0, options_1.getOptions)({
281
+ optionsFromCliArgs: {},
282
+ optionsFromModule: {},
283
+ });
248
284
  expect(reviewers).toEqual(['john']);
249
285
  });
250
286
  });
@@ -253,15 +289,24 @@ describe('getOptions', () => {
253
289
  mockGithubConfigOptions({});
254
290
  });
255
291
  it('is not enabled by default', async () => {
256
- const { mainline } = await (0, options_1.getOptions)([], {});
292
+ const { mainline } = await (0, options_1.getOptions)({
293
+ optionsFromCliArgs: {},
294
+ optionsFromModule: {},
295
+ });
257
296
  expect(mainline).toBe(undefined);
258
297
  });
259
298
  it('can be set via `--mainline` flag', async () => {
260
- const { mainline } = await (0, options_1.getOptions)(['--mainline'], {});
299
+ const { mainline } = await (0, options_1.getOptions)({
300
+ optionsFromCliArgs: { mainline: 1 },
301
+ optionsFromModule: {},
302
+ });
261
303
  expect(mainline).toBe(1);
262
304
  });
263
305
  it('accepts numeric values', async () => {
264
- const { mainline } = await (0, options_1.getOptions)(['--mainline', '2'], {});
306
+ const { mainline } = await (0, options_1.getOptions)({
307
+ optionsFromCliArgs: { mainline: 2 },
308
+ optionsFromModule: {},
309
+ });
265
310
  expect(mainline).toBe(2);
266
311
  });
267
312
  });
@@ -270,25 +315,33 @@ describe('getOptions', () => {
270
315
  mockGithubConfigOptions({ viewerLogin: 'billy.bob' });
271
316
  });
272
317
  it('defaults to authenticated user', async () => {
273
- const { author } = await (0, options_1.getOptions)([], {});
318
+ const { author } = await (0, options_1.getOptions)({
319
+ optionsFromCliArgs: {},
320
+ optionsFromModule: {},
321
+ });
274
322
  expect(author).toBe('billy.bob');
275
323
  });
276
324
  it('can be overridden via `--author` flag', async () => {
277
- const { author } = await (0, options_1.getOptions)(['--author', 'john.doe'], {});
325
+ const { author } = await (0, options_1.getOptions)({
326
+ optionsFromCliArgs: { author: 'john.doe' },
327
+ optionsFromModule: {},
328
+ });
278
329
  expect(author).toBe('john.doe');
279
330
  });
280
- it('can be reset via `--all` flag', async () => {
281
- const { author } = await (0, options_1.getOptions)(['--all'], {});
282
- expect(author).toBe(null);
283
- });
284
331
  it('can be reset via config file (similar to `--all` flag)', async () => {
285
332
  mockProjectConfig({ author: null });
286
- const { author } = await (0, options_1.getOptions)([], {});
333
+ const { author } = await (0, options_1.getOptions)({
334
+ optionsFromCliArgs: {},
335
+ optionsFromModule: {},
336
+ });
287
337
  expect(author).toBe(null);
288
338
  });
289
339
  it('can be overridden via config file', async () => {
290
340
  mockProjectConfig({ author: 'jane.doe' });
291
- const { author } = await (0, options_1.getOptions)([], {});
341
+ const { author } = await (0, options_1.getOptions)({
342
+ optionsFromCliArgs: {},
343
+ optionsFromModule: {},
344
+ });
292
345
  expect(author).toBe('jane.doe');
293
346
  });
294
347
  });
@@ -297,21 +350,26 @@ describe('getOptions', () => {
297
350
  mockGithubConfigOptions({});
298
351
  });
299
352
  it('should default to true', async () => {
300
- const { cherrypickRef } = await (0, options_1.getOptions)([], {});
353
+ const { cherrypickRef } = await (0, options_1.getOptions)({
354
+ optionsFromCliArgs: {},
355
+ optionsFromModule: {},
356
+ });
301
357
  expect(cherrypickRef).toBe(true);
302
358
  });
303
- it('should negate with `noCherrypickRef` cli arg', async () => {
304
- const { cherrypickRef } = await (0, options_1.getOptions)(['--no-cherrypick-ref'], {});
305
- expect(cherrypickRef).toBe(false);
306
- });
307
359
  it('should be settable via config file', async () => {
308
360
  mockProjectConfig({ cherrypickRef: false });
309
- const { cherrypickRef } = await (0, options_1.getOptions)([], {});
361
+ const { cherrypickRef } = await (0, options_1.getOptions)({
362
+ optionsFromCliArgs: {},
363
+ optionsFromModule: {},
364
+ });
310
365
  expect(cherrypickRef).toBe(false);
311
366
  });
312
367
  it('cli args overwrites config', async () => {
313
368
  mockProjectConfig({ cherrypickRef: false });
314
- const { cherrypickRef } = await (0, options_1.getOptions)(['--cherrypick-ref'], {});
369
+ const { cherrypickRef } = await (0, options_1.getOptions)({
370
+ optionsFromCliArgs: { cherrypickRef: true },
371
+ optionsFromModule: {},
372
+ });
315
373
  expect(cherrypickRef).toBe(true);
316
374
  });
317
375
  });
@@ -1,25 +1,26 @@
1
+ import { BackportError } from './lib/BackportError';
2
+ import { Commit } from './lib/sourceCommit/parseSourceCommit';
1
3
  import { ValidConfigOptions } from './options/options';
2
- import { HandledError } from './services/HandledError';
3
- import { Commit } from './services/sourceCommit/parseSourceCommit';
4
- import { GitConfigAuthor } from './ui/getGitConfigAuthor';
5
- export declare type Result = {
4
+ export declare type SuccessResult = {
6
5
  status: 'success';
7
6
  didUpdate: boolean;
8
7
  targetBranch: string;
9
8
  pullRequestUrl: string;
10
9
  pullRequestNumber: number;
11
- } | {
10
+ };
11
+ export declare type HandledErrorResult = {
12
12
  status: 'handled-error';
13
13
  targetBranch: string;
14
- error: HandledError;
15
- } | {
14
+ error: BackportError;
15
+ };
16
+ export declare type UnhandledErrorResult = {
16
17
  status: 'unhandled-error';
17
18
  targetBranch: string;
18
19
  error: Error;
19
20
  };
20
- export declare function runSequentially({ options, commits, targetBranches, gitConfigAuthor, }: {
21
+ export declare type Result = SuccessResult | HandledErrorResult | UnhandledErrorResult;
22
+ export declare function runSequentially({ options, commits, targetBranches, }: {
21
23
  options: ValidConfigOptions;
22
24
  commits: Commit[];
23
25
  targetBranches: string[];
24
- gitConfigAuthor?: GitConfigAuthor;
25
26
  }): Promise<Result[]>;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runSequentially = void 0;
4
- const HandledError_1 = require("./services/HandledError");
5
- const logger_1 = require("./services/logger");
6
- const sequentially_1 = require("./services/sequentially");
7
- const cherrypickAndCreateTargetPullRequest_1 = require("./ui/cherrypickAndCreateTargetPullRequest");
8
- async function runSequentially({ options, commits, targetBranches, gitConfigAuthor, }) {
4
+ const BackportError_1 = require("./lib/BackportError");
5
+ const cherrypickAndCreateTargetPullRequest_1 = require("./lib/cherrypickAndCreateTargetPullRequest");
6
+ const logger_1 = require("./lib/logger");
7
+ const sequentially_1 = require("./lib/sequentially");
8
+ async function runSequentially({ options, commits, targetBranches, }) {
9
9
  logger_1.logger.verbose('Backport options', options);
10
10
  const results = [];
11
11
  await (0, sequentially_1.sequentially)(targetBranches, async (targetBranch) => {
@@ -15,7 +15,6 @@ async function runSequentially({ options, commits, targetBranches, gitConfigAuth
15
15
  options,
16
16
  commits,
17
17
  targetBranch,
18
- gitConfigAuthor: gitConfigAuthor,
19
18
  });
20
19
  results.push({
21
20
  targetBranch,
@@ -26,7 +25,7 @@ async function runSequentially({ options, commits, targetBranches, gitConfigAuth
26
25
  });
27
26
  }
28
27
  catch (e) {
29
- const isHandledError = e instanceof HandledError_1.HandledError;
28
+ const isHandledError = e instanceof BackportError_1.BackportError;
30
29
  if (isHandledError) {
31
30
  results.push({
32
31
  targetBranch,
@@ -46,7 +45,7 @@ async function runSequentially({ options, commits, targetBranches, gitConfigAuth
46
45
  }
47
46
  (0, logger_1.consoleLog)(isHandledError
48
47
  ? e.message
49
- : 'An error occurred while backporting commit. Please see the logs for details');
48
+ : 'An unhandled error occurred while backporting commit. Please see the logs for details');
50
49
  logger_1.logger.error('runSequentially failed', e);
51
50
  }
52
51
  });
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.postinstall = void 0;
4
+ const env_1 = require("../lib/env");
5
+ const logger_1 = require("../lib/logger");
4
6
  const globalConfig_1 = require("../options/config/globalConfig");
5
- const env_1 = require("../services/env");
6
- const logger_1 = require("../services/logger");
7
7
  async function postinstall() {
8
8
  try {
9
- const globalConfigPath = (0, env_1.getGlobalConfigPath)();
9
+ const globalConfigPath = (0, env_1.getGlobalConfigPath)(undefined);
10
10
  const didCreate = await (0, globalConfig_1.createGlobalConfigAndFolderIfNotExist)(globalConfigPath);
11
11
  if (didCreate) {
12
12
  (0, logger_1.consoleLog)(`Global config successfully created in ${globalConfigPath}`);
@@ -27,8 +27,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const os_1 = __importDefault(require("os"));
30
+ const logger = __importStar(require("../lib/logger"));
30
31
  const globalConfig = __importStar(require("../options/config/globalConfig"));
31
- const logger = __importStar(require("../services/logger"));
32
32
  const postinstall_1 = require("./postinstall");
33
33
  describe('postinstall', () => {
34
34
  beforeEach(() => {
@@ -0,0 +1,19 @@
1
+ import { Commit } from './sourceCommit/parseSourceCommit';
2
+ declare type ErrorContext = {
3
+ code: 'merge-conflict-exception';
4
+ conflictingFiles: string[];
5
+ commitsWithoutBackports: {
6
+ formatted: string;
7
+ commit: Commit;
8
+ }[];
9
+ } | {
10
+ code: 'message-only-exception';
11
+ message: string;
12
+ } | {
13
+ code: 'no-branches-exception' | 'abort-exception';
14
+ };
15
+ export declare class BackportError extends Error {
16
+ errorContext: ErrorContext;
17
+ constructor(errorContextOrString: ErrorContext | string);
18
+ }
19
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BackportError = void 0;
4
+ function getMessage(errorContext) {
5
+ switch (errorContext.code) {
6
+ case 'merge-conflict-exception':
7
+ return `Commit could not be cherrypicked due to conflicts in: ${errorContext.conflictingFiles.join(',')}`;
8
+ case 'no-branches-exception':
9
+ return 'There are no branches to backport to. Aborting.';
10
+ case 'abort-exception':
11
+ return 'Aborted';
12
+ case 'message-only-exception':
13
+ return errorContext.message;
14
+ }
15
+ }
16
+ class BackportError extends Error {
17
+ constructor(errorContextOrString) {
18
+ const errorContext = typeof errorContextOrString === 'string'
19
+ ? { code: 'message-only-exception', message: errorContextOrString }
20
+ : errorContextOrString;
21
+ const message = getMessage(errorContext);
22
+ super(message);
23
+ Error.captureStackTrace(this, BackportError);
24
+ this.name = 'BackportError';
25
+ this.message = message;
26
+ this.errorContext = errorContext;
27
+ }
28
+ }
29
+ exports.BackportError = BackportError;
@@ -0,0 +1,19 @@
1
+ import { Commit } from './sourceCommit/parseSourceCommit';
2
+ declare type ErrorContext = {
3
+ code: 'merge-conflict-exception';
4
+ conflictingFiles: string[];
5
+ commitsWithoutBackports: {
6
+ formatted: string;
7
+ commit: Commit;
8
+ }[];
9
+ } | {
10
+ code: 'message-only-exception';
11
+ message: string;
12
+ } | {
13
+ code: 'no-branches-exception' | 'abort-exception';
14
+ };
15
+ export declare class BackportError extends Error {
16
+ errorContext: ErrorContext;
17
+ constructor(errorContextOrString: ErrorContext | string);
18
+ }
19
+ export {};
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BackportError = void 0;
4
+ function getMessage(errorContext) {
5
+ switch (errorContext.code) {
6
+ case 'merge-conflict-exception':
7
+ return `Commit could not be cherrypicked due to conflicts in: ${errorContext.conflictingFiles.join(',')}`;
8
+ case 'no-branches-exception':
9
+ return 'There are no branches to backport to. Aborting.';
10
+ case 'abort-exception':
11
+ return 'Aborted';
12
+ case 'message-only-exception':
13
+ return errorContext.message;
14
+ }
15
+ }
16
+ class BackportError extends Error {
17
+ constructor(errorContextOrString) {
18
+ const errorContext = typeof errorContextOrString === 'string'
19
+ ? { code: 'message-only-exception', message: errorContextOrString }
20
+ : errorContextOrString;
21
+ const message = getMessage(errorContext);
22
+ super(message);
23
+ Error.captureStackTrace(this, BackportError);
24
+ this.name = 'BackportError';
25
+ this.message = message;
26
+ this.errorContext = errorContext;
27
+ }
28
+ }
29
+ exports.BackportError = BackportError;
@@ -12,7 +12,7 @@ declare type ErrorContext = {
12
12
  } | {
13
13
  code: 'no-branches-exception' | 'abort-exception';
14
14
  };
15
- export declare class HandledError extends Error {
15
+ export declare class BackportError extends Error {
16
16
  errorContext: ErrorContext;
17
17
  constructor(errorContextOrString: ErrorContext | string);
18
18
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HandledError = void 0;
3
+ exports.BackportError = void 0;
4
4
  function getMessage(errorContext) {
5
5
  switch (errorContext.code) {
6
6
  case 'merge-conflict-exception':
@@ -13,17 +13,17 @@ function getMessage(errorContext) {
13
13
  return errorContext.message;
14
14
  }
15
15
  }
16
- class HandledError extends Error {
16
+ class BackportError extends Error {
17
17
  constructor(errorContextOrString) {
18
18
  const errorContext = typeof errorContextOrString === 'string'
19
19
  ? { code: 'message-only-exception', message: errorContextOrString }
20
20
  : errorContextOrString;
21
21
  const message = getMessage(errorContext);
22
22
  super(message);
23
- Error.captureStackTrace(this, HandledError);
24
- this.name = 'HandledError';
23
+ Error.captureStackTrace(this, BackportError);
24
+ this.name = 'BackportError';
25
25
  this.message = message;
26
26
  this.errorContext = errorContext;
27
27
  }
28
28
  }
29
- exports.HandledError = HandledError;
29
+ exports.BackportError = BackportError;
@@ -5,7 +5,7 @@ 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");
@@ -240,17 +240,17 @@ async function cherrypick({ options, sha, mergedTargetPullRequest, commitAuthor,
240
240
  if (isSpawnError) {
241
241
  // missing `mainline` option
242
242
  if (e.message.includes('is a merge but no -m option was given')) {
243
- 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');
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
244
  }
245
245
  // commit was already backported
246
246
  if (e.message.includes('The previous cherry-pick is now empty')) {
247
247
  const shortSha = (0, commitFormatters_1.getShortSha)(sha);
248
- throw new HandledError_1.HandledError(`Cherrypick failed because the selected commit (${shortSha}) is empty. ${mergedTargetPullRequest?.url
248
+ throw new BackportError_1.BackportError(`Cherrypick failed because the selected commit (${shortSha}) is empty. ${mergedTargetPullRequest?.url
249
249
  ? `It looks like the commit was already backported in ${mergedTargetPullRequest.url}`
250
250
  : 'Did you already backport this commit? '}`);
251
251
  }
252
252
  if (e.message.includes(`bad object ${sha}`)) {
253
- throw new HandledError_1.HandledError(`Cherrypick failed because commit "${sha}" was not found`);
253
+ throw new BackportError_1.BackportError(`Cherrypick failed because commit "${sha}" was not found`);
254
254
  }
255
255
  const isCherryPickError = e.context.cmdArgs.includes('cherry-pick') && e.context.code > 0;
256
256
  if (isCherryPickError) {
@@ -383,7 +383,7 @@ async function createBackportBranch({ options, targetBranch, backportBranch, })
383
383
  .toLowerCase()
384
384
  .includes(`is not a commit and a branch '${backportBranch}' cannot be created from it`);
385
385
  if (isBranchInvalid) {
386
- throw new HandledError_1.HandledError(`The branch "${targetBranch}" is invalid or doesn't exist`);
386
+ throw new BackportError_1.BackportError(`The branch "${targetBranch}" is invalid or doesn't exist`);
387
387
  }
388
388
  }
389
389
  throw e;
@@ -419,11 +419,11 @@ async function pushBackportBranch({ options, backportBranch, }) {
419
419
  spinner.fail();
420
420
  if (e instanceof child_process_promisified_1.SpawnError &&
421
421
  e.context.stderr.toLowerCase().includes(`repository not found`)) {
422
- throw new HandledError_1.HandledError(`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`);
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
423
  }
424
424
  if (e instanceof child_process_promisified_1.SpawnError &&
425
425
  e.context.stderr.includes(`could not read Username for`)) {
426
- throw new HandledError_1.HandledError(`Invalid credentials: ${e.message}`);
426
+ throw new BackportError_1.BackportError(`Invalid credentials: ${e.message}`);
427
427
  }
428
428
  throw e;
429
429
  }