backport 7.2.0-beta.2 → 7.2.0-beta.3

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 (104) hide show
  1. package/dist/entrypoint.cli.private.test.d.ts +1 -0
  2. package/dist/entrypoint.cli.private.test.js +46 -0
  3. package/dist/options/cliArgs.test.d.ts +1 -0
  4. package/dist/options/cliArgs.test.js +182 -0
  5. package/dist/options/config/config.test.d.ts +1 -0
  6. package/dist/options/config/config.test.js +32 -0
  7. package/dist/options/config/globalConfig.test.d.ts +1 -0
  8. package/dist/options/config/globalConfig.test.js +61 -0
  9. package/dist/options/config/projectConfig.test.d.ts +1 -0
  10. package/dist/options/config/projectConfig.test.js +109 -0
  11. package/dist/options/options.test.d.ts +1 -0
  12. package/dist/options/options.test.js +384 -0
  13. package/dist/runSequentially.test.d.ts +1 -0
  14. package/dist/runSequentially.test.js +243 -0
  15. package/dist/scripts/postinstall.test.d.ts +1 -0
  16. package/dist/scripts/postinstall.test.js +53 -0
  17. package/dist/services/env.test.d.ts +1 -0
  18. package/dist/services/env.test.js +21 -0
  19. package/dist/services/git.d.ts +1 -3
  20. package/dist/services/git.integration.test.d.ts +1 -0
  21. package/dist/services/git.integration.test.js +320 -0
  22. package/dist/services/git.js +5 -3
  23. package/dist/services/git.test.d.ts +1 -0
  24. package/dist/services/git.test.js +532 -0
  25. package/dist/services/github/commitFormatters.test.d.ts +1 -0
  26. package/dist/services/github/commitFormatters.test.js +11 -0
  27. package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +1 -0
  28. package/dist/services/github/v3/addAssigneesToPullRequest.test.js +27 -0
  29. package/dist/services/github/v3/createPullRequest.test.d.ts +1 -0
  30. package/dist/services/github/v3/createPullRequest.test.js +325 -0
  31. package/dist/services/github/v3/createStatusComment.test.d.ts +1 -0
  32. package/dist/services/github/v3/createStatusComment.test.js +386 -0
  33. package/dist/services/github/v4/apiRequestV4.test.d.ts +1 -0
  34. package/dist/services/github/v4/apiRequestV4.test.js +109 -0
  35. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
  36. package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +112 -0
  37. package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +1 -0
  38. package/dist/services/github/v4/fetchAuthorId.private.test.js +28 -0
  39. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +1 -0
  40. package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +93 -0
  41. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
  42. package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +134 -0
  43. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
  44. package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +116 -0
  45. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
  46. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +195 -0
  47. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
  48. package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +152 -0
  49. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
  50. package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +102 -0
  51. package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +1 -0
  52. package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +47 -0
  53. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +1 -0
  54. package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +52 -0
  55. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
  56. package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +117 -0
  57. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +1 -0
  58. package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +71 -0
  59. package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +2 -0
  60. package/dist/services/github/v4/mocks/commitsByAuthorMock.js +156 -0
  61. package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +1 -0
  62. package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +87 -0
  63. package/dist/services/prompt.test.d.ts +1 -0
  64. package/dist/services/prompt.test.js +134 -0
  65. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
  66. package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +467 -0
  67. package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +1 -0
  68. package/dist/services/sourceCommit/parseSourceCommit.test.js +225 -0
  69. package/dist/test/ExecError.d.ts +16 -0
  70. package/dist/test/ExecError.js +15 -0
  71. package/dist/test/e2e/cli.e2e.private.test.d.ts +1 -0
  72. package/dist/test/e2e/cli.e2e.private.test.js +433 -0
  73. package/dist/test/e2e/module.e2e.private.test.d.ts +1 -0
  74. package/dist/test/e2e/module.e2e.private.test.js +363 -0
  75. package/dist/test/handleUnbackportedPullRequests.private.test.d.ts +1 -0
  76. package/dist/test/handleUnbackportedPullRequests.private.test.js +55 -0
  77. package/dist/test/mockConfigFiles.d.ts +5 -0
  78. package/dist/test/mockConfigFiles.js +21 -0
  79. package/dist/test/mocks.d.ts +10 -0
  80. package/dist/test/mocks.js +23 -0
  81. package/dist/test/nockHelpers.d.ts +16 -0
  82. package/dist/test/nockHelpers.js +36 -0
  83. package/dist/test/private/getDevAccessToken.d.ts +2 -0
  84. package/dist/test/private/getDevAccessToken.js +12 -0
  85. package/dist/test/sandbox.d.ts +5 -0
  86. package/dist/test/sandbox.js +43 -0
  87. package/dist/test/setupFiles/automatic-mocks.d.ts +1 -0
  88. package/dist/test/setupFiles/automatic-mocks.js +63 -0
  89. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
  90. package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +459 -0
  91. package/dist/ui/getCommitsWithoutBackports.test.d.ts +1 -0
  92. package/dist/ui/getCommitsWithoutBackports.test.js +311 -0
  93. package/dist/ui/getTargetBranches.test.d.ts +1 -0
  94. package/dist/ui/getTargetBranches.test.js +198 -0
  95. package/dist/ui/maybeSetupRepo.js +7 -3
  96. package/dist/ui/maybeSetupRepo.test.d.ts +1 -0
  97. package/dist/ui/maybeSetupRepo.test.js +238 -0
  98. package/dist/ui/ora.d.ts +1 -1
  99. package/dist/ui/ora.js +2 -2
  100. package/dist/utils/excludeUndefined.test.d.ts +1 -0
  101. package/dist/utils/excludeUndefined.test.js +24 -0
  102. package/dist/utils/packageVersion.d.ts +1 -1
  103. package/dist/utils/packageVersion.js +1 -1
  104. package/package.json +1 -1
@@ -0,0 +1,325 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const createPullRequest_1 = require("./createPullRequest");
4
+ describe('getPullRequestBody', () => {
5
+ it('when single pull request is backported', () => {
6
+ expect((0, createPullRequest_1.getPullRequestBody)({
7
+ options: {},
8
+ commits: [
9
+ {
10
+ sourcePullRequest: {
11
+ number: 55,
12
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
13
+ mergeCommit: {
14
+ sha: 'abcdefghi',
15
+ message: 'My commit message (#55)',
16
+ },
17
+ },
18
+ sourceCommit: {
19
+ committedDate: '2020',
20
+ sha: 'abcdefghi',
21
+ message: 'My commit message (#55)',
22
+ },
23
+ expectedTargetPullRequests: [],
24
+ sourceBranch: 'master',
25
+ },
26
+ ],
27
+ targetBranch: '7.x',
28
+ })).toMatchInlineSnapshot(`
29
+ "# Backport
30
+
31
+ This will backport the following commits from \`master\` to \`7.x\`:
32
+ - [My commit message (#55)](https://github.com/backport-org/different-merge-strategies/pull/55)
33
+
34
+ <!--- Backport version: 1.2.3-mocked -->
35
+
36
+ ### Questions ?
37
+ Please refer to the [Backport tool documentation](https://github.com/sqren/backport)"
38
+ `);
39
+ });
40
+ it('when a single commit (non pull request) is backported', () => {
41
+ expect((0, createPullRequest_1.getPullRequestBody)({
42
+ options: {},
43
+ commits: [
44
+ {
45
+ sourceCommit: {
46
+ committedDate: '',
47
+ sha: 'abcdefghijklmw',
48
+ message: 'My commit message',
49
+ },
50
+ sourceBranch: 'main',
51
+ expectedTargetPullRequests: [],
52
+ },
53
+ ],
54
+ targetBranch: '7.x',
55
+ })).toMatchInlineSnapshot(`
56
+ "# Backport
57
+
58
+ This will backport the following commits from \`main\` to \`7.x\`:
59
+ - My commit message (abcdefgh)
60
+
61
+ <!--- Backport version: 1.2.3-mocked -->
62
+
63
+ ### Questions ?
64
+ Please refer to the [Backport tool documentation](https://github.com/sqren/backport)"
65
+ `);
66
+ });
67
+ it('when multiple commits are backported', () => {
68
+ expect((0, createPullRequest_1.getPullRequestBody)({
69
+ options: {},
70
+ commits: [
71
+ {
72
+ sourcePullRequest: {
73
+ number: 55,
74
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
75
+ mergeCommit: {
76
+ sha: 'abcdefghijklm',
77
+ message: 'My commit message (#55)',
78
+ },
79
+ },
80
+ sourceCommit: {
81
+ committedDate: '',
82
+ sha: 'abcdefghijklm',
83
+ message: 'My commit message (#55)',
84
+ },
85
+ sourceBranch: 'main',
86
+ expectedTargetPullRequests: [],
87
+ },
88
+ {
89
+ sourceCommit: {
90
+ committedDate: '',
91
+ sha: 'qwertyuiop',
92
+ message: 'Another commit message',
93
+ },
94
+ sourceBranch: 'main',
95
+ expectedTargetPullRequests: [],
96
+ },
97
+ ],
98
+ targetBranch: '7.x',
99
+ })).toMatchInlineSnapshot(`
100
+ "# Backport
101
+
102
+ This will backport the following commits from \`main\` to \`7.x\`:
103
+ - [My commit message (#55)](https://github.com/backport-org/different-merge-strategies/pull/55)
104
+ - Another commit message (qwertyui)
105
+
106
+ <!--- Backport version: 1.2.3-mocked -->
107
+
108
+ ### Questions ?
109
+ Please refer to the [Backport tool documentation](https://github.com/sqren/backport)"
110
+ `);
111
+ });
112
+ it('when a PR is merged (instead of squashed) and the individual commits are selected', () => {
113
+ expect((0, createPullRequest_1.getPullRequestBody)({
114
+ options: {},
115
+ commits: [
116
+ {
117
+ sourceCommit: {
118
+ committedDate: '2022-02-07T23:53:14Z',
119
+ message: 'Merge strategy: Second commit',
120
+ sha: 'e8df5eaa4db7b94474b48e2320b02d33a830d9fb',
121
+ },
122
+ sourcePullRequest: {
123
+ number: 1,
124
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/1',
125
+ mergeCommit: {
126
+ message: 'Merge pull request #1 from backport-org/merge-strategy\n\nMerge commits to `main`',
127
+ sha: '0db7f1ac1233461563d8708511d1c14adbab46da',
128
+ },
129
+ },
130
+ sourceBranch: 'main',
131
+ expectedTargetPullRequests: [],
132
+ },
133
+ {
134
+ sourceCommit: {
135
+ committedDate: '2022-02-07T23:51:59Z',
136
+ message: 'Merge strategy: First commit',
137
+ sha: '5411b1c1144093e422220008f23f2c2b909ed113',
138
+ },
139
+ sourcePullRequest: {
140
+ number: 1,
141
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/1',
142
+ mergeCommit: {
143
+ message: 'Merge pull request #1 from backport-org/merge-strategy\n\nMerge commits to `main`',
144
+ sha: '0db7f1ac1233461563d8708511d1c14adbab46da',
145
+ },
146
+ },
147
+ sourceBranch: 'main',
148
+ expectedTargetPullRequests: [],
149
+ },
150
+ ],
151
+ targetBranch: '7.x',
152
+ })).toMatchInlineSnapshot(`
153
+ "# Backport
154
+
155
+ This will backport the following commits from \`main\` to \`7.x\`:
156
+ - [Merge strategy: Second commit](https://github.com/backport-org/different-merge-strategies/pull/1)
157
+ - [Merge strategy: First commit](https://github.com/backport-org/different-merge-strategies/pull/1)
158
+
159
+ <!--- Backport version: 1.2.3-mocked -->
160
+
161
+ ### Questions ?
162
+ Please refer to the [Backport tool documentation](https://github.com/sqren/backport)"
163
+ `);
164
+ });
165
+ it('replaces template variables in PR description', () => {
166
+ expect((0, createPullRequest_1.getPullRequestBody)({
167
+ options: {
168
+ prDescription: 'Backporting the following to {targetBranch}:\n{commitMessages}',
169
+ },
170
+ commits: [
171
+ {
172
+ sourcePullRequest: {
173
+ number: 55,
174
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
175
+ mergeCommit: {
176
+ sha: 'abcdefghijklm',
177
+ message: 'My commit message (#55)',
178
+ },
179
+ },
180
+ sourceCommit: {
181
+ committedDate: '',
182
+ sha: 'abcdefghijklm',
183
+ message: 'My commit message (#55)',
184
+ },
185
+ sourceBranch: 'main',
186
+ expectedTargetPullRequests: [],
187
+ },
188
+ {
189
+ sourceCommit: {
190
+ committedDate: '',
191
+ sha: 'qwertyuiop',
192
+ message: 'Another commit message',
193
+ },
194
+ sourceBranch: 'main',
195
+ expectedTargetPullRequests: [],
196
+ },
197
+ ],
198
+ targetBranch: '7.x',
199
+ })).toMatchInlineSnapshot(`
200
+ "Backporting the following to 7.x:
201
+ - [My commit message (#55)](https://github.com/backport-org/different-merge-strategies/pull/55)
202
+ - Another commit message (qwertyui)"
203
+ `);
204
+ });
205
+ it('appends text to the default descriptions', () => {
206
+ expect((0, createPullRequest_1.getPullRequestBody)({
207
+ options: {
208
+ prDescription: '{defaultPrDescription}\n\ntext to append',
209
+ },
210
+ commits: [
211
+ {
212
+ sourcePullRequest: {
213
+ number: 55,
214
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
215
+ mergeCommit: {
216
+ sha: 'abcdefghijklm',
217
+ message: 'My commit message (#55)',
218
+ },
219
+ },
220
+ sourceCommit: {
221
+ committedDate: '',
222
+ sha: 'abcdefghijklm',
223
+ message: 'My commit message (#55)',
224
+ },
225
+ sourceBranch: 'main',
226
+ expectedTargetPullRequests: [],
227
+ },
228
+ {
229
+ sourceCommit: {
230
+ committedDate: '',
231
+ sha: 'qwertyuiop',
232
+ message: 'Another commit message',
233
+ },
234
+ sourceBranch: 'main',
235
+ expectedTargetPullRequests: [],
236
+ },
237
+ ],
238
+ targetBranch: '7.x',
239
+ })).toMatchInlineSnapshot(`
240
+ "# Backport
241
+
242
+ This will backport the following commits from \`main\` to \`7.x\`:
243
+ - [My commit message (#55)](https://github.com/backport-org/different-merge-strategies/pull/55)
244
+ - Another commit message (qwertyui)
245
+
246
+ <!--- Backport version: 1.2.3-mocked -->
247
+
248
+ ### Questions ?
249
+ Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
250
+
251
+ text to append"
252
+ `);
253
+ });
254
+ });
255
+ describe('getTitle', () => {
256
+ it('has the default title', () => {
257
+ expect((0, createPullRequest_1.getTitle)({
258
+ options: {},
259
+ commits: [
260
+ {
261
+ sourceBranch: 'main',
262
+ sourcePullRequest: {
263
+ number: 55,
264
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
265
+ mergeCommit: {
266
+ sha: 'abcdefghi',
267
+ message: 'My commit message (#55)',
268
+ },
269
+ },
270
+ sourceCommit: {
271
+ committedDate: '2020',
272
+ sha: 'abcdefghi',
273
+ message: 'My commit message (#55)',
274
+ },
275
+ expectedTargetPullRequests: [],
276
+ },
277
+ {
278
+ sourcePullRequest: {
279
+ number: 56,
280
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/56',
281
+ mergeCommit: {
282
+ sha: 'jklmnopqr',
283
+ message: 'Another commit message (#56)',
284
+ },
285
+ },
286
+ sourceCommit: {
287
+ committedDate: '2020',
288
+ sha: 'jklmnopqr',
289
+ message: 'Another commit message (#56)',
290
+ },
291
+ sourceBranch: 'main',
292
+ expectedTargetPullRequests: [],
293
+ },
294
+ ],
295
+ targetBranch: '7.x',
296
+ })).toEqual('[7.x] My commit message (#55) | Another commit message (#56)');
297
+ });
298
+ it('replaces template variables in PR title', () => {
299
+ expect((0, createPullRequest_1.getTitle)({
300
+ options: {
301
+ prTitle: 'Branch: "{targetBranch}". Messages: {commitMessages}',
302
+ },
303
+ commits: [
304
+ {
305
+ sourcePullRequest: {
306
+ number: 55,
307
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
308
+ mergeCommit: {
309
+ sha: 'abcdefghi',
310
+ message: 'My commit message (#55)',
311
+ },
312
+ },
313
+ sourceCommit: {
314
+ committedDate: '',
315
+ sha: 'abcdefghi',
316
+ message: 'My commit message (#55)',
317
+ },
318
+ sourceBranch: 'main',
319
+ expectedTargetPullRequests: [],
320
+ },
321
+ ],
322
+ targetBranch: '7.x',
323
+ })).toEqual('Branch: "7.x". Messages: My commit message (#55)');
324
+ });
325
+ });