backport 9.6.4 → 9.6.6

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 (61) hide show
  1. package/dist/backportRun.d.ts +1 -1
  2. package/dist/backportRun.js +3 -1
  3. package/dist/backportRun.js.map +1 -1
  4. package/dist/entrypoint.api.d.ts +1 -1
  5. package/dist/entrypoint.module.private.test.js +5 -5
  6. package/dist/entrypoint.module.private.test.js.map +1 -1
  7. package/dist/lib/cherrypickAndCreateTargetPullRequest/cherrypickAndCreateTargetPullRequest.js +5 -3
  8. package/dist/lib/cherrypickAndCreateTargetPullRequest/cherrypickAndCreateTargetPullRequest.js.map +1 -1
  9. package/dist/lib/cherrypickAndCreateTargetPullRequest/getBackportBranchName.js +4 -2
  10. package/dist/lib/cherrypickAndCreateTargetPullRequest/getBackportBranchName.js.map +1 -1
  11. package/dist/lib/cherrypickAndCreateTargetPullRequest/getBackportBranchName.test.js +64 -17
  12. package/dist/lib/cherrypickAndCreateTargetPullRequest/getBackportBranchName.test.js.map +1 -1
  13. package/dist/lib/github/v3/getPullRequest/createPullRequest.d.ts +19 -0
  14. package/dist/lib/github/v3/getPullRequest/createPullRequest.js +68 -0
  15. package/dist/lib/github/v3/getPullRequest/createPullRequest.js.map +1 -0
  16. package/dist/lib/github/v3/getPullRequest/getPullRequestBody.d.ts +7 -0
  17. package/dist/lib/github/v3/getPullRequest/getPullRequestBody.js +64 -0
  18. package/dist/lib/github/v3/getPullRequest/getPullRequestBody.js.map +1 -0
  19. package/dist/lib/github/v3/getPullRequest/getPullRequestBody.test.js +447 -0
  20. package/dist/lib/github/v3/getPullRequest/getPullRequestBody.test.js.map +1 -0
  21. package/dist/lib/github/v3/getPullRequest/getTitle.d.ts +7 -0
  22. package/dist/lib/github/v3/getPullRequest/getTitle.js +34 -0
  23. package/dist/lib/github/v3/getPullRequest/getTitle.js.map +1 -0
  24. package/dist/lib/github/v3/getPullRequest/getTitle.test.d.ts +1 -0
  25. package/dist/lib/github/v3/getPullRequest/getTitle.test.js +111 -0
  26. package/dist/lib/github/v3/getPullRequest/getTitle.test.js.map +1 -0
  27. package/dist/lib/github/v4/enablePullRequestAutoMerge.mutation.test.js +1 -1
  28. package/dist/lib/github/v4/enablePullRequestAutoMerge.mutation.test.js.map +1 -1
  29. package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +1 -1
  30. package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js.map +1 -1
  31. package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.js +1 -1
  32. package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.js.map +1 -1
  33. package/dist/lib/github/v4/fetchExistingPullRequest.d.ts +1 -1
  34. package/dist/lib/registerHandlebarsHelpers.d.ts +1 -0
  35. package/dist/lib/registerHandlebarsHelpers.js +14 -0
  36. package/dist/lib/registerHandlebarsHelpers.js.map +1 -0
  37. package/dist/{runSequentially.d.ts → lib/runSequentially.d.ts} +3 -3
  38. package/dist/{runSequentially.js → lib/runSequentially.js} +5 -5
  39. package/dist/lib/runSequentially.js.map +1 -0
  40. package/dist/test/e2e/cli/different-merge-strategies.private.test.js +3 -13
  41. package/dist/test/e2e/cli/different-merge-strategies.private.test.js.map +1 -1
  42. package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.js +2 -9
  43. package/dist/test/e2e/cli/error-handling-interactive-mode.private.test.js.map +1 -1
  44. package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +1 -6
  45. package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js.map +1 -1
  46. package/dist/test/e2e/module/entrypoint.module.mutation.test.js +1 -1
  47. package/dist/test/replaceStringAndLinebreaks.d.ts +1 -0
  48. package/dist/test/replaceStringAndLinebreaks.js +7 -1
  49. package/dist/test/replaceStringAndLinebreaks.js.map +1 -1
  50. package/dist/test/setupFiles/automatic-mocks.js +2 -0
  51. package/dist/test/setupFiles/automatic-mocks.js.map +1 -1
  52. package/dist/utils/packageVersion.d.ts +1 -1
  53. package/dist/utils/packageVersion.js +1 -1
  54. package/package.json +2 -2
  55. package/dist/lib/github/v3/createPullRequest.d.ts +0 -30
  56. package/dist/lib/github/v3/createPullRequest.js +0 -123
  57. package/dist/lib/github/v3/createPullRequest.js.map +0 -1
  58. package/dist/lib/github/v3/createPullRequest.test.js +0 -527
  59. package/dist/lib/github/v3/createPullRequest.test.js.map +0 -1
  60. package/dist/runSequentially.js.map +0 -1
  61. /package/dist/lib/github/v3/{createPullRequest.test.d.ts → getPullRequest/getPullRequestBody.test.d.ts} +0 -0
@@ -0,0 +1,447 @@
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 handlebars_1 = __importDefault(require("handlebars"));
7
+ const getPullRequestBody_1 = require("./getPullRequestBody");
8
+ const commits = [
9
+ {
10
+ sourcePullRequest: {
11
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
12
+ },
13
+ sourceCommit: {
14
+ sha: 'acbcdef',
15
+ message: 'My commit message (#55)',
16
+ },
17
+ sourceBranch: 'main',
18
+ },
19
+ {
20
+ sourcePullRequest: {
21
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/56',
22
+ },
23
+ sourceCommit: {
24
+ sha: 'hijklmn',
25
+ message: 'Another commit message (#56)',
26
+ },
27
+ sourceBranch: 'main',
28
+ },
29
+ ];
30
+ describe('getPullRequestBody', () => {
31
+ describe('template variables should be replaced', () => {
32
+ describe('{{defaultPrDescription}}', () => {
33
+ it('replaces {{defaultPrDescription}}', () => {
34
+ const options = {
35
+ prDescription: '{{defaultPrDescription}}\n\ntext to append',
36
+ };
37
+ expect((0, getPullRequestBody_1.getPullRequestBody)({ options, commits, targetBranch: '7.x' }))
38
+ .toMatchInlineSnapshot(`
39
+ "# Backport
40
+
41
+ This will backport the following commits from \`main\` to \`7.x\`:
42
+ - [My commit message (#55)](https://github.com/backport-org/different-merge-strategies/pull/55)
43
+ - [Another commit message (#56)](https://github.com/backport-org/different-merge-strategies/pull/56)
44
+
45
+ <!--- Backport version: 1.2.3-mocked -->
46
+
47
+ ### Questions ?
48
+ Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)
49
+
50
+ text to append"
51
+ `);
52
+ });
53
+ it('replaces {defaultPrDescription} for legacy reasons', () => {
54
+ const options = {
55
+ prDescription: '{defaultPrDescription}\n\ntext to append',
56
+ };
57
+ expect((0, getPullRequestBody_1.getPullRequestBody)({ options, commits, targetBranch: '7.x' }))
58
+ .toMatchInlineSnapshot(`
59
+ "# Backport
60
+
61
+ This will backport the following commits from \`main\` to \`7.x\`:
62
+ - [My commit message (#55)](https://github.com/backport-org/different-merge-strategies/pull/55)
63
+ - [Another commit message (#56)](https://github.com/backport-org/different-merge-strategies/pull/56)
64
+
65
+ <!--- Backport version: 1.2.3-mocked -->
66
+
67
+ ### Questions ?
68
+ Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)
69
+
70
+ text to append"
71
+ `);
72
+ });
73
+ });
74
+ describe('{{commitsStringified}}', () => {
75
+ it('replaces {{commitsStringified}} with a stringifid JSON', () => {
76
+ const options = {
77
+ prDescription: 'Just output the commits: {{commitsStringified}}',
78
+ };
79
+ expect((0, getPullRequestBody_1.getPullRequestBody)({ options, commits, targetBranch: '7.x' })).toMatchInlineSnapshot(`"Just output the commits: [{"sourcePullRequest":{"url":"https://github.com/backport-org/different-merge-strategies/pull/55"},"sourceCommit":{"sha":"acbcdef","message":"My commit message (#55)"},"sourceBranch":"main"},{"sourcePullRequest":{"url":"https://github.com/backport-org/different-merge-strategies/pull/56"},"sourceCommit":{"sha":"hijklmn","message":"Another commit message (#56)"},"sourceBranch":"main"}]"`);
80
+ });
81
+ it('replaces {commits} for legacy reasons', () => {
82
+ const options = {
83
+ prDescription: 'Just output the commits: {commits}',
84
+ };
85
+ expect((0, getPullRequestBody_1.getPullRequestBody)({ options, commits, targetBranch: '7.x' })).toMatchInlineSnapshot(`"Just output the commits: [{"sourcePullRequest":{"url":"https://github.com/backport-org/different-merge-strategies/pull/55"},"sourceCommit":{"sha":"acbcdef","message":"My commit message (#55)"},"sourceBranch":"main"},{"sourcePullRequest":{"url":"https://github.com/backport-org/different-merge-strategies/pull/56"},"sourceCommit":{"sha":"hijklmn","message":"Another commit message (#56)"},"sourceBranch":"main"}]"`);
86
+ });
87
+ it('strips markdown comments', () => {
88
+ const commits = [
89
+ {
90
+ sourcePullRequest: {
91
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
92
+ },
93
+ sourceCommit: {
94
+ sha: 'acbcdef',
95
+ message: 'My commit message (#55) <!-- markdown-comment --> And then some more text',
96
+ },
97
+ sourceBranch: 'main',
98
+ },
99
+ ];
100
+ const options = {
101
+ prDescription: 'Just output the commits: {commits}',
102
+ };
103
+ const res = (0, getPullRequestBody_1.getPullRequestBody)({
104
+ options,
105
+ commits,
106
+ targetBranch: '7.x',
107
+ });
108
+ expect(res).not.toContain('markdown-comment');
109
+ expect(res).not.toContain('<!--');
110
+ expect(res).not.toContain('-->');
111
+ expect(res).toContain('My commit message (#55) And then some more text');
112
+ });
113
+ it('handles curly brackets in commit messages without error', () => {
114
+ const commits = [
115
+ {
116
+ sourceCommit: {
117
+ message: "This is a commit message\nThis is a description with illegal brackets ```\r\nmetadata={{\r\n extraActionsColor: 'text',\r\n }}\r\n```",
118
+ sha: 'mySha',
119
+ },
120
+ sourceBranch: 'main',
121
+ },
122
+ ];
123
+ const options = {
124
+ prDescription: '{defaultPrDescription}\n\n<!--BACKPORT {commits} BACKPORT-->',
125
+ };
126
+ expect((0, getPullRequestBody_1.getPullRequestBody)({ options, commits, targetBranch: '9.0' }))
127
+ .toMatchInlineSnapshot(`
128
+ "# Backport
129
+
130
+ This will backport the following commits from \`main\` to \`9.0\`:
131
+ - This is a commit message (mySha)
132
+
133
+ <!--- Backport version: 1.2.3-mocked -->
134
+
135
+ ### Questions ?
136
+ Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)
137
+
138
+ <!--BACKPORT [{"sourceCommit":{"message":"This is a commit message\\nThis is a description with illegal brackets \`\`\`\\r\\nmetadata={{\\r\\n extraActionsColor: 'text',\\r\\n }}\\r\\n\`\`\`","sha":"mySha"},"sourceBranch":"main"}] BACKPORT-->"
139
+ `);
140
+ });
141
+ });
142
+ describe('{{commitMessages}}', () => {
143
+ it('replaces {{commitMessages}}', () => {
144
+ const options = {
145
+ prDescription: '{{commitMessages}}',
146
+ };
147
+ expect((0, getPullRequestBody_1.getPullRequestBody)({ options, commits, targetBranch: '7.x' }))
148
+ .toMatchInlineSnapshot(`
149
+ " - [My commit message (#55)](https://github.com/backport-org/different-merge-strategies/pull/55)
150
+ - [Another commit message (#56)](https://github.com/backport-org/different-merge-strategies/pull/56)"
151
+ `);
152
+ });
153
+ it('replaces {{commitMessages}} in default PR description', () => {
154
+ const options = {};
155
+ expect((0, getPullRequestBody_1.getPullRequestBody)({ options, commits, targetBranch: '7.x' }))
156
+ .toMatchInlineSnapshot(`
157
+ "# Backport
158
+
159
+ This will backport the following commits from \`main\` to \`7.x\`:
160
+ - [My commit message (#55)](https://github.com/backport-org/different-merge-strategies/pull/55)
161
+ - [Another commit message (#56)](https://github.com/backport-org/different-merge-strategies/pull/56)
162
+
163
+ <!--- Backport version: 1.2.3-mocked -->
164
+
165
+ ### Questions ?
166
+ Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)"
167
+ `);
168
+ });
169
+ it('handles curly brackets in commit message without error', () => {
170
+ const commits = [
171
+ {
172
+ sourceCommit: {
173
+ message: "```metadata={{ extraActionsColor: 'text',\r\n }}\r\n```",
174
+ sha: 'mySha',
175
+ },
176
+ sourceBranch: 'main',
177
+ },
178
+ ];
179
+ const options = {
180
+ prDescription: '{defaultPrDescription}\n\n<!--BACKPORT {commits} BACKPORT-->',
181
+ };
182
+ expect((0, getPullRequestBody_1.getPullRequestBody)({ options, commits, targetBranch: '9.0' }))
183
+ .toMatchInlineSnapshot(`
184
+ "# Backport
185
+
186
+ This will backport the following commits from \`main\` to \`9.0\`:
187
+ - \`\`\`metadata={{ extraActionsColor: 'text',
188
+ (mySha)
189
+
190
+ <!--- Backport version: 1.2.3-mocked -->
191
+
192
+ ### Questions ?
193
+ Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)
194
+
195
+ <!--BACKPORT [{"sourceCommit":{"message":"\`\`\`metadata={{ extraActionsColor: 'text',\\r\\n }}\\r\\n\`\`\`","sha":"mySha"},"sourceBranch":"main"}] BACKPORT-->"
196
+ `);
197
+ });
198
+ });
199
+ describe('{{packageVersion}}', () => {
200
+ it('replaces {{PACKAGE_VERSION}}', () => {
201
+ const body = (0, getPullRequestBody_1.getPullRequestBody)({
202
+ options: {},
203
+ commits,
204
+ targetBranch: 'release',
205
+ });
206
+ expect(body).toContain('Backport version: 1.2.3-mocked');
207
+ });
208
+ });
209
+ describe('{{commits}}', () => {
210
+ it('should render commits using Handlebars #each helper', () => {
211
+ const options = {
212
+ prDescription: '{{#each commits}} - {{shortSha this.sourceCommit.sha}} {{this.sourceCommit.message}}\n{{/each}}',
213
+ };
214
+ expect((0, getPullRequestBody_1.getPullRequestBody)({ options, commits, targetBranch: '7.x' }))
215
+ .toMatchInlineSnapshot(`
216
+ " - acbcdef My commit message (#55)
217
+ - hijklmn Another commit message (#56)
218
+ "
219
+ `);
220
+ });
221
+ it('should handle curly brackets in commits message', () => {
222
+ const commits = [
223
+ {
224
+ sourceCommit: {
225
+ message: "This is a commit message\nThis is a description with illegal brackets ```\r\nmetadata={{\r\n extraActionsColor: 'text',\r\n }}\r\n```",
226
+ sha: 'mySha',
227
+ },
228
+ sourceBranch: 'main',
229
+ },
230
+ ];
231
+ const options = {
232
+ prDescription: '{{#each commits}} - {{shortSha this.sourceCommit.sha}} {{this.sourceCommit.message}}\n{{/each}}',
233
+ };
234
+ expect((0, getPullRequestBody_1.getPullRequestBody)({ options, commits, targetBranch: '7.x' }))
235
+ .toMatchInlineSnapshot(`
236
+ " - mySha This is a commit message
237
+ This is a description with illegal brackets \`\`\`
238
+ metadata={{
239
+ extraActionsColor: 'text',
240
+ }}
241
+ \`\`\`
242
+ "
243
+ `);
244
+ });
245
+ });
246
+ });
247
+ describe('custom templates', () => {
248
+ it('should support prodfiler team format', () => {
249
+ const commits = [
250
+ {
251
+ sourceCommit: {
252
+ sha: '9e42503a7d0e06e60c575ed2c3b7dc3e5df0dd5c',
253
+ message: 'My commit message (#55)',
254
+ },
255
+ sourcePullRequest: {
256
+ number: 123,
257
+ title: 'Original PR title',
258
+ },
259
+ },
260
+ {
261
+ sourceCommit: {
262
+ sha: '5ce6c3fb9525426d66a85eba057e1214f5f52995',
263
+ message: 'Another commit message',
264
+ },
265
+ },
266
+ ];
267
+ const options = {
268
+ prDescription: `Backport #{{commits.0.sourcePullRequest.number}}: {{commits.0.sourcePullRequest.title}}
269
+
270
+ {{#each commits}}{{shortSha this.sourceCommit.sha}} {{this.sourceCommit.message}}\n{{/each}}`,
271
+ };
272
+ expect((0, getPullRequestBody_1.getPullRequestBody)({ options, commits, targetBranch: '7.x' }))
273
+ .toMatchInlineSnapshot(`
274
+ "Backport #123: Original PR title
275
+
276
+ 9e42503a My commit message (#55)
277
+ 5ce6c3fb Another commit message
278
+ "
279
+ `);
280
+ });
281
+ });
282
+ describe('commit message formatting', () => {
283
+ it('when single pull request is backported', () => {
284
+ expect((0, getPullRequestBody_1.getPullRequestBody)({
285
+ options: {},
286
+ commits: [
287
+ {
288
+ sourcePullRequest: {
289
+ title: 'My PR Title',
290
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
291
+ },
292
+ sourceCommit: {
293
+ sha: 'abcdefghi',
294
+ message: 'My commit message (#55)',
295
+ },
296
+ sourceBranch: 'master',
297
+ },
298
+ ],
299
+ targetBranch: '7.x',
300
+ })).toMatchInlineSnapshot(`
301
+ "# Backport
302
+
303
+ This will backport the following commits from \`master\` to \`7.x\`:
304
+ - [My commit message (#55)](https://github.com/backport-org/different-merge-strategies/pull/55)
305
+
306
+ <!--- Backport version: 1.2.3-mocked -->
307
+
308
+ ### Questions ?
309
+ Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)"
310
+ `);
311
+ });
312
+ it('when a single commit (non pull request) is backported', () => {
313
+ expect((0, getPullRequestBody_1.getPullRequestBody)({
314
+ options: {},
315
+ commits: [
316
+ {
317
+ sourceCommit: {
318
+ sha: 'abcdefghijklmw',
319
+ message: 'My commit message',
320
+ },
321
+ sourceBranch: 'main',
322
+ },
323
+ ],
324
+ targetBranch: '7.x',
325
+ })).toMatchInlineSnapshot(`
326
+ "# Backport
327
+
328
+ This will backport the following commits from \`main\` to \`7.x\`:
329
+ - My commit message (abcdefgh)
330
+
331
+ <!--- Backport version: 1.2.3-mocked -->
332
+
333
+ ### Questions ?
334
+ Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)"
335
+ `);
336
+ });
337
+ it('when multiple commits are backported', () => {
338
+ expect((0, getPullRequestBody_1.getPullRequestBody)({
339
+ options: {},
340
+ commits: [
341
+ {
342
+ sourcePullRequest: {
343
+ number: 55,
344
+ title: 'My PR Title',
345
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
346
+ },
347
+ sourceCommit: {
348
+ sha: 'abcdefghijklm',
349
+ message: 'My commit message (#55)',
350
+ },
351
+ sourceBranch: 'main',
352
+ },
353
+ {
354
+ sourceCommit: {
355
+ sha: 'qwertyuiop',
356
+ message: 'Another commit message',
357
+ },
358
+ sourceBranch: 'main',
359
+ },
360
+ ],
361
+ targetBranch: '7.x',
362
+ })).toMatchInlineSnapshot(`
363
+ "# Backport
364
+
365
+ This will backport the following commits from \`main\` to \`7.x\`:
366
+ - [My commit message (#55)](https://github.com/backport-org/different-merge-strategies/pull/55)
367
+ - Another commit message (qwertyui)
368
+
369
+ <!--- Backport version: 1.2.3-mocked -->
370
+
371
+ ### Questions ?
372
+ Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)"
373
+ `);
374
+ });
375
+ it('when a PR is merged (instead of squashed) and the individual commits are selected', () => {
376
+ expect((0, getPullRequestBody_1.getPullRequestBody)({
377
+ options: {},
378
+ commits: [
379
+ {
380
+ sourceCommit: {
381
+ message: 'Merge strategy: Second commit',
382
+ sha: 'e8df5eaa4db7b94474b48e2320b02d33a830d9fb',
383
+ },
384
+ sourcePullRequest: {
385
+ number: 1,
386
+ title: 'My PR Title',
387
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/1',
388
+ },
389
+ sourceBranch: 'main',
390
+ },
391
+ {
392
+ sourceCommit: {
393
+ message: 'Merge strategy: First commit',
394
+ sha: '5411b1c1144093e422220008f23f2c2b909ed113',
395
+ },
396
+ sourcePullRequest: {
397
+ number: 1,
398
+ title: 'My PR Title',
399
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/1',
400
+ },
401
+ sourceBranch: 'main',
402
+ },
403
+ ],
404
+ targetBranch: '7.x',
405
+ })).toMatchInlineSnapshot(`
406
+ "# Backport
407
+
408
+ This will backport the following commits from \`main\` to \`7.x\`:
409
+ - [Merge strategy: Second commit](https://github.com/backport-org/different-merge-strategies/pull/1)
410
+ - [Merge strategy: First commit](https://github.com/backport-org/different-merge-strategies/pull/1)
411
+
412
+ <!--- Backport version: 1.2.3-mocked -->
413
+
414
+ ### Questions ?
415
+ Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)"
416
+ `);
417
+ });
418
+ });
419
+ describe('handlebars', () => {
420
+ it('should return default description if handlebars compilation fails', () => {
421
+ const compileError = new Error('Simulated compile error');
422
+ // Stub Handlebars.compile to throw an error.
423
+ const compileSpy = jest
424
+ .spyOn(handlebars_1.default, 'compile')
425
+ .mockImplementation(() => {
426
+ throw compileError;
427
+ });
428
+ const options = {};
429
+ expect((0, getPullRequestBody_1.getPullRequestBody)({ options, commits, targetBranch: '7.x' }))
430
+ .toMatchInlineSnapshot(`
431
+ "# Backport
432
+
433
+ This will backport the following commits from \`main\` to \`7.x\`:
434
+ - [My commit message (#55)](https://github.com/backport-org/different-merge-strategies/pull/55)
435
+ - [Another commit message (#56)](https://github.com/backport-org/different-merge-strategies/pull/56)
436
+
437
+ <!--- Backport version: 1.2.3-mocked -->
438
+
439
+ ### Questions ?
440
+ Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)"
441
+ `);
442
+ // Restore the stubs.
443
+ compileSpy.mockRestore();
444
+ });
445
+ });
446
+ });
447
+ //# sourceMappingURL=getPullRequestBody.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPullRequestBody.test.js","sourceRoot":"","sources":["../../../../../src/lib/github/v3/getPullRequest/getPullRequestBody.test.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AAGpC,6DAA0D;AAE1D,MAAM,OAAO,GAAG;IACd;QACE,iBAAiB,EAAE;YACjB,GAAG,EAAE,oEAAoE;SAC1E;QACD,YAAY,EAAE;YACZ,GAAG,EAAE,SAAS;YACd,OAAO,EAAE,yBAAyB;SACnC;QACD,YAAY,EAAE,MAAM;KACrB;IACD;QACE,iBAAiB,EAAE;YACjB,GAAG,EAAE,oEAAoE;SAC1E;QACD,YAAY,EAAE;YACZ,GAAG,EAAE,SAAS;YACd,OAAO,EAAE,8BAA8B;SACxC;QACD,YAAY,EAAE,MAAM;KACrB;CACU,CAAC;AAEd,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,QAAQ,CAAC,uCAAuC,EAAE,GAAG,EAAE;QACrD,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;YACxC,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;gBAC3C,MAAM,OAAO,GAAG;oBACd,aAAa,EAAE,4CAA4C;iBACtC,CAAC;gBAExB,MAAM,CAAC,IAAA,uCAAkB,EAAC,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;qBAClE,qBAAqB,CAAC;;;;;;;;;;;;;CAahC,CAAC,CAAC;YACG,C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A6C;YAC7C,MAAM,UAAU,GAAG,IAAI;iBACpB,KAAK,CAAC,oBAAU,EAAE,SAAS,CAAC;iBAC5B,kBAAkB,CAAC,GAAG,EAAE;gBACvB,MAAM,YAAY,CAAC;YACrB,CAAC,CAAC,CAAC;YAEL,MAAM,OAAO,GAAG,EAAwB,CAAC;YAEzC,MAAM,CAAC,IAAA,uCAAkB,EAAC,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;iBAClE,qBAAqB,CAAC;;;;;;;;;;;CAW9B,CAAC,CAAC;YAEG,qBAAqB;YACrB,UAAU,CAAC,WAAW,EAAE,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { ValidConfigOptions } from '../../../../options/options';
2
+ import { Commit } from '../../../sourceCommit/parseSourceCommit';
3
+ export declare function getTitle({ options, commits, targetBranch, }: {
4
+ options: ValidConfigOptions;
5
+ commits: Commit[];
6
+ targetBranch: string;
7
+ }): string;
@@ -0,0 +1,34 @@
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.getTitle = void 0;
7
+ const handlebars_1 = __importDefault(require("handlebars"));
8
+ const getSourceBranchFromCommits_1 = require("../../../getSourceBranchFromCommits");
9
+ const logger_1 = require("../../../logger");
10
+ const commitFormatters_1 = require("../../commitFormatters");
11
+ function getTitle({ options, commits, targetBranch, }) {
12
+ const sourceBranch = (0, getSourceBranchFromCommits_1.getSourceBranchFromCommits)(commits);
13
+ const commitMessages = commits
14
+ .map((c) => (0, commitFormatters_1.getFirstLine)(c.sourceCommit.message))
15
+ .join(' | ');
16
+ const defaultPrTitle = '[{{targetBranch}}] {{commitMessages}}';
17
+ const prTitle = (options.prTitle ?? defaultPrTitle)
18
+ .replaceAll('{{commitMessages}}', `{{{{raw}}}}${commitMessages}{{{{/raw}}}}`)
19
+ .replaceAll('{{targetBranch}}', targetBranch)
20
+ .replaceAll('{{sourceBranch}}', sourceBranch);
21
+ try {
22
+ const template = handlebars_1.default.compile(prTitle, { noEscape: true });
23
+ return template({
24
+ sourcePullRequest: commits[0].sourcePullRequest, // assume that all commits are from the same PR
25
+ commits,
26
+ });
27
+ }
28
+ catch (error) {
29
+ logger_1.logger.error('Error while compiling PR title template', error);
30
+ return prTitle.replaceAll('{{{{raw}}}}', '').replaceAll('{{{{/raw}}}}', '');
31
+ }
32
+ }
33
+ exports.getTitle = getTitle;
34
+ //# sourceMappingURL=getTitle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTitle.js","sourceRoot":"","sources":["../../../../../src/lib/github/v3/getPullRequest/getTitle.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAoC;AAEpC,oFAAiF;AACjF,4CAAyC;AAEzC,6DAAsD;AAEtD,SAAgB,QAAQ,CAAC,EACvB,OAAO,EACP,OAAO,EACP,YAAY,GAKb;IACC,MAAM,YAAY,GAAG,IAAA,uDAA0B,EAAC,OAAO,CAAC,CAAC;IACzD,MAAM,cAAc,GAAG,OAAO;SAC3B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,+BAAY,EAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;SAChD,IAAI,CAAC,KAAK,CAAC,CAAC;IAEf,MAAM,cAAc,GAAG,uCAAuC,CAAC;IAE/D,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,cAAc,CAAC;SAChD,UAAU,CACT,oBAAoB,EACpB,cAAc,cAAc,cAAc,CAC3C;SACA,UAAU,CAAC,kBAAkB,EAAE,YAAY,CAAC;SAC5C,UAAU,CAAC,kBAAkB,EAAE,YAAY,CAAC,CAAC;IAEhD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,oBAAU,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,OAAO,QAAQ,CAAC;YACd,iBAAiB,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,+CAA+C;YAChG,OAAO;SACR,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,eAAM,CAAC,KAAK,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAAC;QAC/D,OAAO,OAAO,CAAC,UAAU,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC;AAlCD,4BAkCC"}
@@ -0,0 +1,111 @@
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 handlebars_1 = __importDefault(require("handlebars"));
7
+ const getTitle_1 = require("./getTitle");
8
+ describe('getTitle', () => {
9
+ const commits = [
10
+ {
11
+ sourceBranch: 'main',
12
+ sourcePullRequest: {
13
+ title: 'My PR Title',
14
+ number: 55,
15
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
16
+ },
17
+ sourceCommit: {
18
+ sha: 'abcdefghi',
19
+ message: 'My commit message (#55)',
20
+ },
21
+ },
22
+ {
23
+ sourcePullRequest: {
24
+ number: 56,
25
+ title: 'My PR Title',
26
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/56',
27
+ },
28
+ sourceCommit: {
29
+ sha: 'jklmnopqr',
30
+ message: 'Another commit message (#56)',
31
+ },
32
+ sourceBranch: 'main',
33
+ },
34
+ ];
35
+ it('has the default title', () => {
36
+ const options = {};
37
+ expect((0, getTitle_1.getTitle)({ options, commits, targetBranch: '7.x' })).toEqual('[7.x] My commit message (#55) | Another commit message (#56)');
38
+ });
39
+ it('renders title with the original PR title', () => {
40
+ const options = {
41
+ prTitle: '[{{targetBranch}}] {{sourcePullRequest.title}}',
42
+ };
43
+ expect((0, getTitle_1.getTitle)({ options, commits, targetBranch: '7.x' })).toEqual('[7.x] My PR Title');
44
+ });
45
+ it('renders title using a specific commit', () => {
46
+ const options = {
47
+ prTitle: '[{{targetBranch}}] {{commits.0.sourcePullRequest.title}}',
48
+ };
49
+ expect((0, getTitle_1.getTitle)({ options, commits, targetBranch: '7.x' })).toEqual('[7.x] My PR Title');
50
+ });
51
+ it('renders title using {{commitMessages}}', () => {
52
+ const options = {
53
+ prTitle: 'Branch: "{{targetBranch}}". Messages: {{commitMessages}}',
54
+ };
55
+ expect((0, getTitle_1.getTitle)({ options, commits, targetBranch: '7.x' })).toEqual('Branch: "7.x". Messages: My commit message (#55) | Another commit message (#56)');
56
+ });
57
+ it('support backticks', () => {
58
+ const options = {
59
+ prTitle: '[{{targetBranch}}] {{commitMessages}}',
60
+ };
61
+ const commits = [
62
+ {
63
+ sourceBranch: 'main',
64
+ sourcePullRequest: {
65
+ title: 'My PR Title',
66
+ number: 55,
67
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
68
+ },
69
+ sourceCommit: {
70
+ sha: 'abcdefghi',
71
+ message: 'My commit message with `backticks` (#55)',
72
+ },
73
+ },
74
+ ];
75
+ expect((0, getTitle_1.getTitle)({ options, commits, targetBranch: '7.x' })).toEqual('[7.x] My commit message with `backticks` (#55)');
76
+ });
77
+ it('does not break on curly brackets', () => {
78
+ const options = {
79
+ prTitle: '[{{targetBranch}}] {{commitMessages}}',
80
+ };
81
+ const commits = [
82
+ {
83
+ sourceBranch: 'main',
84
+ sourcePullRequest: {
85
+ title: 'My PR Title',
86
+ number: 55,
87
+ url: 'https://github.com/backport-org/different-merge-strategies/pull/55',
88
+ },
89
+ sourceCommit: {
90
+ sha: 'abcdefghi',
91
+ message: "```metadata={{ extraActionsColor: 'text',\r\n }}\r\n```",
92
+ },
93
+ },
94
+ ];
95
+ expect(() => (0, getTitle_1.getTitle)({ options, commits, targetBranch: '7.x' })).not.toThrow();
96
+ });
97
+ it('should return default description if handlebars compilation fails', () => {
98
+ const compileError = new Error('Simulated compile error');
99
+ // Stub Handlebars.compile to throw an error.
100
+ const compileSpy = jest
101
+ .spyOn(handlebars_1.default, 'compile')
102
+ .mockImplementation(() => {
103
+ throw compileError;
104
+ });
105
+ const options = {};
106
+ expect((0, getTitle_1.getTitle)({ options, commits, targetBranch: '7.x' })).toMatchInlineSnapshot(`"[7.x] My commit message (#55) | Another commit message (#56)"`);
107
+ // Restore the stubs.
108
+ compileSpy.mockRestore();
109
+ });
110
+ });
111
+ //# sourceMappingURL=getTitle.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTitle.test.js","sourceRoot":"","sources":["../../../../../src/lib/github/v3/getPullRequest/getTitle.test.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AAGpC,yCAAsC;AAEtC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,MAAM,OAAO,GAAG;QACd;YACE,YAAY,EAAE,MAAM;YACpB,iBAAiB,EAAE;gBACjB,KAAK,EAAE,aAAa;gBACpB,MAAM,EAAE,EAAE;gBACV,GAAG,EAAE,oEAAoE;aAC1E;YACD,YAAY,EAAE;gBACZ,GAAG,EAAE,WAAW;gBAChB,OAAO,EAAE,yBAAyB;aACnC;SACF;QACD;YACE,iBAAiB,EAAE;gBACjB,MAAM,EAAE,EAAE;gBACV,KAAK,EAAE,aAAa;gBACpB,GAAG,EAAE,oEAAoE;aAC1E;YACD,YAAY,EAAE;gBACZ,GAAG,EAAE,WAAW;gBAChB,OAAO,EAAE,8BAA8B;aACxC;YACD,YAAY,EAAE,MAAM;SACrB;KACU,CAAC;IAEd,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,MAAM,OAAO,GAAG,EAAwB,CAAC;QACzC,MAAM,CAAC,IAAA,mBAAQ,EAAC,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK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UAAU,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const crypto_1 = __importDefault(require("crypto"));
7
7
  const rest_1 = require("@octokit/rest");
8
8
  const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
9
- const createPullRequest_1 = require("../v3/createPullRequest");
9
+ const createPullRequest_1 = require("../v3/getPullRequest/createPullRequest");
10
10
  const disablePullRequestAutoMerge_1 = require("./disablePullRequestAutoMerge");
11
11
  const enablePullRequestAutoMerge_1 = require("./enablePullRequestAutoMerge");
12
12
  const fetchPullRequestAutoMergeMethod_1 = require("./fetchPullRequestAutoMergeMethod");