backport 8.3.1 → 8.4.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 (202) hide show
  1. package/dist/lib/child-process-promisified.js +2 -2
  2. package/dist/lib/git.js +1 -0
  3. package/dist/lib/git.test.js +26 -0
  4. package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -0
  5. package/dist/options/ConfigOptions.d.ts +1 -0
  6. package/dist/options/cliArgs.d.ts +1 -0
  7. package/dist/options/cliArgs.js +5 -0
  8. package/dist/options/config/config.d.ts +1 -0
  9. package/dist/options/config/readConfigFile.d.ts +1 -0
  10. package/dist/options/options.d.ts +2 -0
  11. package/dist/options/options.js +1 -0
  12. package/dist/options/options.test.js +1 -0
  13. package/dist/test/e2e/cli/entrypoint.cli.private.test.js +2 -0
  14. package/dist/utils/packageVersion.d.ts +1 -1
  15. package/dist/utils/packageVersion.js +1 -1
  16. package/package.json +3 -4
  17. package/dist/entrypoint.cli.private.test.d.ts +0 -1
  18. package/dist/entrypoint.cli.private.test.js +0 -47
  19. package/dist/errors/BackportError.d.ts +0 -19
  20. package/dist/errors/BackportError.js +0 -29
  21. package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts +0 -1
  22. package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
  23. package/dist/runSequentially.test.d.ts +0 -1
  24. package/dist/runSequentially.test.js +0 -243
  25. package/dist/services/BackportError.d.ts +0 -19
  26. package/dist/services/BackportError.js +0 -29
  27. package/dist/services/HandledBackportError.d.ts +0 -19
  28. package/dist/services/HandledBackportError.js +0 -29
  29. package/dist/services/HandledError.d.ts +0 -19
  30. package/dist/services/HandledError.js +0 -29
  31. package/dist/services/child-process-promisified.d.ts +0 -25
  32. package/dist/services/child-process-promisified.js +0 -58
  33. package/dist/services/env.d.ts +0 -7
  34. package/dist/services/env.js +0 -30
  35. package/dist/services/env.test.d.ts +0 -1
  36. package/dist/services/env.test.js +0 -21
  37. package/dist/services/git.d.ts +0 -77
  38. package/dist/services/git.integration.test.d.ts +0 -1
  39. package/dist/services/git.integration.test.js +0 -616
  40. package/dist/services/git.js +0 -439
  41. package/dist/services/git.private.test.d.ts +0 -1
  42. package/dist/services/git.private.test.js +0 -618
  43. package/dist/services/git.test.d.ts +0 -1
  44. package/dist/services/git.test.js +0 -580
  45. package/dist/services/github/commitFormatters.d.ts +0 -3
  46. package/dist/services/github/commitFormatters.js +0 -17
  47. package/dist/services/github/commitFormatters.test.d.ts +0 -1
  48. package/dist/services/github/commitFormatters.test.js +0 -11
  49. package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +0 -2
  50. package/dist/services/github/v3/addAssigneesToPullRequest.js +0 -32
  51. package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +0 -1
  52. package/dist/services/github/v3/addAssigneesToPullRequest.test.js +0 -27
  53. package/dist/services/github/v3/addLabelsToPullRequest.d.ts +0 -2
  54. package/dist/services/github/v3/addLabelsToPullRequest.js +0 -30
  55. package/dist/services/github/v3/addReviewersToPullRequest.d.ts +0 -2
  56. package/dist/services/github/v3/addReviewersToPullRequest.js +0 -32
  57. package/dist/services/github/v3/createPullRequest.d.ts +0 -29
  58. package/dist/services/github/v3/createPullRequest.js +0 -91
  59. package/dist/services/github/v3/createPullRequest.test.d.ts +0 -1
  60. package/dist/services/github/v3/createPullRequest.test.js +0 -377
  61. package/dist/services/github/v3/createStatusComment.d.ts +0 -11
  62. package/dist/services/github/v3/createStatusComment.js +0 -131
  63. package/dist/services/github/v3/createStatusComment.test.d.ts +0 -1
  64. package/dist/services/github/v3/createStatusComment.test.js +0 -409
  65. package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +0 -14
  66. package/dist/services/github/v3/getGithubV3ErrorMessage.js +0 -16
  67. package/dist/services/github/v4/FetchPullRequestId.d.ts +0 -2
  68. package/dist/services/github/v4/FetchPullRequestId.js +0 -36
  69. package/dist/services/github/v4/apiRequestV4.d.ts +0 -31
  70. package/dist/services/github/v4/apiRequestV4.js +0 -71
  71. package/dist/services/github/v4/apiRequestV4.test.d.ts +0 -1
  72. package/dist/services/github/v4/apiRequestV4.test.js +0 -109
  73. package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -2
  74. package/dist/services/github/v4/disablePullRequestAutoMerge.js +0 -32
  75. package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -2
  76. package/dist/services/github/v4/enablePullRequestAutoMerge.js +0 -50
  77. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +0 -1
  78. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
  79. package/dist/services/github/v4/fetchAuthorId.d.ts +0 -10
  80. package/dist/services/github/v4/fetchAuthorId.js +0 -28
  81. package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +0 -1
  82. package/dist/services/github/v4/fetchAuthorId.private.test.js +0 -25
  83. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +0 -1
  84. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -93
  85. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +0 -11
  86. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +0 -58
  87. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +0 -1
  88. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +0 -136
  89. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +0 -11
  90. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +0 -48
  91. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +0 -1
  92. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +0 -118
  93. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +0 -29
  94. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +0 -110
  95. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +0 -1
  96. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +0 -196
  97. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +0 -1
  98. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -157
  99. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +0 -3
  100. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +0 -61
  101. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
  102. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +0 -107
  103. package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +0 -12
  104. package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +0 -69
  105. package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -9
  106. package/dist/services/github/v4/fetchExistingPullRequest.js +0 -64
  107. package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +0 -1
  108. package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -44
  109. package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -2
  110. package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +0 -39
  111. package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +0 -8
  112. package/dist/services/github/v4/fetchRemoteProjectConfig.js +0 -49
  113. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +0 -1
  114. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +0 -49
  115. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +0 -69
  116. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +0 -73
  117. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +0 -1
  118. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -116
  119. package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +0 -16
  120. package/dist/services/github/v4/getOptionsFromGithub/query.js +0 -29
  121. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +0 -29
  122. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +0 -61
  123. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +0 -1
  124. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +0 -72
  125. package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +0 -2
  126. package/dist/services/github/v4/mocks/commitsByAuthorMock.js +0 -176
  127. package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +0 -6
  128. package/dist/services/github/v4/throwOnInvalidAccessToken.js +0 -45
  129. package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +0 -1
  130. package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +0 -87
  131. package/dist/services/logger.d.ts +0 -9
  132. package/dist/services/logger.js +0 -74
  133. package/dist/services/prompt.test.d.ts +0 -1
  134. package/dist/services/prompt.test.js +0 -139
  135. package/dist/services/prompts.d.ts +0 -17
  136. package/dist/services/prompts.js +0 -132
  137. package/dist/services/remoteConfig.d.ts +0 -20
  138. package/dist/services/remoteConfig.js +0 -52
  139. package/dist/services/sequentially.d.ts +0 -1
  140. package/dist/services/sequentially.js +0 -10
  141. package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +0 -16
  142. package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +0 -102
  143. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +0 -1
  144. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +0 -467
  145. package/dist/services/sourceCommit/getMockSourceCommit.d.ts +0 -26
  146. package/dist/services/sourceCommit/getMockSourceCommit.js +0 -103
  147. package/dist/services/sourceCommit/parseSourceCommit.d.ts +0 -108
  148. package/dist/services/sourceCommit/parseSourceCommit.js +0 -123
  149. package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +0 -1
  150. package/dist/services/sourceCommit/parseSourceCommit.test.js +0 -226
  151. package/dist/services/test.d.ts +0 -1
  152. package/dist/services/test.js +0 -23
  153. package/dist/state.d.ts +0 -0
  154. package/dist/state.js +0 -1
  155. package/dist/test/ExecError.d.ts +0 -16
  156. package/dist/test/ExecError.js +0 -15
  157. package/dist/test/e2e/cli/cli.private.test.d.ts +0 -1
  158. package/dist/test/e2e/cli/cli.private.test.js +0 -222
  159. package/dist/test/e2e/cli/date-filters.d.ts +0 -1
  160. package/dist/test/e2e/cli/date-filters.js +0 -43
  161. package/dist/test/e2e/cli/interactive-error-handling.private.test.d.ts +0 -1
  162. package/dist/test/e2e/cli/interactive-error-handling.private.test.js +0 -80
  163. package/dist/test/e2e/cli/non-interactive-error-handling.private.test.d.ts +0 -1
  164. package/dist/test/e2e/cli/non-interactive-error-handling.private.test.js +0 -198
  165. package/dist/test/e2e/cli.e2e.private.test.d.ts +0 -1
  166. package/dist/test/e2e/cli.e2e.private.test.js +0 -433
  167. package/dist/test/e2e/module/module.mutation.test.d.ts +0 -1
  168. package/dist/test/e2e/module/module.mutation.test.js +0 -369
  169. package/dist/test/e2e/module.e2e.mutation.test.d.ts +0 -1
  170. package/dist/test/e2e/module.e2e.mutation.test.js +0 -369
  171. package/dist/test/e2e/module.e2e.private.test.d.ts +0 -1
  172. package/dist/test/e2e/module.e2e.private.test.js +0 -369
  173. package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -13
  174. package/dist/ui/cherrypickAndCreateTargetPullRequest.js +0 -243
  175. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
  176. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +0 -320
  177. package/dist/ui/getCommits.d.ts +0 -2
  178. package/dist/ui/getCommits.js +0 -75
  179. package/dist/ui/getCommitsWithoutBackports.d.ts +0 -11
  180. package/dist/ui/getCommitsWithoutBackports.js +0 -68
  181. package/dist/ui/getCommitsWithoutBackports.test.d.ts +0 -1
  182. package/dist/ui/getCommitsWithoutBackports.test.js +0 -335
  183. package/dist/ui/getGitConfigAuthor.d.ts +0 -6
  184. package/dist/ui/getGitConfigAuthor.js +0 -15
  185. package/dist/ui/getTargetBranches.d.ts +0 -5
  186. package/dist/ui/getTargetBranches.js +0 -67
  187. package/dist/ui/getTargetBranches.test.d.ts +0 -1
  188. package/dist/ui/getTargetBranches.test.js +0 -204
  189. package/dist/ui/maybeSetupRepo.d.ts +0 -2
  190. package/dist/ui/maybeSetupRepo.js +0 -53
  191. package/dist/ui/maybeSetupRepo.test.d.ts +0 -1
  192. package/dist/ui/maybeSetupRepo.test.js +0 -238
  193. package/dist/ui/ora.d.ts +0 -2
  194. package/dist/ui/ora.js +0 -21
  195. package/dist/ui/setupRepo.d.ts +0 -2
  196. package/dist/ui/setupRepo.js +0 -56
  197. package/dist/ui/setupRepo.test.d.ts +0 -1
  198. package/dist/ui/setupRepo.test.js +0 -273
  199. package/dist/utils/filterMissingCommits.d.ts +0 -2
  200. package/dist/utils/filterMissingCommits.js +0 -7
  201. package/dist/utils/redact.d.ts +0 -1
  202. package/dist/utils/redact.js +0 -7
@@ -1,222 +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
- Object.defineProperty(exports, "__esModule", { value: true });
22
- const child_process_promisified_1 = require("../../../services/child-process-promisified");
23
- const packageVersion = __importStar(require("../../../utils/packageVersion"));
24
- const getDevAccessToken_1 = require("../../private/getDevAccessToken");
25
- const sandbox_1 = require("../../sandbox");
26
- const runBackportViaCli_1 = require("./runBackportViaCli");
27
- const TIMEOUT_IN_SECONDS = 15;
28
- jest.setTimeout(TIMEOUT_IN_SECONDS * 1000);
29
- const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
30
- describe('backport cli', () => {
31
- it('--version', async () => {
32
- const res = await (0, runBackportViaCli_1.runBackportViaCli)([`--version`], {
33
- showOra: true,
34
- });
35
- expect(res).toEqual(process.env.npm_package_version);
36
- });
37
- it('-v', async () => {
38
- const res = await (0, runBackportViaCli_1.runBackportViaCli)([`-v`], {
39
- showOra: true,
40
- });
41
- expect(res).toEqual(process.env.npm_package_version);
42
- });
43
- it('PACKAGE_VERSION should match', async () => {
44
- // @ts-expect-error
45
- expect(packageVersion.UNMOCKED_PACKAGE_VERSION).toBe(process.env.npm_package_version);
46
- });
47
- it('--help', async () => {
48
- const res = await (0, runBackportViaCli_1.runBackportViaCli)([`--help`]);
49
- expect(res).toMatchInlineSnapshot(`
50
- "entrypoint.cli.ts [args]
51
- Options:
52
- -v, -V, --version Show version number [boolean]
53
- --accessToken, --accesstoken Github access token [string]
54
- -a, --all List all commits [boolean]
55
- --assignee, --assign Add assignees to the target pull request [array]
56
- --autoAssign Auto assign the target pull request to yourself [boolean]
57
- --autoMerge Enable auto-merge for created pull requests [boolean]
58
- --autoMergeMethod Sets auto-merge method when using --auto-merge. Default:
59
- merge [string] [choices: \\"merge\\", \\"rebase\\", \\"squash\\"]
60
- --ci Disable interactive prompts [boolean]
61
- --cherrypickRef Append commit message with \\"(cherry picked from commit...)
62
- [boolean]
63
- --configFile, --config Path to project config [string]
64
- --since ISO-8601 date for filtering commits [string]
65
- --until ISO-8601 date for filtering commits [string]
66
- --dir Location where the temporary repository will be stored
67
- [string]
68
- --details Show details about each commit [boolean]
69
- --dryRun Run backport locally without pushing to Github [boolean]
70
- --editor Editor to be opened during conflict resolution [string]
71
- --skipRemoteConfig Use local .backportrc.json config instead of loading from
72
- Github [boolean]
73
- --fork Create backports in fork or origin repo. Defaults to true
74
- [boolean]
75
- --gitAuthorName Set commit author name [string]
76
- --gitAuthorEmail Set commit author email [string]
77
- --ls List commits instead of backporting them [boolean]
78
- --mainline Parent id of merge commit. Defaults to 1 when supplied
79
- without arguments [number]
80
- -n, --maxNumber, --number Number of commits to choose from [number]
81
- --multiple Select multiple branches/commits [boolean]
82
- --multipleBranches Backport to multiple branches [boolean]
83
- --multipleCommits Backport multiple commits [boolean]
84
- --noCherrypickRef Do not append commit message with \\"(cherry picked from
85
- commit...)\\" [boolean]
86
- --noStatusComment Don't publish status comment to Github [boolean]
87
- --noVerify Bypass the pre-commit and commit-msg hooks [boolean]
88
- --noFork Create backports in the origin repo [boolean]
89
- --onlyMissing Only list commits with missing or unmerged backports
90
- [boolean]
91
- -p, --path Only list commits touching files under the specified path
92
- [array]
93
- --prDescription, --description Description to be added to pull request [string]
94
- --prTitle, --title Title of pull request [string]
95
- --prFilter Filter source pull requests by a query [string]
96
- --pullNumber, --pr Pull request to backport [number]
97
- --resetAuthor Set yourself as commit author [boolean]
98
- --reviewer Add reviewer to the target PR [array]
99
- --repoForkOwner The owner of the fork where the backport branch is pushed.
100
- Defaults to the currently authenticated user [string]
101
- --repoOwner Repository owner [string]
102
- --repoName Repository name [string]
103
- --repo Repo owner and name [string]
104
- --sha, --commit Commit sha to backport [string]
105
- --sourceBranch Specify a non-default branch (normally \\"master\\") to backport
106
- from [string]
107
- --sourcePRLabel, --sourcePrLabel Add labels to the source (original) PR [array]
108
- -b, --targetBranch, --branch Branch(es) to backport to [array]
109
- --targetBranchChoice List branches to backport to [array]
110
- -l, --targetPRLabel, --label Add labels to the target (backport) PR [array]
111
- --verbose Show additional debug information [boolean]
112
- --verify Opposite of no-verify [boolean]
113
- --help Show help [boolean]
114
- For bugs, feature requests or questions: https://github.com/sqren/backport/issues
115
- Or contact me directly: https://twitter.com/sorenlouv"
116
- `);
117
- });
118
- it('should return error when branch is missing', async () => {
119
- const res = await (0, runBackportViaCli_1.runBackportViaCli)([
120
- '--skip-remote-config',
121
- '--repo=backport-org/backport-e2e',
122
- `--accessToken=${accessToken}`,
123
- ]);
124
- expect(res).toMatchInlineSnapshot(`
125
- "Please specify a target branch: \\"--branch 6.1\\".
126
- Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
127
- `);
128
- });
129
- it('should list commits based on .git/config when `repoOwner`/`repoName` is missing', async () => {
130
- const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
131
- await (0, sandbox_1.resetSandbox)(sandboxPath);
132
- await (0, child_process_promisified_1.exec)(`git init`, { cwd: sandboxPath });
133
- await (0, child_process_promisified_1.exec)(`git remote add origin git@github.com:backport-org/backport-e2e.git`, { cwd: sandboxPath });
134
- const res = await (0, runBackportViaCli_1.runBackportViaCli)([`--accessToken=${accessToken}`], {
135
- cwd: sandboxPath,
136
- waitForString: 'Select commit',
137
- });
138
- expect(res).toMatchInlineSnapshot(`
139
- "? Select commit (Use arrow keys)
140
- ❯ 1. Add sheep emoji (#9) 7.8
141
- 2. Change Ulysses to Gretha (conflict) (#8) 7.x
142
- 3. Add 🍏 emoji (#5) 7.x, 7.8
143
- 4. Add family emoji (#2) 7.x
144
- 5. Add \`backport\` dep
145
- 6. Merge pull request #1 from backport-org/add-heart-emoji
146
- 7. Add ❤️ emoji
147
- 8. Update .backportrc.json
148
- 9. Bump to 8.0.0
149
- 10.Add package.json"
150
- `);
151
- });
152
- it('should return error when access token is invalid', async () => {
153
- const res = await (0, runBackportViaCli_1.runBackportViaCli)([
154
- '--branch=foo',
155
- '--repo=foo/bar',
156
- '--accessToken=some-token',
157
- ]);
158
- expect(res).toContain('Please check your access token and make sure it is valid');
159
- });
160
- it(`should return error when repo doesn't exist`, async () => {
161
- const res = await (0, runBackportViaCli_1.runBackportViaCli)([
162
- '--branch=foo',
163
- '--repo=foo/bar',
164
- '--author=sqren',
165
- `--accessToken=${accessToken}`,
166
- ]);
167
- expect(res).toMatchInlineSnapshot(`"The repository \\"foo/bar\\" doesn't exist"`);
168
- });
169
- it(`should list commits from master`, async () => {
170
- const output = await (0, runBackportViaCli_1.runBackportViaCli)([
171
- '--branch=foo',
172
- '--repo=backport-org/backport-e2e',
173
- '--author=sqren',
174
- `--accessToken=${accessToken}`,
175
- '--max-number=6',
176
- ], { waitForString: 'Select commit' });
177
- expect(output).toMatchInlineSnapshot(`
178
- "? Select commit (Use arrow keys)
179
- ❯ 1. Add sheep emoji (#9) 7.8
180
- 2. Change Ulysses to Gretha (conflict) (#8) 7.x
181
- 3. Add 🍏 emoji (#5) 7.x, 7.8
182
- 4. Add family emoji (#2) 7.x
183
- 5. Add \`backport\` dep
184
- 6. Merge pull request #1 from backport-org/add-heart-emoji"
185
- `);
186
- });
187
- it(`should filter commits by "since" and "until"`, async () => {
188
- const output = await (0, runBackportViaCli_1.runBackportViaCli)([
189
- '--branch=foo',
190
- '--repo=backport-org/backport-e2e',
191
- `--accessToken=${accessToken}`,
192
- '--since=2020-08-15T10:00:00.000Z',
193
- '--until=2020-08-15T10:30:00.000Z',
194
- ], { waitForString: 'Select commit' });
195
- expect(output).toMatchInlineSnapshot(`
196
- "? Select commit (Use arrow keys)
197
- ❯ 1. Bump to 8.0.0
198
- 2. Add package.json
199
- 3. Update .backportrc.json
200
- 4. Create .backportrc.json"
201
- `);
202
- });
203
- it(`should list commits from 7.x`, async () => {
204
- const output = await (0, runBackportViaCli_1.runBackportViaCli)([
205
- '--branch=foo',
206
- '--repo=backport-org/backport-e2e',
207
- '--author=sqren',
208
- `--accessToken=${accessToken}`,
209
- '--max-number=6',
210
- '--source-branch=7.x',
211
- ], { waitForString: 'Select commit' });
212
- expect(output).toMatchInlineSnapshot(`
213
- "? Select commit (Use arrow keys)
214
- ❯ 1. Add 🍏 emoji (#5) (#6)
215
- 2. Change Ulysses to Carol
216
- 3. Add family emoji (#2) (#4)
217
- 4. Update .backportrc.json
218
- 5. Branch off: 7.9.0 (7.x)
219
- 6. Bump to 8.0.0"
220
- `);
221
- });
222
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const getDevAccessToken_1 = require("../../private/getDevAccessToken");
4
- const runBackportViaCli_1 = require("./runBackportViaCli");
5
- const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
6
- describe('date filters (dateSince, dateUntil)', () => {
7
- it(`filters commits by "since" and "until"`, async () => {
8
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
9
- '--branch=7.x',
10
- '--repo=backport-org/backport-e2e',
11
- `--accessToken=${accessToken}`,
12
- '--since=2020-08-15T10:00:00.000Z',
13
- '--until=2020-08-15T10:30:00.000Z',
14
- ], { waitForString: 'Select commit' });
15
- expect(output).toMatchInlineSnapshot(`
16
- "? Select commit (Use arrow keys)
17
- ❯ 1. Bump to 8.0.0
18
- 2. Add package.json
19
- 3. Update .backportrc.json
20
- 4. Create .backportrc.json"
21
- `);
22
- });
23
- it('works with --pr-filter', async () => {
24
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
25
- '--branch=7.x',
26
- '--repo=elastic/kibana',
27
- `--accessToken=${accessToken}`,
28
- `--author=sqren`,
29
- '--since=2021-09-20',
30
- '--until=2021-10-01',
31
- ]);
32
- const { output: output2 } = await (0, runBackportViaCli_1.runBackportViaCli)([
33
- '--branch=7.x',
34
- '--repo=elastic/kibana',
35
- `--accessToken=${accessToken}`,
36
- `--pr-filter="author:sqren"`,
37
- '--since=2021-09-20',
38
- '--until=2021-10-01',
39
- ]);
40
- expect(output).toMatchInlineSnapshot();
41
- expect(output2).toMatchInlineSnapshot();
42
- });
43
- });
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const getDevAccessToken_1 = require("../../private/getDevAccessToken");
4
- const sandbox_1 = require("../../sandbox");
5
- const runBackportViaCli_1 = require("./runBackportViaCli");
6
- const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
7
- describe('interactive error handling', () => {
8
- it('when branch is missing', async () => {
9
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
10
- '--skip-remote-config',
11
- '--repo=backport-org/backport-e2e',
12
- `--accessToken=${accessToken}`,
13
- ]);
14
- expect(output).toMatchInlineSnapshot(`
15
- "Please specify a target branch: \\"--branch 6.1\\".
16
-
17
- Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
18
- `);
19
- });
20
- it('when supplying invalid argument', async () => {
21
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([`--foo`]);
22
- expect(output).toMatchInlineSnapshot(`
23
- "Unknown argument: foo
24
- Run \\"backport --help\\" to see all options"
25
- `);
26
- });
27
- it('when access token is invalid', async () => {
28
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
29
- '--branch=foo',
30
- '--repo=foo/bar',
31
- '--accessToken=some-token',
32
- ]);
33
- expect(output).toContain('Please check your access token and make sure it is valid');
34
- });
35
- it(`when repo doesn't exist`, async () => {
36
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
37
- '--branch=foo',
38
- '--repo=foo/bar',
39
- '--author=sqren',
40
- `--accessToken=${accessToken}`,
41
- ]);
42
- expect(output).toMatchInlineSnapshot(`"The repository \\"foo/bar\\" doesn't exist"`);
43
- });
44
- it(`when given branch is invalid`, async () => {
45
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
46
- '--branch=foo',
47
- '--repo=backport-org/backport-e2e',
48
- '--pr=9',
49
- `--accessToken=${accessToken}`,
50
- ]);
51
- expect(output).toMatchInlineSnapshot(`"The branch \\"foo\\" does not exist"`);
52
- });
53
- it(`when encountering conflicts`, async () => {
54
- const backportDir = (0, sandbox_1.getSandboxPath)({ filename: __filename });
55
- await (0, sandbox_1.resetSandbox)(backportDir);
56
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
57
- '--repo=backport-org/repo-with-conflicts',
58
- '--pr=12',
59
- '--branch=7.x',
60
- `--accessToken=${accessToken}`,
61
- `--dir=${backportDir}`,
62
- '--dry-run',
63
- ], {
64
- waitForString: 'Press ENTER when the conflicts',
65
- timeoutSeconds: 5,
66
- });
67
- // //@ts-expect-error
68
- // const lineToReplace = output.match(
69
- // /Conflicting files:[\s]+- (.*[\s].*)la-liga.md/
70
- // )[1];
71
- // const lineWithoutBreaks = lineToReplace.replace(/\s/g, '');
72
- // const outputReplaced = output
73
- // .replace(lineToReplace, lineWithoutBreaks)
74
- // .replaceAll(backportDir, '<BACKPORT_DIR>');
75
- const outputReplaced = output
76
- .replaceAll('\n', '')
77
- .replaceAll(backportDir, '<BACKPORT_DIR>');
78
- expect(outputReplaced).toMatchInlineSnapshot(`"Backporting to 7.x:The commit could not be backported due to conflictsPlease fix the conflicts in <BACKPORT_DIR>Hint: Before fixing the conflicts manually you should consider backporting the following pull requests to \\"7.x\\": - Change Barca to Braithwaite (#8) (backport missing) https://github.com/backport-org/repo-with-conflicts/pull/8? Fix the following conflicts manually:Conflicting files: - <BACKPORT_DIR>/la-liga.mdPress ENTER when the conflicts are resolved and files are staged (Y/n)"`);
79
- });
80
- });
@@ -1,198 +0,0 @@
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
- const promises_1 = __importDefault(require("fs/promises"));
7
- const path_1 = __importDefault(require("path"));
8
- const getDevAccessToken_1 = require("../../private/getDevAccessToken");
9
- const sandbox_1 = require("../../sandbox");
10
- const runBackportViaCli_1 = require("./runBackportViaCli");
11
- const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
12
- describe('non interactive (json) error handling', () => {
13
- it(`when access token is missing`, async () => {
14
- const configFilePath = await createConfigFile({});
15
- const { output, code } = await (0, runBackportViaCli_1.runBackportViaCli)([
16
- '--json',
17
- `--globalConfigFile=${configFilePath}`,
18
- ]);
19
- const backportResult = JSON.parse(output);
20
- // remove absolute path to avoid issues on ci
21
- const errorMessage = backportResult.errorMessage.replace(configFilePath, '<GLOBAL_CONFIG_FILE>');
22
- expect(code).toBe(1);
23
- expect(backportResult.status).toBe('failure');
24
- expect(errorMessage).toMatchInlineSnapshot(`
25
- "Please update your config file: \\"<GLOBAL_CONFIG_FILE>\\".
26
- It must contain a valid \\"accessToken\\".
27
-
28
- Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
29
- `);
30
- });
31
- it('when target branches cannot be inferred from pull request', async () => {
32
- const { output, code } = await (0, runBackportViaCli_1.runBackportViaCli)([
33
- '--json',
34
- '--repo=backport-org/backport-e2e',
35
- '--pr=9',
36
- `--accessToken=${accessToken}`,
37
- ]);
38
- expect(code).toBe(0);
39
- const backportResult = JSON.parse(output);
40
- expect(backportResult.status).toBe('aborted');
41
- expect(backportResult.error).toEqual({
42
- errorContext: { code: 'no-branches-exception' },
43
- name: 'BackportError',
44
- });
45
- expect(backportResult.errorMessage).toBe('There are no branches to backport to. Aborting.');
46
- });
47
- it(`when target branch and branch label mapping are missing`, async () => {
48
- const { output, code } = await (0, runBackportViaCli_1.runBackportViaCli)([
49
- '--json',
50
- `--access-token=${accessToken}`,
51
- ]);
52
- expect(code).toBe(1);
53
- const backportResult = JSON.parse(output);
54
- expect(backportResult.status).toBe('failure');
55
- expect(backportResult.errorMessage).toMatchInlineSnapshot(`
56
- "Please specify a target branch: \\"--branch 6.1\\".
57
-
58
- Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
59
- `);
60
- });
61
- it(`when argument is invalid`, async () => {
62
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)(['--json', '--foo'], {});
63
- const backportResult = JSON.parse(output);
64
- expect(backportResult.status).toBe('failure');
65
- expect(backportResult.errorMessage).toEqual('Unknown argument: foo');
66
- });
67
- it('when `--repo` is invalid', async () => {
68
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
69
- '--json',
70
- '--repo=backport-org/backport-e2e-foo',
71
- `--accessToken=${accessToken}`,
72
- ]);
73
- const backportResult = JSON.parse(output);
74
- expect(backportResult.status).toBe('failure');
75
- expect(backportResult.errorMessage).toEqual('The repository "backport-org/backport-e2e-foo" doesn\'t exist');
76
- });
77
- it('when `--sha` is invalid', async () => {
78
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
79
- '--json',
80
- '--repo=backport-org/backport-e2e',
81
- '--sha=abcdefg',
82
- `--accessToken=${accessToken}`,
83
- ]);
84
- const backportResult = JSON.parse(output);
85
- expect(backportResult.status).toBe('failure');
86
- expect(backportResult.errorMessage).toEqual('No commit found on branch "master" with sha "abcdefg"');
87
- });
88
- it('when `--branch` is invalid', async () => {
89
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
90
- '--json',
91
- '--repo=backport-org/backport-e2e',
92
- '--pr=9',
93
- '--branch=foobar',
94
- `--accessToken=${accessToken}`,
95
- ]);
96
- const backportResult = JSON.parse(output);
97
- expect(backportResult.status).toBe('failure');
98
- expect(backportResult.error).toEqual({
99
- name: 'BackportError',
100
- errorContext: {
101
- code: 'message-only-exception',
102
- message: 'The branch "foobar" does not exist',
103
- },
104
- });
105
- });
106
- it('when `--branch` tries to inject argument', async () => {
107
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
108
- '--json',
109
- '--repo=backport-org/backport-e2e',
110
- '--pr=9',
111
- '--branch=--foo bar',
112
- `--accessToken=${accessToken}`,
113
- ]);
114
- const backportResult = JSON.parse(output);
115
- expect(backportResult.status).toBe('failure');
116
- expect(backportResult.error).toEqual({
117
- name: 'BackportError',
118
- errorContext: {
119
- code: 'message-only-exception',
120
- message: 'The branch "--foo bar" does not exist',
121
- },
122
- });
123
- });
124
- it('when `--pr` is invalid', async () => {
125
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
126
- '--json',
127
- '--repo=backport-org/backport-e2e',
128
- '--pr=900',
129
- '--branch=7.x',
130
- `--accessToken=${accessToken}`,
131
- ]);
132
- const backportResult = JSON.parse(output);
133
- expect(backportResult.status).toEqual('failure');
134
- expect(backportResult.errorMessage).toEqual('Could not resolve to a PullRequest with the number of 900. (Github API v4)');
135
- });
136
- it('when encountering conflicts', async () => {
137
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
138
- '--json',
139
- '--repo=backport-org/repo-with-conflicts',
140
- '--pr=12',
141
- '--branch=7.x',
142
- `--accessToken=${accessToken}`,
143
- ]);
144
- const backportResult = JSON.parse(output);
145
- expect(backportResult.status).toEqual('success');
146
- expect(
147
- //@ts-expect-error
148
- backportResult.results[0].error.errorContext.conflictingFiles).toEqual(['la-liga.md']);
149
- });
150
- it('when `--source-branch` is invalid', async () => {
151
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
152
- '--json',
153
- '--repo=backport-org/backport-e2e',
154
- '--pr=9',
155
- '--branch=7.x',
156
- '--source-branch=foo',
157
- `--accessToken=${accessToken}`,
158
- ]);
159
- const backportResult = JSON.parse(output);
160
- expect(backportResult.status).toBe('success');
161
- expect(backportResult.results[0]).toEqual({
162
- error: {
163
- context: {
164
- cmdArgs: ['checkout', 'foo'],
165
- code: 1,
166
- stderr: "error: pathspec 'foo' did not match any file(s) known to git\n",
167
- stdout: '',
168
- },
169
- name: 'SpawnError',
170
- },
171
- status: 'unhandled-error',
172
- targetBranch: '7.x',
173
- });
174
- });
175
- it('when attempting to backport unmerged PR', async () => {
176
- const { output } = await (0, runBackportViaCli_1.runBackportViaCli)([
177
- '--json',
178
- '--repo=backport-org/backport-e2e',
179
- '--pr=12',
180
- `--accessToken=${accessToken}`,
181
- ]);
182
- const backportResult = JSON.parse(output);
183
- expect(backportResult.status).toBe('failure');
184
- expect(backportResult.error).toEqual({
185
- errorContext: {
186
- code: 'message-only-exception',
187
- message: 'The PR #12 is not merged',
188
- },
189
- name: 'BackportError',
190
- });
191
- });
192
- });
193
- async function createConfigFile(options) {
194
- const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
195
- const configPath = path_1.default.join(sandboxPath, 'config.json');
196
- await promises_1.default.writeFile(configPath, JSON.stringify(options));
197
- return configPath;
198
- }
@@ -1 +0,0 @@
1
- export {};