backport 8.0.0 → 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 (205) hide show
  1. package/README.md +4 -4
  2. package/dist/backportRun.d.ts +5 -4
  3. package/dist/backportRun.js +41 -42
  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 +4 -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 +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 +4 -2
  151. package/dist/options/cliArgs.d.ts +15 -12
  152. package/dist/options/cliArgs.js +34 -19
  153. package/dist/options/cliArgs.test.js +125 -1
  154. package/dist/options/config/config.d.ts +5 -4
  155. package/dist/options/config/config.js +3 -5
  156. package/dist/options/config/config.test.js +0 -1
  157. package/dist/options/config/globalConfig.d.ts +3 -1
  158. package/dist/options/config/globalConfig.js +5 -5
  159. package/dist/options/config/readConfigFile.d.ts +9 -7
  160. package/dist/options/config/readConfigFile.js +2 -2
  161. package/dist/options/options.d.ts +43 -7
  162. package/dist/options/options.js +20 -24
  163. package/dist/options/options.test.js +112 -54
  164. package/dist/runSequentially.d.ts +10 -7
  165. package/dist/runSequentially.js +5 -5
  166. package/dist/scripts/postinstall.js +3 -3
  167. package/dist/scripts/postinstall.test.js +1 -1
  168. package/dist/services/BackportError.d.ts +19 -0
  169. package/dist/services/BackportError.js +29 -0
  170. package/dist/services/HandledBackportError.d.ts +19 -0
  171. package/dist/services/HandledBackportError.js +29 -0
  172. package/dist/services/HandledError.d.ts +1 -1
  173. package/dist/services/HandledError.js +5 -5
  174. package/dist/services/git.js +7 -7
  175. package/dist/services/github/v3/createPullRequest.js +2 -2
  176. package/dist/services/github/v3/createStatusComment.js +2 -2
  177. package/dist/services/github/v3/createStatusComment.test.js +5 -4
  178. package/dist/services/github/v4/apiRequestV4.js +2 -2
  179. package/dist/services/github/v4/apiRequestV4.test.js +2 -2
  180. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +3 -3
  181. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +2 -2
  182. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +3 -3
  183. package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +2 -2
  184. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +2 -2
  185. package/dist/services/github/v4/throwOnInvalidAccessToken.js +5 -5
  186. package/dist/state.d.ts +0 -0
  187. package/dist/state.js +1 -0
  188. package/dist/test/e2e/cli/commit-author.private.test.js +4 -4
  189. package/dist/test/e2e/cli/different-merge-strategies.private.test.js +26 -24
  190. package/dist/test/e2e/cli/entrypoint.cli.private.test.js +189 -140
  191. package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +12 -14
  192. package/dist/test/e2e/cli/runBackportViaCli.d.ts +5 -2
  193. package/dist/test/e2e/cli/runBackportViaCli.js +42 -29
  194. package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +22 -14
  195. package/dist/test/e2e/module/entrypoint.module.mutation.test.js +2 -2
  196. package/dist/test/handleUnbackportedPullRequests.private.test.js +3 -2
  197. package/dist/test/setupFiles/automatic-mocks.js +1 -1
  198. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +3 -3
  199. package/dist/ui/getCommits.js +2 -2
  200. package/dist/ui/getTargetBranches.js +3 -3
  201. package/dist/ui/setupRepo.js +2 -2
  202. package/dist/utils/packageVersion.d.ts +1 -1
  203. package/dist/utils/packageVersion.js +1 -1
  204. package/package.json +12 -12
  205. package/yarn.lock +112 -65
package/README.md CHANGED
@@ -91,13 +91,13 @@ See [configuration.md](https://github.com/sqren/backport/blob/main/docs/configur
91
91
  | --author | | Filter commits by Github username. Opposite of `--all` | _Current user_ |
92
92
  | --auto-assign | | Assign current user to the target PR | false |
93
93
  | --branch | -b | Target branch to backport to | |
94
- | --ci | | Disable interactive prompts | false |
95
94
  | --config-file | | Custom path to project config file (.backportrc.json) | |
96
95
  | --dir | | Clone repository into custom directory | ~/.backport/repositories/ |
97
96
  | --dry-run | | Perform backport without pushing to Github | false |
98
97
  | --editor | | Editor (eg. `code`) to open and resolve conflicts | nano |
99
98
  | --fork | | Create backports in fork repo | true |
100
99
  | --git-hostname | | Hostname for Git | github.com |
100
+ | --interactive | | Enable interactive prompts | true |
101
101
  | --mainline | | Parent id of merge commit | 1 |
102
102
  | --max-number | --number, -n | Number of commits to choose from | 10 |
103
103
  | --multiple | | Multi-select for commits and branches | false |
@@ -153,8 +153,8 @@ Filter commits by pull request number
153
153
  `sha` _string_<br/>
154
154
  Filter commits by commit sha
155
155
 
156
- `ci` _boolean_<br/>
157
- Enabling this will disable the interactive prompts
156
+ `interactive` _boolean_<br/>
157
+ Enable interactive prompts
158
158
 
159
159
  #### Example
160
160
 
@@ -167,7 +167,7 @@ const result = await backportRun({
167
167
  repoName: 'kibana',
168
168
  repoOwner: 'elastic',
169
169
  pullNumber: 121633,
170
- ci: true,
170
+ interactive: false,
171
171
  },
172
172
  });
173
173
 
@@ -1,11 +1,12 @@
1
+ import { BackportError } from './lib/BackportError';
2
+ import { Commit } from './lib/sourceCommit/parseSourceCommit';
1
3
  import { ConfigFileOptions } from './options/ConfigOptions';
2
4
  import { Result } from './runSequentially';
3
- import { HandledError } from './services/HandledError';
4
- import { Commit } from './services/sourceCommit/parseSourceCommit';
5
5
  export declare type BackportAbortResponse = {
6
6
  status: 'aborted';
7
7
  commits: Commit[];
8
- error: HandledError;
8
+ error: BackportError;
9
+ errorMessage: string;
9
10
  };
10
11
  export declare type BackportSuccessResponse = {
11
12
  status: 'success';
@@ -15,7 +16,7 @@ export declare type BackportSuccessResponse = {
15
16
  export declare type BackportFailureResponse = {
16
17
  status: 'failure';
17
18
  commits: Commit[];
18
- error: Error | HandledError;
19
+ error: Error | BackportError;
19
20
  errorMessage: string;
20
21
  };
21
22
  export declare type BackportResponse = BackportSuccessResponse | BackportFailureResponse | BackportAbortResponse;
@@ -5,52 +5,49 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.backportRun = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
- const yargs_parser_1 = __importDefault(require("yargs-parser"));
8
+ const BackportError_1 = require("./lib/BackportError");
9
+ const env_1 = require("./lib/env");
10
+ const getCommits_1 = require("./lib/getCommits");
11
+ const getGitConfigAuthor_1 = require("./lib/getGitConfigAuthor");
12
+ const getTargetBranches_1 = require("./lib/getTargetBranches");
13
+ const createStatusComment_1 = require("./lib/github/v3/createStatusComment");
14
+ const apiRequestV4_1 = require("./lib/github/v4/apiRequestV4");
15
+ const logger_1 = require("./lib/logger");
16
+ const ora_1 = require("./lib/ora");
17
+ const setupRepo_1 = require("./lib/setupRepo");
9
18
  const cliArgs_1 = require("./options/cliArgs");
10
19
  const options_1 = require("./options/options");
11
20
  const runSequentially_1 = require("./runSequentially");
12
- const HandledError_1 = require("./services/HandledError");
13
- const env_1 = require("./services/env");
14
- const createStatusComment_1 = require("./services/github/v3/createStatusComment");
15
- const apiRequestV4_1 = require("./services/github/v4/apiRequestV4");
16
- const logger_1 = require("./services/logger");
17
- const getCommits_1 = require("./ui/getCommits");
18
- const getGitConfigAuthor_1 = require("./ui/getGitConfigAuthor");
19
- const getTargetBranches_1 = require("./ui/getTargetBranches");
20
- const ora_1 = require("./ui/ora");
21
- const setupRepo_1 = require("./ui/setupRepo");
22
21
  async function backportRun({ processArgs, optionsFromModule = {}, exitCodeOnFailure, }) {
23
- const argv = (0, yargs_parser_1.default)(processArgs);
24
- const ci = argv.ci ?? optionsFromModule.ci;
25
- const logFilePath = argv.logFilePath ?? optionsFromModule.logFilePath;
26
- const logger = (0, logger_1.initLogger)({ ci, logFilePath });
22
+ const { interactive, logFilePath } = (0, cliArgs_1.getEarlyArguments)(processArgs, optionsFromModule);
23
+ const logger = (0, logger_1.initLogger)({ interactive, logFilePath });
24
+ let optionsFromCliArgs;
25
+ try {
26
+ optionsFromCliArgs = (0, cliArgs_1.getOptionsFromCliArgs)(processArgs);
27
+ }
28
+ catch (e) {
29
+ if (e instanceof Error) {
30
+ (0, logger_1.consoleLog)(e.message);
31
+ (0, logger_1.consoleLog)(`Run "backport --help" to see all options`);
32
+ return {
33
+ status: 'failure',
34
+ error: e,
35
+ errorMessage: e.message,
36
+ commits: [],
37
+ };
38
+ }
39
+ throw e;
40
+ }
27
41
  let options = null;
28
42
  let commits = [];
43
+ const spinner = (0, ora_1.ora)(interactive).start('Initializing...');
29
44
  try {
30
- const spinner = (0, ora_1.ora)(ci);
31
- try {
32
- // don't show spinner for yargs commands that exit the process without stopping the spinner first
33
- if (!argv.help && !argv.version && !argv.v) {
34
- spinner.start('Initializing...');
35
- }
36
- options = await (0, options_1.getOptions)(processArgs, optionsFromModule);
37
- logger.info('Backporting options', options);
38
- spinner.stop();
39
- }
40
- catch (e) {
41
- spinner.stop();
42
- if (e instanceof cliArgs_1.CliError) {
43
- (0, logger_1.consoleLog)(e.message);
44
- (0, logger_1.consoleLog)(`Run "backport --help" to see all options`);
45
- return {
46
- status: 'failure',
47
- error: e,
48
- errorMessage: e.message,
49
- commits: [],
50
- };
51
- }
52
- throw e;
53
- }
45
+ options = await (0, options_1.getOptions)({
46
+ optionsFromCliArgs,
47
+ optionsFromModule,
48
+ });
49
+ logger.info('Backporting options', options);
50
+ spinner.stop();
54
51
  commits = await (0, getCommits_1.getCommits)(options);
55
52
  logger.info('Commits', commits);
56
53
  if (options.ls) {
@@ -78,15 +75,17 @@ async function backportRun({ processArgs, optionsFromModule = {}, exitCodeOnFail
78
75
  return backportResponse;
79
76
  }
80
77
  catch (e) {
78
+ spinner.stop();
81
79
  let backportResponse;
82
- if (e instanceof HandledError_1.HandledError &&
80
+ if (e instanceof BackportError_1.BackportError &&
83
81
  e.errorContext.code === 'no-branches-exception') {
84
82
  backportResponse = {
85
83
  status: 'aborted',
86
84
  commits,
87
85
  error: e,
86
+ errorMessage: e.message,
88
87
  };
89
- // this will catch both HandledError and Error
88
+ // this will catch both BackportError and Error
90
89
  }
91
90
  else if (e instanceof Error) {
92
91
  backportResponse = {
@@ -113,7 +112,7 @@ async function backportRun({ processArgs, optionsFromModule = {}, exitCodeOnFail
113
112
  }
114
113
  exports.backportRun = backportRun;
115
114
  function outputError({ e, logFilePath, }) {
116
- if (e instanceof HandledError_1.HandledError || e instanceof apiRequestV4_1.GithubV4Exception) {
115
+ if (e instanceof BackportError_1.BackportError || e instanceof apiRequestV4_1.GithubV4Exception) {
117
116
  (0, logger_1.consoleLog)(e.message);
118
117
  return;
119
118
  }
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const yargs_parser_1 = __importDefault(require("yargs-parser"));
7
3
  const backportRun_1 = require("./backportRun");
4
+ const cliArgs_1 = require("./options/cliArgs");
8
5
  const processArgs = process.argv.slice(2);
9
6
  // this is the entrypoint when running from command line
10
7
  (0, backportRun_1.backportRun)({ processArgs, exitCodeOnFailure: true }).then((backportResponse) => {
11
- const argv = (0, yargs_parser_1.default)(processArgs);
12
- const { ci, ls } = argv;
13
- if (ci || ls) {
8
+ const { interactive, ls } = (0, cliArgs_1.getEarlyArguments)(processArgs);
9
+ if (!interactive || ls) {
14
10
  // eslint-disable-next-line no-console
15
11
  console.log(JSON.stringify(backportResponse));
16
12
  }
@@ -1,11 +1,13 @@
1
1
  import { BackportResponse } from './backportRun';
2
+ import type { Commit } from './lib/sourceCommit/parseSourceCommit';
2
3
  import { ConfigFileOptions } from './options/ConfigOptions';
3
4
  import { ValidConfigOptions } from './options/options';
4
- import { Commit } from './services/sourceCommit/parseSourceCommit';
5
- export { BackportResponse };
6
- export { Commit };
7
- export { ConfigFileOptions } from './options/ConfigOptions';
8
- export { fetchRemoteProjectConfig as getRemoteProjectConfig } from './services/github/v4/fetchRemoteProjectConfig';
5
+ export type { HandledErrorResult, SuccessResult, UnhandledErrorResult, } from './runSequentially';
6
+ export type { BackportAbortResponse, BackportFailureResponse, BackportResponse, BackportSuccessResponse, } from './backportRun';
7
+ export { BackportError } from './lib/BackportError';
8
+ export type { Commit } from './lib/sourceCommit/parseSourceCommit';
9
+ export type { ConfigFileOptions } from './options/ConfigOptions';
10
+ export { fetchRemoteProjectConfig as getRemoteProjectConfig } from './lib/github/v4/fetchRemoteProjectConfig';
9
11
  export { getGlobalConfig as getLocalGlobalConfig } from './options/config/globalConfig';
10
12
  export declare function backportRun({ options, processArgs, exitCodeOnFailure, }: {
11
13
  options: ConfigFileOptions;
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCommits = exports.backportRun = exports.getLocalGlobalConfig = exports.getRemoteProjectConfig = void 0;
3
+ exports.getCommits = exports.backportRun = exports.getLocalGlobalConfig = exports.getRemoteProjectConfig = exports.BackportError = void 0;
4
4
  const backportRun_1 = require("./backportRun");
5
- const fetchCommitByPullNumber_1 = require("./services/github/v4/fetchCommits/fetchCommitByPullNumber");
6
- const fetchCommitBySha_1 = require("./services/github/v4/fetchCommits/fetchCommitBySha");
7
- const fetchCommitsByAuthor_1 = require("./services/github/v4/fetchCommits/fetchCommitsByAuthor");
8
- const fetchPullRequestsBySearchQuery_1 = require("./services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery");
9
- const getOptionsFromGithub_1 = require("./services/github/v4/getOptionsFromGithub/getOptionsFromGithub");
10
- const logger_1 = require("./services/logger");
5
+ const fetchCommitByPullNumber_1 = require("./lib/github/v4/fetchCommits/fetchCommitByPullNumber");
6
+ const fetchCommitBySha_1 = require("./lib/github/v4/fetchCommits/fetchCommitBySha");
7
+ const fetchCommitsByAuthor_1 = require("./lib/github/v4/fetchCommits/fetchCommitsByAuthor");
8
+ const fetchPullRequestsBySearchQuery_1 = require("./lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery");
9
+ const getOptionsFromGithub_1 = require("./lib/github/v4/getOptionsFromGithub/getOptionsFromGithub");
10
+ const logger_1 = require("./lib/logger");
11
11
  const excludeUndefined_1 = require("./utils/excludeUndefined");
12
- var fetchRemoteProjectConfig_1 = require("./services/github/v4/fetchRemoteProjectConfig");
12
+ var BackportError_1 = require("./lib/BackportError");
13
+ Object.defineProperty(exports, "BackportError", { enumerable: true, get: function () { return BackportError_1.BackportError; } });
14
+ var fetchRemoteProjectConfig_1 = require("./lib/github/v4/fetchRemoteProjectConfig");
13
15
  Object.defineProperty(exports, "getRemoteProjectConfig", { enumerable: true, get: function () { return fetchRemoteProjectConfig_1.fetchRemoteProjectConfig; } });
14
16
  var globalConfig_1 = require("./options/config/globalConfig");
15
17
  Object.defineProperty(exports, "getLocalGlobalConfig", { enumerable: true, get: function () { return globalConfig_1.getGlobalConfig; } });
@@ -22,7 +24,7 @@ function backportRun({ options, processArgs = [], exitCodeOnFailure = true, }) {
22
24
  }
23
25
  exports.backportRun = backportRun;
24
26
  async function getCommits(options) {
25
- (0, logger_1.initLogger)({ ci: true, accessToken: options.accessToken });
27
+ (0, logger_1.initLogger)({ interactive: false, accessToken: options.accessToken });
26
28
  const optionsFromGithub = await (0, getOptionsFromGithub_1.getOptionsFromGithub)(options);
27
29
  if (options.pullNumber) {
28
30
  return [
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const entrypoint_module_1 = require("./entrypoint.module");
4
- const commitFormatters_1 = require("./services/github/commitFormatters");
4
+ const commitFormatters_1 = require("./lib/github/commitFormatters");
5
5
  const getDevAccessToken_1 = require("./test/private/getDevAccessToken");
6
6
  const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
7
7
  jest.unmock('del');
@@ -16,7 +16,7 @@ describe('entrypoint.module', () => {
16
16
  options: {
17
17
  repoOwner: 'backport-org',
18
18
  repoName: 'repo-with-conflicts',
19
- ci: true,
19
+ interactive: false,
20
20
  accessToken,
21
21
  pullNumber: 12,
22
22
  targetBranches: ['7.x'],
@@ -47,7 +47,7 @@ describe('entrypoint.module', () => {
47
47
  options: {
48
48
  repoOwner: 'backport-org',
49
49
  repoName: 'repo-with-conflicts',
50
- ci: true,
50
+ interactive: false,
51
51
  accessToken,
52
52
  pullNumber: 12,
53
53
  },
@@ -67,7 +67,7 @@ describe('entrypoint.module', () => {
67
67
  options: {
68
68
  repoOwner: 'backport-org',
69
69
  repoName: 'repo-with-conflicts',
70
- ci: true,
70
+ interactive: false,
71
71
  accessToken,
72
72
  pullNumber: 8,
73
73
  dryRun: true,
@@ -0,0 +1,19 @@
1
+ import { Commit } from '../lib/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-conflict-resolution-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-conflict-resolution-exception':
11
+ return 'Conflict resolution was aborted by the user';
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,13 @@
1
+ import { ValidConfigOptions } from '../options/options';
2
+ import { GitConfigAuthor } from './getGitConfigAuthor';
3
+ import { Commit } from './sourceCommit/parseSourceCommit';
4
+ export declare function cherrypickAndCreateTargetPullRequest({ options, commits, targetBranch, gitConfigAuthor, }: {
5
+ options: ValidConfigOptions;
6
+ commits: Commit[];
7
+ targetBranch: string;
8
+ gitConfigAuthor?: GitConfigAuthor;
9
+ }): Promise<{
10
+ url: string;
11
+ number: number;
12
+ didUpdate: boolean;
13
+ }>;
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.cherrypickAndCreateTargetPullRequest = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const lodash_1 = require("lodash");
9
+ const BackportError_1 = require("./BackportError");
10
+ const child_process_promisified_1 = require("./child-process-promisified");
11
+ const env_1 = require("./env");
12
+ const getCommitsWithoutBackports_1 = require("./getCommitsWithoutBackports");
13
+ const git_1 = require("./git");
14
+ const commitFormatters_1 = require("./github/commitFormatters");
15
+ const addAssigneesToPullRequest_1 = require("./github/v3/addAssigneesToPullRequest");
16
+ const addLabelsToPullRequest_1 = require("./github/v3/addLabelsToPullRequest");
17
+ const addReviewersToPullRequest_1 = require("./github/v3/addReviewersToPullRequest");
18
+ const createPullRequest_1 = require("./github/v3/createPullRequest");
19
+ const enablePullRequestAutoMerge_1 = require("./github/v4/enablePullRequestAutoMerge");
20
+ const logger_1 = require("./logger");
21
+ const ora_1 = require("./ora");
22
+ const prompts_1 = require("./prompts");
23
+ const sequentially_1 = require("./sequentially");
24
+ async function cherrypickAndCreateTargetPullRequest({ options, commits, targetBranch, gitConfigAuthor, }) {
25
+ const backportBranch = getBackportBranchName(targetBranch, commits);
26
+ const repoForkOwner = (0, git_1.getRepoForkOwner)(options);
27
+ (0, logger_1.consoleLog)(`\n${chalk_1.default.bold(`Backporting to ${targetBranch}:`)}`);
28
+ await (0, git_1.createBackportBranch)({ options, targetBranch, backportBranch });
29
+ await (0, sequentially_1.sequentially)(commits, (commit) => waitForCherrypick(options, commit, targetBranch, gitConfigAuthor));
30
+ if (options.dryRun) {
31
+ (0, ora_1.ora)(options.interactive).succeed('Dry run complete');
32
+ return { url: 'https://localhost/dry-run', didUpdate: false, number: 1337 };
33
+ }
34
+ await (0, git_1.pushBackportBranch)({ options, backportBranch });
35
+ await (0, git_1.deleteBackportBranch)({ options, backportBranch });
36
+ const prPayload = {
37
+ owner: options.repoOwner,
38
+ repo: options.repoName,
39
+ title: (0, createPullRequest_1.getTitle)({ options, commits, targetBranch }),
40
+ body: (0, createPullRequest_1.getPullRequestBody)({ options, commits, targetBranch }),
41
+ head: `${repoForkOwner}:${backportBranch}`,
42
+ base: targetBranch, // eg. 7.x
43
+ };
44
+ const targetPullRequest = await (0, createPullRequest_1.createPullRequest)({ options, prPayload });
45
+ // add assignees to target pull request
46
+ const assignees = options.autoAssign
47
+ ? [options.authenticatedUsername]
48
+ : options.assignees;
49
+ if (options.assignees.length > 0) {
50
+ await (0, addAssigneesToPullRequest_1.addAssigneesToPullRequest)(options, targetPullRequest.number, assignees);
51
+ }
52
+ // add reviewers to target pull request
53
+ if (options.reviewers.length > 0) {
54
+ await (0, addReviewersToPullRequest_1.addReviewersToPullRequest)(options, targetPullRequest.number, options.reviewers);
55
+ }
56
+ // add labels to target pull request
57
+ if (options.targetPRLabels.length > 0) {
58
+ await (0, addLabelsToPullRequest_1.addLabelsToPullRequest)(options, targetPullRequest.number, options.targetPRLabels);
59
+ }
60
+ // make PR auto mergable
61
+ if (options.autoMerge) {
62
+ await (0, enablePullRequestAutoMerge_1.enablePullRequestAutoMerge)(options, targetPullRequest.number);
63
+ }
64
+ // add labels to source pull requests
65
+ if (options.sourcePRLabels.length > 0) {
66
+ const promises = commits.map((commit) => {
67
+ if (commit.sourcePullRequest) {
68
+ return (0, addLabelsToPullRequest_1.addLabelsToPullRequest)(options, commit.sourcePullRequest.number, options.sourcePRLabels);
69
+ }
70
+ });
71
+ await Promise.all(promises);
72
+ }
73
+ (0, logger_1.consoleLog)(`View pull request: ${targetPullRequest.url}`);
74
+ return targetPullRequest;
75
+ }
76
+ exports.cherrypickAndCreateTargetPullRequest = cherrypickAndCreateTargetPullRequest;
77
+ /*
78
+ * Returns the name of the backport branch without remote name
79
+ *
80
+ * Examples:
81
+ * For a single PR: `backport/7.x/pr-1234`
82
+ * For a single commit: `backport/7.x/commit-abcdef`
83
+ * For multiple: `backport/7.x/pr-1234_commit-abcdef`
84
+ */
85
+ function getBackportBranchName(targetBranch, commits) {
86
+ const refValues = commits
87
+ .map((commit) => commit.sourcePullRequest
88
+ ? `pr-${commit.sourcePullRequest.number}`
89
+ : `commit-${(0, commitFormatters_1.getShortSha)(commit.sourceCommit.sha)}`)
90
+ .join('_')
91
+ .slice(0, 200);
92
+ return `backport/${targetBranch}/${refValues}`;
93
+ }
94
+ async function waitForCherrypick(options, commit, targetBranch, gitConfigAuthor) {
95
+ const spinnerText = `Cherry-picking: ${chalk_1.default.greenBright((0, commitFormatters_1.getFirstLine)(commit.sourceCommit.message))}`;
96
+ const mergedTargetPullRequest = commit.expectedTargetPullRequests.find((pr) => pr.state === 'MERGED' && pr.branch === targetBranch);
97
+ const cherrypickSpinner = (0, ora_1.ora)(options.interactive, spinnerText).start();
98
+ let conflictingFiles;
99
+ let unstagedFiles;
100
+ let needsResolving;
101
+ const commitAuthor = getCommitAuthor({
102
+ options,
103
+ gitConfigAuthor,
104
+ commit,
105
+ });
106
+ try {
107
+ await (0, git_1.fetchBranch)(options, commit.sourceBranch);
108
+ ({ conflictingFiles, unstagedFiles, needsResolving } = await (0, git_1.cherrypick)({
109
+ options,
110
+ sha: commit.sourceCommit.sha,
111
+ mergedTargetPullRequest,
112
+ commitAuthor,
113
+ }));
114
+ // no conflicts encountered
115
+ if (!needsResolving) {
116
+ cherrypickSpinner.succeed();
117
+ return;
118
+ }
119
+ // cherrypick failed due to conflicts
120
+ cherrypickSpinner.fail();
121
+ }
122
+ catch (e) {
123
+ cherrypickSpinner.fail();
124
+ throw e;
125
+ }
126
+ const repoPath = (0, env_1.getRepoPath)(options);
127
+ // resolve conflicts automatically
128
+ if (options.autoFixConflicts) {
129
+ const autoResolveSpinner = (0, ora_1.ora)(options.interactive, 'Attempting to resolve conflicts automatically').start();
130
+ const didAutoFix = await options.autoFixConflicts({
131
+ files: conflictingFiles.map((f) => f.absolute),
132
+ directory: repoPath,
133
+ logger: logger_1.logger,
134
+ targetBranch,
135
+ });
136
+ // conflicts were automatically resolved
137
+ if (didAutoFix) {
138
+ autoResolveSpinner.succeed();
139
+ return;
140
+ }
141
+ autoResolveSpinner.fail();
142
+ }
143
+ const conflictingFilesRelative = conflictingFiles
144
+ .map((f) => f.relative)
145
+ .slice(0, 50);
146
+ const commitsWithoutBackports = await (0, getCommitsWithoutBackports_1.getCommitsWithoutBackports)({
147
+ options,
148
+ commit,
149
+ targetBranch,
150
+ conflictingFiles: conflictingFilesRelative,
151
+ });
152
+ if (!options.interactive) {
153
+ throw new BackportError_1.BackportError({
154
+ code: 'merge-conflict-exception',
155
+ commitsWithoutBackports,
156
+ conflictingFiles: conflictingFilesRelative,
157
+ });
158
+ }
159
+ (0, logger_1.consoleLog)(chalk_1.default.bold('\nThe commit could not be backported due to conflicts\n'));
160
+ (0, logger_1.consoleLog)(`Please fix the conflicts in ${repoPath}`);
161
+ if (commitsWithoutBackports.length > 0) {
162
+ (0, logger_1.consoleLog)(chalk_1.default.italic(`Hint: Before fixing the conflicts manually you should consider backporting the following pull requests to "${targetBranch}":`));
163
+ (0, logger_1.consoleLog)(`${commitsWithoutBackports.map((c) => c.formatted).join('\n')}\n\n`);
164
+ }
165
+ /*
166
+ * Commit could not be cleanly cherrypicked: Initiating conflict resolution
167
+ */
168
+ if (options.editor) {
169
+ await (0, child_process_promisified_1.spawnPromise)(options.editor, [repoPath], options.cwd);
170
+ }
171
+ // list files with conflict markers + unstaged files and require user to resolve them
172
+ await listConflictingAndUnstagedFiles({
173
+ retries: 0,
174
+ options,
175
+ conflictingFiles: conflictingFiles.map((f) => f.absolute),
176
+ unstagedFiles,
177
+ });
178
+ // Conflicts should be resolved and files staged at this point
179
+ const stagingSpinner = (0, ora_1.ora)(options.interactive, `Finalizing cherrypick`).start();
180
+ try {
181
+ // Run `git commit`
182
+ await (0, git_1.commitChanges)(commit, options);
183
+ stagingSpinner.succeed();
184
+ }
185
+ catch (e) {
186
+ stagingSpinner.fail();
187
+ throw e;
188
+ }
189
+ }
190
+ async function listConflictingAndUnstagedFiles({ retries, options, conflictingFiles, unstagedFiles, }) {
191
+ const hasUnstagedFiles = !(0, lodash_1.isEmpty)((0, lodash_1.difference)(unstagedFiles, conflictingFiles));
192
+ const hasConflictingFiles = !(0, lodash_1.isEmpty)(conflictingFiles);
193
+ if (!hasConflictingFiles && !hasUnstagedFiles) {
194
+ return;
195
+ }
196
+ // add divider between prompts
197
+ if (retries > 0) {
198
+ (0, logger_1.consoleLog)('\n----------------------------------------\n');
199
+ }
200
+ const header = chalk_1.default.reset(`Fix the following conflicts manually:`);
201
+ // show conflict section if there are conflicting files
202
+ const conflictSection = hasConflictingFiles
203
+ ? `Conflicting files:\n${chalk_1.default.reset(conflictingFiles.map((file) => ` - ${file}`).join('\n'))}`
204
+ : '';
205
+ const unstagedSection = hasUnstagedFiles
206
+ ? `Unstaged files:\n${chalk_1.default.reset(unstagedFiles.map((file) => ` - ${file}`).join('\n'))}`
207
+ : '';
208
+ const didConfirm = await (0, prompts_1.confirmPrompt)(`${header}\n\n${conflictSection}\n${unstagedSection}\n\nPress ENTER when the conflicts are resolved and files are staged`);
209
+ if (!didConfirm) {
210
+ throw new BackportError_1.BackportError({ code: 'abort-conflict-resolution-exception' });
211
+ }
212
+ const MAX_RETRIES = 100;
213
+ if (retries++ > MAX_RETRIES) {
214
+ throw new Error(`Maximum number of retries (${MAX_RETRIES}) exceeded`);
215
+ }
216
+ const [_conflictingFiles, _unstagedFiles] = await Promise.all([
217
+ (0, git_1.getConflictingFiles)(options),
218
+ (0, git_1.getUnstagedFiles)(options),
219
+ ]);
220
+ await listConflictingAndUnstagedFiles({
221
+ retries,
222
+ options,
223
+ conflictingFiles: _conflictingFiles.map((file) => file.absolute),
224
+ unstagedFiles: _unstagedFiles,
225
+ });
226
+ }
227
+ function getCommitAuthor({ options, gitConfigAuthor, commit, }) {
228
+ if (options.resetAuthor) {
229
+ return {
230
+ name: options.authenticatedUsername,
231
+ email: `<${options.authenticatedUsername}@users.noreply.github.com>`,
232
+ };
233
+ }
234
+ return {
235
+ name: options.gitAuthorName ?? gitConfigAuthor?.name ?? commit.author.name,
236
+ email: options.gitAuthorEmail ?? gitConfigAuthor?.email ?? commit.author.email,
237
+ };
238
+ }