backport 8.3.1 → 8.4.2

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 (225) hide show
  1. package/README.md +11 -178
  2. package/dist/lib/cherrypickAndCreateTargetPullRequest.js +42 -21
  3. package/dist/lib/child-process-promisified.js +2 -2
  4. package/dist/lib/git.d.ts +4 -3
  5. package/dist/lib/git.js +22 -29
  6. package/dist/lib/git.private.test.js +10 -7
  7. package/dist/lib/git.test.js +47 -15
  8. package/dist/lib/github/v4/apiRequestV4.js +14 -8
  9. package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +1 -0
  10. package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -0
  11. package/dist/lib/ora.d.ts +1 -0
  12. package/dist/options/ConfigOptions.d.ts +1 -0
  13. package/dist/options/cliArgs.d.ts +1 -0
  14. package/dist/options/cliArgs.js +5 -0
  15. package/dist/options/config/config.d.ts +1 -0
  16. package/dist/options/config/readConfigFile.d.ts +1 -0
  17. package/dist/options/options.d.ts +2 -0
  18. package/dist/options/options.js +3 -2
  19. package/dist/options/options.test.js +5 -4
  20. package/dist/test/e2e/cli/date-filters.private.test.js +1 -0
  21. package/dist/test/e2e/cli/different-merge-strategies.private.test.js +122 -6
  22. package/dist/test/e2e/cli/entrypoint.cli.private.test.js +2 -0
  23. package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.js +27 -13
  24. package/dist/test/e2e/cli/error-handling-non-interactive-mode.private.test.js +3 -2
  25. package/dist/{entrypoint.cli.private.test.d.ts → test/e2e/cli/gracefully-handles-corrupt-repo.private.test.d.ts} +0 -0
  26. package/dist/test/e2e/cli/gracefully-handles-corrupt-repo.private.test.js +52 -0
  27. package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +2 -2
  28. package/dist/{lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts → test/e2e/cli/repo-with-programatically-added-commits.mutation.test.d.ts} +0 -0
  29. package/dist/test/e2e/cli/repo-with-programatically-added-commits.mutation.test.js +114 -0
  30. package/dist/test/e2e/cli/runBackportViaCli.d.ts +8 -2
  31. package/dist/test/e2e/cli/runBackportViaCli.js +47 -17
  32. package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +7 -1
  33. package/dist/test/e2e/module/entrypoint.module.mutation.test.js +1 -1
  34. package/dist/test/handleUnbackportedPullRequests.private.test.js +1 -1
  35. package/dist/test/replaceStringAndLinebreaks.d.ts +5 -0
  36. package/dist/test/replaceStringAndLinebreaks.js +8 -0
  37. package/dist/test/sandbox.js +6 -2
  38. package/dist/utils/packageVersion.d.ts +1 -1
  39. package/dist/utils/packageVersion.js +1 -1
  40. package/package.json +23 -24
  41. package/yarn.lock +841 -950
  42. package/dist/entrypoint.cli.private.test.js +0 -47
  43. package/dist/errors/BackportError.d.ts +0 -19
  44. package/dist/errors/BackportError.js +0 -29
  45. package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
  46. package/dist/runSequentially.test.d.ts +0 -1
  47. package/dist/runSequentially.test.js +0 -243
  48. package/dist/services/BackportError.d.ts +0 -19
  49. package/dist/services/BackportError.js +0 -29
  50. package/dist/services/HandledBackportError.d.ts +0 -19
  51. package/dist/services/HandledBackportError.js +0 -29
  52. package/dist/services/HandledError.d.ts +0 -19
  53. package/dist/services/HandledError.js +0 -29
  54. package/dist/services/child-process-promisified.d.ts +0 -25
  55. package/dist/services/child-process-promisified.js +0 -58
  56. package/dist/services/env.d.ts +0 -7
  57. package/dist/services/env.js +0 -30
  58. package/dist/services/env.test.d.ts +0 -1
  59. package/dist/services/env.test.js +0 -21
  60. package/dist/services/git.d.ts +0 -77
  61. package/dist/services/git.integration.test.d.ts +0 -1
  62. package/dist/services/git.integration.test.js +0 -616
  63. package/dist/services/git.js +0 -439
  64. package/dist/services/git.private.test.d.ts +0 -1
  65. package/dist/services/git.private.test.js +0 -618
  66. package/dist/services/git.test.d.ts +0 -1
  67. package/dist/services/git.test.js +0 -580
  68. package/dist/services/github/commitFormatters.d.ts +0 -3
  69. package/dist/services/github/commitFormatters.js +0 -17
  70. package/dist/services/github/commitFormatters.test.d.ts +0 -1
  71. package/dist/services/github/commitFormatters.test.js +0 -11
  72. package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +0 -2
  73. package/dist/services/github/v3/addAssigneesToPullRequest.js +0 -32
  74. package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +0 -1
  75. package/dist/services/github/v3/addAssigneesToPullRequest.test.js +0 -27
  76. package/dist/services/github/v3/addLabelsToPullRequest.d.ts +0 -2
  77. package/dist/services/github/v3/addLabelsToPullRequest.js +0 -30
  78. package/dist/services/github/v3/addReviewersToPullRequest.d.ts +0 -2
  79. package/dist/services/github/v3/addReviewersToPullRequest.js +0 -32
  80. package/dist/services/github/v3/createPullRequest.d.ts +0 -29
  81. package/dist/services/github/v3/createPullRequest.js +0 -91
  82. package/dist/services/github/v3/createPullRequest.test.d.ts +0 -1
  83. package/dist/services/github/v3/createPullRequest.test.js +0 -377
  84. package/dist/services/github/v3/createStatusComment.d.ts +0 -11
  85. package/dist/services/github/v3/createStatusComment.js +0 -131
  86. package/dist/services/github/v3/createStatusComment.test.d.ts +0 -1
  87. package/dist/services/github/v3/createStatusComment.test.js +0 -409
  88. package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +0 -14
  89. package/dist/services/github/v3/getGithubV3ErrorMessage.js +0 -16
  90. package/dist/services/github/v4/FetchPullRequestId.d.ts +0 -2
  91. package/dist/services/github/v4/FetchPullRequestId.js +0 -36
  92. package/dist/services/github/v4/apiRequestV4.d.ts +0 -31
  93. package/dist/services/github/v4/apiRequestV4.js +0 -71
  94. package/dist/services/github/v4/apiRequestV4.test.d.ts +0 -1
  95. package/dist/services/github/v4/apiRequestV4.test.js +0 -109
  96. package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -2
  97. package/dist/services/github/v4/disablePullRequestAutoMerge.js +0 -32
  98. package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -2
  99. package/dist/services/github/v4/enablePullRequestAutoMerge.js +0 -50
  100. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +0 -1
  101. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
  102. package/dist/services/github/v4/fetchAuthorId.d.ts +0 -10
  103. package/dist/services/github/v4/fetchAuthorId.js +0 -28
  104. package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +0 -1
  105. package/dist/services/github/v4/fetchAuthorId.private.test.js +0 -25
  106. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +0 -1
  107. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -93
  108. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +0 -11
  109. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +0 -58
  110. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +0 -1
  111. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +0 -136
  112. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +0 -11
  113. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +0 -48
  114. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +0 -1
  115. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +0 -118
  116. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +0 -29
  117. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +0 -110
  118. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +0 -1
  119. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +0 -196
  120. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +0 -1
  121. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -157
  122. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +0 -3
  123. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +0 -61
  124. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
  125. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +0 -107
  126. package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +0 -12
  127. package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +0 -69
  128. package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -9
  129. package/dist/services/github/v4/fetchExistingPullRequest.js +0 -64
  130. package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +0 -1
  131. package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -44
  132. package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -2
  133. package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +0 -39
  134. package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +0 -8
  135. package/dist/services/github/v4/fetchRemoteProjectConfig.js +0 -49
  136. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +0 -1
  137. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +0 -49
  138. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +0 -69
  139. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +0 -73
  140. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +0 -1
  141. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -116
  142. package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +0 -16
  143. package/dist/services/github/v4/getOptionsFromGithub/query.js +0 -29
  144. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +0 -29
  145. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +0 -61
  146. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +0 -1
  147. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +0 -72
  148. package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +0 -2
  149. package/dist/services/github/v4/mocks/commitsByAuthorMock.js +0 -176
  150. package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +0 -6
  151. package/dist/services/github/v4/throwOnInvalidAccessToken.js +0 -45
  152. package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +0 -1
  153. package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +0 -87
  154. package/dist/services/logger.d.ts +0 -9
  155. package/dist/services/logger.js +0 -74
  156. package/dist/services/prompt.test.d.ts +0 -1
  157. package/dist/services/prompt.test.js +0 -139
  158. package/dist/services/prompts.d.ts +0 -17
  159. package/dist/services/prompts.js +0 -132
  160. package/dist/services/remoteConfig.d.ts +0 -20
  161. package/dist/services/remoteConfig.js +0 -52
  162. package/dist/services/sequentially.d.ts +0 -1
  163. package/dist/services/sequentially.js +0 -10
  164. package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +0 -16
  165. package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +0 -102
  166. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +0 -1
  167. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +0 -467
  168. package/dist/services/sourceCommit/getMockSourceCommit.d.ts +0 -26
  169. package/dist/services/sourceCommit/getMockSourceCommit.js +0 -103
  170. package/dist/services/sourceCommit/parseSourceCommit.d.ts +0 -108
  171. package/dist/services/sourceCommit/parseSourceCommit.js +0 -123
  172. package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +0 -1
  173. package/dist/services/sourceCommit/parseSourceCommit.test.js +0 -226
  174. package/dist/services/test.d.ts +0 -1
  175. package/dist/services/test.js +0 -23
  176. package/dist/state.d.ts +0 -0
  177. package/dist/state.js +0 -1
  178. package/dist/test/ExecError.d.ts +0 -16
  179. package/dist/test/ExecError.js +0 -15
  180. package/dist/test/e2e/cli/cli.private.test.d.ts +0 -1
  181. package/dist/test/e2e/cli/cli.private.test.js +0 -222
  182. package/dist/test/e2e/cli/date-filters.d.ts +0 -1
  183. package/dist/test/e2e/cli/date-filters.js +0 -43
  184. package/dist/test/e2e/cli/interactive-error-handling.private.test.d.ts +0 -1
  185. package/dist/test/e2e/cli/interactive-error-handling.private.test.js +0 -80
  186. package/dist/test/e2e/cli/non-interactive-error-handling.private.test.d.ts +0 -1
  187. package/dist/test/e2e/cli/non-interactive-error-handling.private.test.js +0 -198
  188. package/dist/test/e2e/cli.e2e.private.test.d.ts +0 -1
  189. package/dist/test/e2e/cli.e2e.private.test.js +0 -433
  190. package/dist/test/e2e/module/module.mutation.test.d.ts +0 -1
  191. package/dist/test/e2e/module/module.mutation.test.js +0 -369
  192. package/dist/test/e2e/module.e2e.mutation.test.d.ts +0 -1
  193. package/dist/test/e2e/module.e2e.mutation.test.js +0 -369
  194. package/dist/test/e2e/module.e2e.private.test.d.ts +0 -1
  195. package/dist/test/e2e/module.e2e.private.test.js +0 -369
  196. package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -13
  197. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +0 -243
  198. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
  199. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +0 -320
  200. package/dist/ui/getCommits.d.ts +0 -2
  201. package/dist/ui/getCommits.js +0 -75
  202. package/dist/ui/getCommitsWithoutBackports.d.ts +0 -11
  203. package/dist/ui/getCommitsWithoutBackports.js +0 -68
  204. package/dist/ui/getCommitsWithoutBackports.test.d.ts +0 -1
  205. package/dist/ui/getCommitsWithoutBackports.test.js +0 -335
  206. package/dist/ui/getGitConfigAuthor.d.ts +0 -6
  207. package/dist/ui/getGitConfigAuthor.js +0 -15
  208. package/dist/ui/getTargetBranches.d.ts +0 -5
  209. package/dist/ui/getTargetBranches.js +0 -67
  210. package/dist/ui/getTargetBranches.test.d.ts +0 -1
  211. package/dist/ui/getTargetBranches.test.js +0 -204
  212. package/dist/ui/maybeSetupRepo.d.ts +0 -2
  213. package/dist/ui/maybeSetupRepo.js +0 -53
  214. package/dist/ui/maybeSetupRepo.test.d.ts +0 -1
  215. package/dist/ui/maybeSetupRepo.test.js +0 -238
  216. package/dist/ui/ora.d.ts +0 -2
  217. package/dist/ui/ora.js +0 -21
  218. package/dist/ui/setupRepo.d.ts +0 -2
  219. package/dist/ui/setupRepo.js +0 -56
  220. package/dist/ui/setupRepo.test.d.ts +0 -1
  221. package/dist/ui/setupRepo.test.js +0 -273
  222. package/dist/utils/filterMissingCommits.d.ts +0 -2
  223. package/dist/utils/filterMissingCommits.js +0 -7
  224. package/dist/utils/redact.d.ts +0 -1
  225. package/dist/utils/redact.js +0 -7
@@ -1,433 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- const child_process_1 = require("child_process");
26
- const path_1 = __importDefault(require("path"));
27
- const strip_ansi_1 = __importDefault(require("strip-ansi"));
28
- const child_process_promisified_1 = require("../../services/child-process-promisified");
29
- const packageVersion = __importStar(require("../../utils/packageVersion"));
30
- const getDevAccessToken_1 = require("../private/getDevAccessToken");
31
- const sandbox_1 = require("../sandbox");
32
- const TIMEOUT_IN_SECONDS = 15;
33
- jest.setTimeout(TIMEOUT_IN_SECONDS * 1000);
34
- const devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
35
- describe('inquirer cli', () => {
36
- it('--version', async () => {
37
- const res = await runBackportViaCli([`--version`], {
38
- showLoadingSpinner: true,
39
- });
40
- expect(res).toEqual(process.env.npm_package_version);
41
- });
42
- it('-v', async () => {
43
- const res = await runBackportViaCli([`-v`], {
44
- showLoadingSpinner: true,
45
- });
46
- expect(res).toEqual(process.env.npm_package_version);
47
- });
48
- it('PACKAGE_VERSION should match', async () => {
49
- // @ts-expect-error
50
- expect(packageVersion.UNMOCKED_PACKAGE_VERSION).toBe(process.env.npm_package_version);
51
- });
52
- it('--help', async () => {
53
- const res = await runBackportViaCli([`--help`]);
54
- expect(res).toMatchInlineSnapshot(`
55
- "entrypoint.cli.ts [args]
56
- Options:
57
- -v, -V, --version Show version number [boolean]
58
- --accessToken, --accesstoken Github access token [string]
59
- -a, --all List all commits [boolean]
60
- --assignee, --assign Add assignees to the target pull request [array]
61
- --autoAssign Auto assign the target pull request to yourself [boolean]
62
- --autoMerge Enable auto-merge for created pull requests [boolean]
63
- --autoMergeMethod Sets auto-merge method when using --auto-merge. Default:
64
- merge [string] [choices: \\"merge\\", \\"rebase\\", \\"squash\\"]
65
- --ci Disable interactive prompts [boolean]
66
- --cherrypickRef Append commit message with \\"(cherry picked from commit...)
67
- [boolean]
68
- --configFile, --config Path to project config [string]
69
- --since ISO-8601 date for filtering commits [string]
70
- --until ISO-8601 date for filtering commits [string]
71
- --dir Location where the temporary repository will be stored
72
- [string]
73
- --details Show details about each commit [boolean]
74
- --dryRun Run backport locally without pushing to Github [boolean]
75
- --editor Editor to be opened during conflict resolution [string]
76
- --skipRemoteConfig Use local .backportrc.json config instead of loading from
77
- Github [boolean]
78
- --fork Create backports in fork or origin repo [boolean]
79
- --mainline Parent id of merge commit. Defaults to 1 when supplied
80
- without arguments [number]
81
- -n, --maxNumber, --number Number of commits to choose from [number]
82
- --multiple Select multiple branches/commits [boolean]
83
- --multipleBranches Backport to multiple branches [boolean]
84
- --multipleCommits Backport multiple commits [boolean]
85
- --noCherrypickRef Do not append commit message with \\"(cherry picked from
86
- commit...)\\" [boolean]
87
- --noStatusComment Don't publish status comment to Github [boolean]
88
- --noVerify Bypass the pre-commit and commit-msg hooks [boolean]
89
- --noFork Create backports in the origin repo [boolean]
90
- -p, --path Only list commits touching files under the specified path
91
- [array]
92
- --prDescription, --description Description to be added to pull request [string]
93
- --prTitle, --title Title of pull request [string]
94
- --prFilter Filter source pull requests by a query [string]
95
- --pullNumber, --pr Pull request to backport [number]
96
- --resetAuthor Set yourself as commit author [boolean]
97
- --reviewer Add reviewer to the target PR [array]
98
- --repoOwner Repository owner [string]
99
- --repoName Repository name [string]
100
- --repo Repo owner and name [string]
101
- --sha, --commit Commit sha to backport [string]
102
- --sourceBranch Specify a non-default branch (normally \\"master\\") to backport
103
- from [string]
104
- --sourcePRLabel, --sourcePrLabel Add labels to the source (original) PR [array]
105
- -b, --targetBranch, --branch Branch(es) to backport to [array]
106
- --targetBranchChoice List branches to backport to [array]
107
- -l, --targetPRLabel, --label Add labels to the target (backport) PR [array]
108
- --username Defaults to the authenticated user [string]
109
- --verbose Show additional debug information [boolean]
110
- --verify Opposite of no-verify [boolean]
111
- --help Show help [boolean]
112
- For bugs, feature requests or questions: https://github.com/sqren/backport/issues
113
- Or contact me directly: https://twitter.com/sorenlouv"
114
- `);
115
- });
116
- it('should return error when branch is missing', async () => {
117
- const res = await runBackportViaCli([
118
- '--skip-remote-config',
119
- '--repo-owner',
120
- 'backport-org',
121
- '--repo-name',
122
- 'backport-e2e',
123
- '--accessToken',
124
- devAccessToken,
125
- ]);
126
- expect(res).toMatchInlineSnapshot(`
127
- "Please specify a target branch: \\"--branch 6.1\\".
128
- Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
129
- `);
130
- });
131
- it('should list commits based on .git/config when `repoOwner`/`repoName` is missing', async () => {
132
- const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
133
- await (0, sandbox_1.resetSandbox)(sandboxPath);
134
- await (0, child_process_promisified_1.exec)(`git init`, { cwd: sandboxPath });
135
- await (0, child_process_promisified_1.exec)(`git remote add origin git@github.com:backport-org/backport-e2e.git`, { cwd: sandboxPath });
136
- const res = await runBackportViaCli(['--accessToken', devAccessToken], {
137
- cwd: sandboxPath,
138
- waitForString: 'Select commit',
139
- });
140
- expect(res).toMatchInlineSnapshot(`
141
- "? Select commit (Use arrow keys)
142
- ❯ 1. Add sheep emoji (#9) 7.8
143
- 2. Change Ulysses to Gretha (conflict) (#8) 7.x
144
- 3. Add 🍏 emoji (#5) 7.x, 7.8
145
- 4. Add family emoji (#2) 7.x
146
- 5. Add \`backport\` dep
147
- 6. Merge pull request #1 from backport-org/add-heart-emoji
148
- 7. Add ❤️ emoji
149
- 8. Update .backportrc.json
150
- 9. Bump to 8.0.0
151
- 10.Add package.json"
152
- `);
153
- });
154
- it('should return error when access token is invalid', async () => {
155
- const res = await runBackportViaCli([
156
- '--branch',
157
- 'foo',
158
- '--repo-owner',
159
- 'foo',
160
- '--repo-name',
161
- 'bar',
162
- '--accessToken',
163
- 'some-token',
164
- ]);
165
- expect(res).toContain('Please check your access token and make sure it is valid');
166
- });
167
- it(`should return error when repo doesn't exist`, async () => {
168
- const res = await runBackportViaCli([
169
- '--branch',
170
- 'foo',
171
- '--repo-owner',
172
- 'foo',
173
- '--repo-name',
174
- 'bar',
175
- '--author',
176
- 'sqren',
177
- '--accessToken',
178
- devAccessToken,
179
- ]);
180
- expect(res).toMatchInlineSnapshot(`"The repository \\"foo/bar\\" doesn't exist"`);
181
- });
182
- it(`should list commits from master`, async () => {
183
- const output = await runBackportViaCli([
184
- '--branch',
185
- 'foo',
186
- '--repo-owner',
187
- 'backport-org',
188
- '--repo-name',
189
- 'backport-e2e',
190
- '--author',
191
- 'sqren',
192
- '--accessToken',
193
- devAccessToken,
194
- '--max-number',
195
- '6',
196
- ], { waitForString: 'Select commit' });
197
- expect(output).toMatchInlineSnapshot(`
198
- "? Select commit (Use arrow keys)
199
- ❯ 1. Add sheep emoji (#9) 7.8
200
- 2. Change Ulysses to Gretha (conflict) (#8) 7.x
201
- 3. Add 🍏 emoji (#5) 7.x, 7.8
202
- 4. Add family emoji (#2) 7.x
203
- 5. Add \`backport\` dep
204
- 6. Merge pull request #1 from backport-org/add-heart-emoji"
205
- `);
206
- });
207
- it(`should filter commits by "since" and "until"`, async () => {
208
- const output = await runBackportViaCli([
209
- '--branch',
210
- 'foo',
211
- '--repo-owner',
212
- 'backport-org',
213
- '--repo-name',
214
- 'backport-e2e',
215
- '--accessToken',
216
- devAccessToken,
217
- '--since',
218
- '2020-08-15T10:00:00.000Z',
219
- '--until',
220
- '2020-08-15T10:30:00.000Z',
221
- ], { waitForString: 'Select commit' });
222
- expect(output).toMatchInlineSnapshot(`
223
- "? Select commit (Use arrow keys)
224
- ❯ 1. Bump to 8.0.0
225
- 2. Add package.json
226
- 3. Update .backportrc.json
227
- 4. Create .backportrc.json"
228
- `);
229
- });
230
- it(`should list commits from 7.x`, async () => {
231
- const output = await runBackportViaCli([
232
- '--branch',
233
- 'foo',
234
- '--repo-owner',
235
- 'backport-org',
236
- '--repo-name',
237
- 'backport-e2e',
238
- '--author',
239
- 'sqren',
240
- '--accessToken',
241
- devAccessToken,
242
- '--max-number',
243
- '6',
244
- '--source-branch',
245
- '7.x',
246
- ], { waitForString: 'Select commit' });
247
- expect(output).toMatchInlineSnapshot(`
248
- "? Select commit (Use arrow keys)
249
- ❯ 1. Add 🍏 emoji (#5) (#6)
250
- 2. Change Ulysses to Carol
251
- 3. Add family emoji (#2) (#4)
252
- 4. Update .backportrc.json
253
- 5. Branch off: 7.9.0 (7.x)
254
- 6. Bump to 8.0.0"
255
- `);
256
- });
257
- describe('repo: repo-with-backportrc-removed (missing .backportrc.json config file)', () => {
258
- it('should list commits', async () => {
259
- const output = await runBackportViaCli([
260
- '--branch',
261
- 'foo',
262
- '--repo',
263
- 'backport-org/repo-with-backportrc-removed',
264
- '--accessToken',
265
- devAccessToken,
266
- ], { waitForString: 'Select commit' });
267
- expect(output).toMatchInlineSnapshot(`
268
- "? Select commit (Use arrow keys)
269
- ❯ 1. Rename README.me to README.md
270
- 2. Merge pull request #1 from backport-org/add-readme
271
- 3. Create README.me
272
- 4. Delete .backportrc.json
273
- 5. Create .backportrc.json
274
- 6. Delete .backportrc.json
275
- 7. Create .backportrc.json"
276
- `);
277
- });
278
- it('should attempt to backport by PR', async () => {
279
- const output = await runBackportViaCli([
280
- '--branch',
281
- 'foo',
282
- '--repo',
283
- 'backport-org/repo-with-backportrc-removed',
284
- '--pr',
285
- '1',
286
- '--accessToken',
287
- devAccessToken,
288
- ], { waitForString: "is invalid or doesn't exist" });
289
- expect(output).toMatchInlineSnapshot(`
290
- "
291
- Backporting to foo:
292
- The branch \\"foo\\" is invalid or doesn't exist"
293
- `);
294
- });
295
- it('should attempt to backport by commit sha', async () => {
296
- const output = await runBackportViaCli([
297
- '--branch',
298
- 'foo',
299
- '--repo',
300
- 'backport-org/repo-with-backportrc-removed',
301
- '--sha',
302
- 'be59df6912a550c8cb49ba3e18be3e512f3d608c',
303
- '--accessToken',
304
- devAccessToken,
305
- ], { waitForString: `Backporting to foo:` });
306
- expect(output).toMatchInlineSnapshot(`
307
- "
308
- Backporting to foo:"
309
- `);
310
- });
311
- });
312
- describe('repo: different-merge-strategies', () => {
313
- it('list all commits regardless how they were merged', async () => {
314
- const output = await runBackportViaCli([
315
- '--branch',
316
- 'foo',
317
- '--repo-owner',
318
- 'backport-org',
319
- '--repo-name',
320
- 'different-merge-strategies',
321
- '--accessToken',
322
- devAccessToken,
323
- '-n',
324
- '20',
325
- ], { waitForString: 'Select commit' });
326
- expect(output).toMatchInlineSnapshot(`
327
- "? Select commit (Use arrow keys)
328
- ❯ 1. Merge pull request #9 from backport-org/many-merge-commits
329
- 2. Merge strategy: Eighth of many merges
330
- 3. Merge strategy: Seventh of many merges
331
- 4. Merge strategy: Sixth of many merges
332
- 5. Merge strategy: Fifth of many merges
333
- 6. Merge strategy: Fourth of many merges
334
- 7. Merge strategy: Third of many merges
335
- 8. Merge strategy: Second of many merges
336
- 9. Merge strategy: First of many merges
337
- 10.Using squash to merge commits (#3) 7.x
338
- 11.Rebase strategy: Second commit 7.x
339
- 12.Rebase strategy: First commit
340
- 13.Merge pull request #1 from backport-org/merge-strategy
341
- 14.Merge strategy: Second commit
342
- 15.Merge strategy: First commit
343
- 16.Initial commit"
344
- `);
345
- });
346
- });
347
- describe('repo: test-that-repo-can-be-cloned', () => {
348
- let sandboxPath;
349
- beforeAll(async () => {
350
- sandboxPath = (0, sandbox_1.getSandboxPath)({
351
- filename: __filename,
352
- specname: 'test-cloning',
353
- });
354
- await (0, sandbox_1.resetSandbox)(sandboxPath);
355
- });
356
- function run() {
357
- return runBackportViaCli([
358
- '--repo',
359
- 'backport-org/test-that-repo-can-be-cloned',
360
- '--branch',
361
- 'foo',
362
- '--pr',
363
- '1',
364
- '--dir',
365
- sandboxPath,
366
- '--dry-run',
367
- '--accessToken',
368
- devAccessToken,
369
- ], { showLoadingSpinner: true, waitForString: 'Backporting to foo:' });
370
- }
371
- it('clones the repo on the very first run', async () => {
372
- const output = await run();
373
- expect(output).toContain('Cloning repository from github.com');
374
- expect(output).toMatchInlineSnapshot(`
375
- "- Initializing...
376
- ? Select pull request Beginning of a beautiful repo (#1)
377
- ✔ 100% Cloning repository from github.com (one-time operation)
378
- Backporting to foo:"
379
- `);
380
- });
381
- it('does not clone the repo on subsequent runs', async () => {
382
- const output = await run();
383
- expect(output).not.toContain('Cloning repository from github.com');
384
- expect(output).toMatchInlineSnapshot(`
385
- "- Initializing...
386
- ? Select pull request Beginning of a beautiful repo (#1)
387
- Backporting to foo:"
388
- `);
389
- });
390
- });
391
- });
392
- function runBackportViaCli(cliArgs, { showLoadingSpinner, waitForString, cwd, } = {}) {
393
- const tsNodeBinary = path_1.default.resolve('./node_modules/.bin/ts-node');
394
- const entrypointFile = path_1.default.resolve('./src/entrypoint.cli.ts');
395
- const proc = (0, child_process_1.spawn)(tsNodeBinary, [
396
- '--transpile-only',
397
- entrypointFile,
398
- '--log-file-path',
399
- '/dev/null',
400
- ...cliArgs,
401
- ], { cwd });
402
- const p = new Promise((resolve, reject) => {
403
- let data = '';
404
- // fail if expectations hasn't been found within 10 seconds
405
- const timeout = setTimeout(() => {
406
- reject(`Expectation '${waitForString}' not found within ${TIMEOUT_IN_SECONDS} seconds in:
407
- '${data.toString()}'`);
408
- }, TIMEOUT_IN_SECONDS * 1000);
409
- proc.stdout.on('data', (chunk) => {
410
- data += chunk;
411
- const rawOutput = data.toString();
412
- // remove ansi codes and whitespace
413
- const output = (0, strip_ansi_1.default)(rawOutput).replace(/\s+$/gm, '');
414
- if (!waitForString || output.includes(waitForString)) {
415
- clearTimeout(timeout);
416
- resolve(output);
417
- }
418
- });
419
- // ora (loading spinner) is redirected to stderr
420
- if (showLoadingSpinner) {
421
- proc.stderr.on('data', (chunk) => {
422
- data += chunk;
423
- });
424
- }
425
- proc.on('error', (err) => {
426
- reject(`runBackportViaCli failed with: ${err}`);
427
- });
428
- });
429
- // kill child process
430
- return p.finally(() => {
431
- proc.kill();
432
- });
433
- }
@@ -1 +0,0 @@
1
- export {};