backport 8.6.2 → 8.7.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.
- package/dist/entrypoint.module.private.test.js +78 -52
- package/dist/lib/{cherrypickAndCreateTargetPullRequest.d.ts → cherrypickAndCreateTargetPullRequest/cherrypickAndCreateTargetPullRequest.d.ts} +2 -2
- package/dist/lib/cherrypickAndCreateTargetPullRequest/cherrypickAndCreateTargetPullRequest.js +98 -0
- package/dist/lib/{cherrypickAndCreateTargetPullRequest.test.d.ts → cherrypickAndCreateTargetPullRequest/cherrypickAndCreateTargetPullRequest.test.d.ts} +0 -0
- package/dist/lib/{cherrypickAndCreateTargetPullRequest.test.js → cherrypickAndCreateTargetPullRequest/cherrypickAndCreateTargetPullRequest.test.js} +12 -10
- package/dist/lib/cherrypickAndCreateTargetPullRequest/getBackportBranchName.d.ts +2 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest/getBackportBranchName.js +22 -0
- package/dist/lib/{getCommitsWithoutBackports.d.ts → cherrypickAndCreateTargetPullRequest/getCommitsWithoutBackports.d.ts} +2 -2
- package/dist/lib/{getCommitsWithoutBackports.js → cherrypickAndCreateTargetPullRequest/getCommitsWithoutBackports.js} +6 -6
- package/dist/lib/{getCommitsWithoutBackports.test.d.ts → cherrypickAndCreateTargetPullRequest/getCommitsWithoutBackports.test.d.ts} +0 -0
- package/dist/lib/{getCommitsWithoutBackports.test.js → cherrypickAndCreateTargetPullRequest/getCommitsWithoutBackports.test.js} +24 -17
- package/dist/lib/cherrypickAndCreateTargetPullRequest/getMergeCommit.d.ts +3 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest/getMergeCommit.js +17 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels.d.ts +7 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels.js +33 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels.test.d.ts +1 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest/getTargetPRLabels.test.js +166 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest/waitForCherrypick.d.ts +3 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest/waitForCherrypick.js +154 -0
- package/dist/lib/getSourceBranchFromCommits.d.ts +2 -0
- package/dist/lib/getSourceBranchFromCommits.js +10 -0
- package/dist/lib/getTargetBranches.js +2 -3
- package/dist/lib/getTargetBranches.test.js +6 -4
- package/dist/lib/git.test.js +1 -1
- package/dist/lib/github/v3/addAssigneesToPullRequest.d.ts +11 -2
- package/dist/lib/github/v3/addAssigneesToPullRequest.js +9 -1
- package/dist/lib/github/v3/addAssigneesToPullRequest.test.js +5 -2
- package/dist/lib/github/v3/addLabelsToPullRequest.d.ts +10 -2
- package/dist/lib/github/v3/addLabelsToPullRequest.js +5 -1
- package/dist/lib/github/v3/addReviewersToPullRequest.d.ts +1 -1
- package/dist/lib/github/v3/addReviewersToPullRequest.js +5 -1
- package/dist/lib/github/v3/createPullRequest.js +7 -1
- package/dist/lib/github/v3/createPullRequest.test.js +22 -13
- package/dist/lib/github/v3/createStatusComment.test.js +4 -2
- package/dist/lib/github/v4/enablePullRequestAutoMerge.js +4 -0
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +10 -1
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +5 -1
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.js +3 -1
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +10 -4
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +7 -5
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +8 -2
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +6 -5
- package/dist/lib/prompt.test.js +14 -6
- package/dist/lib/prompts.js +2 -2
- package/dist/lib/sourceCommit/getPullRequestStates.d.ts +3 -2
- package/dist/lib/sourceCommit/getPullRequestStates.js +13 -20
- package/dist/lib/sourceCommit/getPullRequestStates.test.js +69 -28
- package/dist/lib/sourceCommit/parseSourceCommit.d.ts +2 -1
- package/dist/lib/sourceCommit/parseSourceCommit.js +15 -7
- package/dist/lib/sourceCommit/parseSourceCommit.test.js +15 -4
- package/dist/runSequentially.js +5 -5
- package/dist/test/e2e/cli/different-merge-strategies.private.test.js +6 -2
- package/dist/test/e2e/cli/gracefully-handles-corrupt-repo.private.test.js +5 -1
- package/dist/test/e2e/cli/repo-with-changing-branchLabelMapping.private.test.js +2 -2
- package/dist/test/e2e/cli/repo-with-programatically-added-commits.mutation.test.js +1 -1
- package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +6 -2
- package/dist/test/e2e/module/entrypoint.module.mutation.test.js +4 -4
- package/dist/test/handleUnbackportedPullRequests.private.test.js +3 -1
- package/dist/utils/filterUnmergedCommits.js +1 -1
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +7 -7
- package/yarn.lock +75 -75
- package/dist/lib/cherrypickAndCreateTargetPullRequest.js +0 -255
|
@@ -67,11 +67,11 @@ describe('getPullRequestStates', () => {
|
|
|
67
67
|
},
|
|
68
68
|
],
|
|
69
69
|
});
|
|
70
|
-
const
|
|
70
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
71
71
|
sourceCommit: mockSourceCommit,
|
|
72
72
|
branchLabelMapping: {},
|
|
73
73
|
});
|
|
74
|
-
expect(
|
|
74
|
+
expect(targetPullRequestStates).toEqual([]);
|
|
75
75
|
});
|
|
76
76
|
it('should return empty when repoOwner does not match', () => {
|
|
77
77
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
@@ -87,11 +87,11 @@ describe('getPullRequestStates', () => {
|
|
|
87
87
|
},
|
|
88
88
|
],
|
|
89
89
|
});
|
|
90
|
-
const
|
|
90
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
91
91
|
sourceCommit: mockSourceCommit,
|
|
92
92
|
branchLabelMapping: {},
|
|
93
93
|
});
|
|
94
|
-
expect(
|
|
94
|
+
expect(targetPullRequestStates).toEqual([]);
|
|
95
95
|
});
|
|
96
96
|
it('should return empty when commit messages do not match', () => {
|
|
97
97
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
@@ -106,11 +106,11 @@ describe('getPullRequestStates', () => {
|
|
|
106
106
|
},
|
|
107
107
|
],
|
|
108
108
|
});
|
|
109
|
-
const
|
|
109
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
110
110
|
sourceCommit: mockSourceCommit,
|
|
111
111
|
branchLabelMapping: {},
|
|
112
112
|
});
|
|
113
|
-
expect(
|
|
113
|
+
expect(targetPullRequestStates).toEqual([]);
|
|
114
114
|
});
|
|
115
115
|
it('should return a result if commits messages are different but title includes message and number', () => {
|
|
116
116
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
@@ -126,11 +126,11 @@ describe('getPullRequestStates', () => {
|
|
|
126
126
|
},
|
|
127
127
|
],
|
|
128
128
|
});
|
|
129
|
-
const
|
|
129
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
130
130
|
sourceCommit: mockSourceCommit,
|
|
131
131
|
branchLabelMapping: {},
|
|
132
132
|
});
|
|
133
|
-
expect(
|
|
133
|
+
expect(targetPullRequestStates).toEqual([
|
|
134
134
|
{
|
|
135
135
|
branch: '6.x',
|
|
136
136
|
state: 'MERGED',
|
|
@@ -157,11 +157,11 @@ describe('getPullRequestStates', () => {
|
|
|
157
157
|
},
|
|
158
158
|
],
|
|
159
159
|
});
|
|
160
|
-
const
|
|
160
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
161
161
|
sourceCommit: mockSourceCommit,
|
|
162
162
|
branchLabelMapping: {},
|
|
163
163
|
});
|
|
164
|
-
expect(
|
|
164
|
+
expect(targetPullRequestStates).toEqual([]);
|
|
165
165
|
});
|
|
166
166
|
it('should return a result when first line of a multiline commit message matches', () => {
|
|
167
167
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
@@ -176,11 +176,11 @@ describe('getPullRequestStates', () => {
|
|
|
176
176
|
},
|
|
177
177
|
],
|
|
178
178
|
});
|
|
179
|
-
const
|
|
179
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
180
180
|
sourceCommit: mockSourceCommit,
|
|
181
181
|
branchLabelMapping: {},
|
|
182
182
|
});
|
|
183
|
-
expect(
|
|
183
|
+
expect(targetPullRequestStates).toEqual([
|
|
184
184
|
{
|
|
185
185
|
branch: '6.x',
|
|
186
186
|
state: 'MERGED',
|
|
@@ -206,21 +206,23 @@ describe('getPullRequestStates', () => {
|
|
|
206
206
|
'v8.0.0': 'master',
|
|
207
207
|
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
208
208
|
};
|
|
209
|
-
const
|
|
209
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
210
210
|
sourceCommit: mockSourceCommit,
|
|
211
211
|
branchLabelMapping,
|
|
212
212
|
});
|
|
213
|
-
expect(
|
|
213
|
+
expect(targetPullRequestStates).toEqual([
|
|
214
214
|
{
|
|
215
215
|
branch: '7.2',
|
|
216
216
|
label: 'v7.2.0',
|
|
217
217
|
isSourceBranch: false,
|
|
218
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
218
219
|
state: 'NOT_CREATED',
|
|
219
220
|
},
|
|
220
221
|
{
|
|
221
222
|
branch: '7.1',
|
|
222
223
|
label: 'v7.1.0',
|
|
223
224
|
isSourceBranch: false,
|
|
225
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
224
226
|
state: 'NOT_CREATED',
|
|
225
227
|
},
|
|
226
228
|
]);
|
|
@@ -246,15 +248,16 @@ describe('getPullRequestStates', () => {
|
|
|
246
248
|
'v8.0.0': 'master',
|
|
247
249
|
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
248
250
|
};
|
|
249
|
-
const
|
|
251
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
250
252
|
sourceCommit: mockSourceCommit,
|
|
251
253
|
branchLabelMapping,
|
|
252
254
|
});
|
|
253
|
-
expect(
|
|
255
|
+
expect(targetPullRequestStates).toEqual([
|
|
254
256
|
{
|
|
255
257
|
branch: '7.2',
|
|
256
258
|
label: 'v7.2.0',
|
|
257
259
|
isSourceBranch: false,
|
|
260
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
258
261
|
state: 'MERGED',
|
|
259
262
|
number: 5678,
|
|
260
263
|
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
@@ -267,6 +270,7 @@ describe('getPullRequestStates', () => {
|
|
|
267
270
|
branch: '7.1',
|
|
268
271
|
label: 'v7.1.0',
|
|
269
272
|
isSourceBranch: false,
|
|
273
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
270
274
|
state: 'NOT_CREATED',
|
|
271
275
|
},
|
|
272
276
|
]);
|
|
@@ -308,141 +312,163 @@ describe('getPullRequestStates', () => {
|
|
|
308
312
|
],
|
|
309
313
|
},
|
|
310
314
|
});
|
|
311
|
-
const
|
|
315
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
312
316
|
sourceCommit: mockSourceCommit,
|
|
313
317
|
branchLabelMapping,
|
|
314
318
|
});
|
|
315
|
-
expect(
|
|
319
|
+
expect(targetPullRequestStates).toEqual([
|
|
316
320
|
{
|
|
317
321
|
branch: '5.4',
|
|
318
322
|
label: 'v5.4.3',
|
|
319
323
|
isSourceBranch: false,
|
|
324
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
320
325
|
state: 'NOT_CREATED',
|
|
321
326
|
},
|
|
322
327
|
{
|
|
323
328
|
branch: '5.5',
|
|
324
329
|
label: 'v5.5.3',
|
|
325
330
|
isSourceBranch: false,
|
|
331
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
326
332
|
state: 'NOT_CREATED',
|
|
327
333
|
},
|
|
328
334
|
{
|
|
329
335
|
branch: '5.6',
|
|
330
336
|
label: 'v5.6.16',
|
|
331
337
|
isSourceBranch: false,
|
|
338
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
332
339
|
state: 'NOT_CREATED',
|
|
333
340
|
},
|
|
334
341
|
{
|
|
335
342
|
branch: '6.0',
|
|
336
343
|
label: 'v6.0.1',
|
|
337
344
|
isSourceBranch: false,
|
|
345
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
338
346
|
state: 'NOT_CREATED',
|
|
339
347
|
},
|
|
340
348
|
{
|
|
341
349
|
branch: '6.1',
|
|
342
350
|
label: 'v6.1.4',
|
|
343
351
|
isSourceBranch: false,
|
|
352
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
344
353
|
state: 'NOT_CREATED',
|
|
345
354
|
},
|
|
346
355
|
{
|
|
347
356
|
branch: '6.2',
|
|
348
357
|
label: 'v6.2.5',
|
|
349
358
|
isSourceBranch: false,
|
|
359
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
350
360
|
state: 'NOT_CREATED',
|
|
351
361
|
},
|
|
352
362
|
{
|
|
353
363
|
branch: '6.3',
|
|
354
364
|
label: 'v6.3.3',
|
|
355
365
|
isSourceBranch: false,
|
|
366
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
356
367
|
state: 'NOT_CREATED',
|
|
357
368
|
},
|
|
358
369
|
{
|
|
359
370
|
branch: '6.4',
|
|
360
371
|
label: 'v6.4.4',
|
|
361
372
|
isSourceBranch: false,
|
|
373
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
362
374
|
state: 'NOT_CREATED',
|
|
363
375
|
},
|
|
364
376
|
{
|
|
365
377
|
branch: '6.5',
|
|
366
378
|
label: 'v6.5.5',
|
|
367
379
|
isSourceBranch: false,
|
|
380
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
368
381
|
state: 'NOT_CREATED',
|
|
369
382
|
},
|
|
370
383
|
{
|
|
371
384
|
branch: '6.6',
|
|
372
385
|
label: 'v6.6.3',
|
|
373
386
|
isSourceBranch: false,
|
|
387
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
374
388
|
state: 'NOT_CREATED',
|
|
375
389
|
},
|
|
376
390
|
{
|
|
377
391
|
branch: '6.7',
|
|
378
392
|
label: 'v6.7.2',
|
|
379
393
|
isSourceBranch: false,
|
|
394
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
380
395
|
state: 'NOT_CREATED',
|
|
381
396
|
},
|
|
382
397
|
{
|
|
383
398
|
branch: '6.8',
|
|
384
399
|
label: 'v6.8.4',
|
|
385
400
|
isSourceBranch: false,
|
|
401
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
386
402
|
state: 'NOT_CREATED',
|
|
387
403
|
},
|
|
388
404
|
{
|
|
389
405
|
branch: '7.0',
|
|
390
406
|
label: 'v7.0.2',
|
|
391
407
|
isSourceBranch: false,
|
|
408
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
392
409
|
state: 'NOT_CREATED',
|
|
393
410
|
},
|
|
394
411
|
{
|
|
395
412
|
branch: '7.1',
|
|
396
413
|
label: 'v7.1.2',
|
|
397
414
|
isSourceBranch: false,
|
|
415
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
398
416
|
state: 'NOT_CREATED',
|
|
399
417
|
},
|
|
400
418
|
{
|
|
401
419
|
branch: '7.2',
|
|
402
420
|
label: 'v7.2.2',
|
|
403
421
|
isSourceBranch: false,
|
|
422
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
404
423
|
state: 'NOT_CREATED',
|
|
405
424
|
},
|
|
406
425
|
{
|
|
407
426
|
branch: '7.3',
|
|
408
427
|
label: 'v7.3.3',
|
|
409
428
|
isSourceBranch: false,
|
|
429
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
410
430
|
state: 'NOT_CREATED',
|
|
411
431
|
},
|
|
412
432
|
{
|
|
413
433
|
branch: '7.4',
|
|
414
434
|
label: 'v7.4.1',
|
|
415
435
|
isSourceBranch: false,
|
|
436
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
416
437
|
state: 'NOT_CREATED',
|
|
417
438
|
},
|
|
418
439
|
{
|
|
419
440
|
branch: '7.5',
|
|
420
441
|
label: 'v7.5.0',
|
|
421
442
|
isSourceBranch: false,
|
|
443
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
422
444
|
state: 'NOT_CREATED',
|
|
423
445
|
},
|
|
424
446
|
{
|
|
425
447
|
branch: '7.6',
|
|
426
448
|
label: 'v7.6.0',
|
|
427
449
|
isSourceBranch: false,
|
|
450
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
428
451
|
state: 'NOT_CREATED',
|
|
429
452
|
},
|
|
430
453
|
{
|
|
431
454
|
branch: '7.7',
|
|
432
455
|
label: 'v7.7.0',
|
|
433
456
|
isSourceBranch: false,
|
|
457
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
434
458
|
state: 'NOT_CREATED',
|
|
435
459
|
},
|
|
436
460
|
{
|
|
437
461
|
branch: '7.x',
|
|
438
462
|
label: 'v7.8.0',
|
|
439
463
|
isSourceBranch: false,
|
|
464
|
+
labelRegex: '^v7.8.0$',
|
|
440
465
|
state: 'NOT_CREATED',
|
|
441
466
|
},
|
|
442
467
|
{
|
|
443
468
|
branch: 'master',
|
|
444
469
|
label: 'v8.0.0',
|
|
445
470
|
isSourceBranch: false,
|
|
471
|
+
labelRegex: 'v8.0.0',
|
|
446
472
|
state: 'NOT_CREATED',
|
|
447
473
|
},
|
|
448
474
|
]);
|
|
@@ -458,21 +484,23 @@ describe('getPullRequestStates', () => {
|
|
|
458
484
|
labels: ['backport-to-dev', 'backport-to-v3.1.0'],
|
|
459
485
|
},
|
|
460
486
|
});
|
|
461
|
-
const
|
|
487
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
462
488
|
sourceCommit: mockSourceCommit,
|
|
463
489
|
branchLabelMapping,
|
|
464
490
|
});
|
|
465
|
-
expect(
|
|
491
|
+
expect(targetPullRequestStates).toEqual([
|
|
466
492
|
{
|
|
467
493
|
branch: 'dev',
|
|
468
494
|
label: 'backport-to-dev',
|
|
469
495
|
isSourceBranch: false,
|
|
496
|
+
labelRegex: '^backport-to-(.+)$',
|
|
470
497
|
state: 'NOT_CREATED',
|
|
471
498
|
},
|
|
472
499
|
{
|
|
473
500
|
branch: 'v3.1.0',
|
|
474
501
|
label: 'backport-to-v3.1.0',
|
|
475
502
|
isSourceBranch: false,
|
|
503
|
+
labelRegex: '^backport-to-(.+)$',
|
|
476
504
|
state: 'NOT_CREATED',
|
|
477
505
|
},
|
|
478
506
|
]);
|
|
@@ -489,15 +517,16 @@ describe('getPullRequestStates', () => {
|
|
|
489
517
|
labels: ['label-2'],
|
|
490
518
|
},
|
|
491
519
|
});
|
|
492
|
-
const
|
|
520
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
493
521
|
sourceCommit: mockSourceCommit,
|
|
494
522
|
branchLabelMapping,
|
|
495
523
|
});
|
|
496
|
-
expect(
|
|
524
|
+
expect(targetPullRequestStates).toEqual([
|
|
497
525
|
{
|
|
498
526
|
branch: 'branch-b',
|
|
499
527
|
label: 'label-2',
|
|
500
528
|
isSourceBranch: false,
|
|
529
|
+
labelRegex: 'label-2',
|
|
501
530
|
state: 'NOT_CREATED',
|
|
502
531
|
},
|
|
503
532
|
]);
|
|
@@ -521,21 +550,23 @@ describe('getPullRequestStates', () => {
|
|
|
521
550
|
},
|
|
522
551
|
],
|
|
523
552
|
});
|
|
524
|
-
const
|
|
553
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
525
554
|
sourceCommit: mockSourceCommit,
|
|
526
555
|
branchLabelMapping,
|
|
527
556
|
});
|
|
528
|
-
expect(
|
|
557
|
+
expect(targetPullRequestStates).toEqual([
|
|
529
558
|
{
|
|
530
559
|
branch: 'branch-1',
|
|
531
560
|
label: 'label-1',
|
|
532
561
|
isSourceBranch: false,
|
|
562
|
+
labelRegex: 'label-(\\d+)',
|
|
533
563
|
state: 'NOT_CREATED',
|
|
534
564
|
},
|
|
535
565
|
{
|
|
536
566
|
branch: 'branch-2',
|
|
537
567
|
label: 'label-2',
|
|
538
568
|
isSourceBranch: false,
|
|
569
|
+
labelRegex: 'label-(\\d+)',
|
|
539
570
|
state: 'NOT_CREATED',
|
|
540
571
|
},
|
|
541
572
|
{
|
|
@@ -543,6 +574,7 @@ describe('getPullRequestStates', () => {
|
|
|
543
574
|
label: 'label-3',
|
|
544
575
|
number: 5678,
|
|
545
576
|
isSourceBranch: false,
|
|
577
|
+
labelRegex: 'label-(\\d+)',
|
|
546
578
|
state: 'OPEN',
|
|
547
579
|
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
548
580
|
},
|
|
@@ -550,6 +582,7 @@ describe('getPullRequestStates', () => {
|
|
|
550
582
|
branch: 'branch-4',
|
|
551
583
|
label: 'label-4',
|
|
552
584
|
isSourceBranch: false,
|
|
585
|
+
labelRegex: 'label-(\\d+)',
|
|
553
586
|
state: 'NOT_CREATED',
|
|
554
587
|
},
|
|
555
588
|
]);
|
|
@@ -573,33 +606,37 @@ describe('getPullRequestStates', () => {
|
|
|
573
606
|
},
|
|
574
607
|
],
|
|
575
608
|
});
|
|
576
|
-
const
|
|
609
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
577
610
|
sourceCommit: mockSourceCommit,
|
|
578
611
|
branchLabelMapping,
|
|
579
612
|
});
|
|
580
|
-
expect(
|
|
613
|
+
expect(targetPullRequestStates).toEqual([
|
|
581
614
|
{
|
|
582
615
|
branch: 'branch-1',
|
|
583
616
|
label: 'label-1',
|
|
584
617
|
isSourceBranch: false,
|
|
618
|
+
labelRegex: 'label-(\\d+)',
|
|
585
619
|
state: 'NOT_CREATED',
|
|
586
620
|
},
|
|
587
621
|
{
|
|
588
622
|
branch: 'branch-2',
|
|
589
623
|
label: 'label-2',
|
|
590
624
|
isSourceBranch: false,
|
|
625
|
+
labelRegex: 'label-(\\d+)',
|
|
591
626
|
state: 'NOT_CREATED',
|
|
592
627
|
},
|
|
593
628
|
{
|
|
594
629
|
branch: 'branch-3',
|
|
595
630
|
label: 'label-3',
|
|
596
631
|
isSourceBranch: false,
|
|
632
|
+
labelRegex: 'label-(\\d+)',
|
|
597
633
|
state: 'NOT_CREATED',
|
|
598
634
|
},
|
|
599
635
|
{
|
|
600
636
|
branch: 'branch-4',
|
|
601
637
|
label: 'label-4',
|
|
602
638
|
isSourceBranch: false,
|
|
639
|
+
labelRegex: 'label-(\\d+)',
|
|
603
640
|
state: 'NOT_CREATED',
|
|
604
641
|
},
|
|
605
642
|
]);
|
|
@@ -623,27 +660,30 @@ describe('getPullRequestStates', () => {
|
|
|
623
660
|
},
|
|
624
661
|
],
|
|
625
662
|
});
|
|
626
|
-
const
|
|
663
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
627
664
|
sourceCommit: mockSourceCommit,
|
|
628
665
|
branchLabelMapping,
|
|
629
666
|
});
|
|
630
|
-
expect(
|
|
667
|
+
expect(targetPullRequestStates).toEqual([
|
|
631
668
|
{
|
|
632
669
|
branch: 'branch-1',
|
|
633
670
|
label: 'label-1',
|
|
634
671
|
isSourceBranch: false,
|
|
672
|
+
labelRegex: 'label-(\\d+)',
|
|
635
673
|
state: 'NOT_CREATED',
|
|
636
674
|
},
|
|
637
675
|
{
|
|
638
676
|
branch: 'branch-2',
|
|
639
677
|
label: 'label-2',
|
|
640
678
|
isSourceBranch: false,
|
|
679
|
+
labelRegex: 'label-(\\d+)',
|
|
641
680
|
state: 'NOT_CREATED',
|
|
642
681
|
},
|
|
643
682
|
{
|
|
644
683
|
branch: 'branch-3',
|
|
645
684
|
label: 'label-3',
|
|
646
685
|
isSourceBranch: false,
|
|
686
|
+
labelRegex: 'label-(\\d+)',
|
|
647
687
|
number: 5678,
|
|
648
688
|
state: 'MERGED',
|
|
649
689
|
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
@@ -656,6 +696,7 @@ describe('getPullRequestStates', () => {
|
|
|
656
696
|
branch: 'branch-4',
|
|
657
697
|
label: 'label-4',
|
|
658
698
|
isSourceBranch: false,
|
|
699
|
+
labelRegex: 'label-(\\d+)',
|
|
659
700
|
state: 'NOT_CREATED',
|
|
660
701
|
},
|
|
661
702
|
]);
|
|
@@ -10,6 +10,7 @@ export interface Commit {
|
|
|
10
10
|
branchLabelMapping: ValidConfigOptions['branchLabelMapping'];
|
|
11
11
|
};
|
|
12
12
|
sourcePullRequest?: {
|
|
13
|
+
labels: string[];
|
|
13
14
|
number: number;
|
|
14
15
|
url: string;
|
|
15
16
|
mergeCommit: {
|
|
@@ -19,7 +20,7 @@ export interface Commit {
|
|
|
19
20
|
};
|
|
20
21
|
sourceBranch: string;
|
|
21
22
|
suggestedTargetBranches: string[];
|
|
22
|
-
|
|
23
|
+
targetPullRequestStates: TargetPullRequest[];
|
|
23
24
|
}
|
|
24
25
|
export interface SourcePullRequestNode {
|
|
25
26
|
baseRefName: string;
|
|
@@ -8,23 +8,23 @@ const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
9
|
const remoteConfig_1 = require("../remoteConfig");
|
|
10
10
|
const getPullRequestStates_1 = require("./getPullRequestStates");
|
|
11
|
-
function getSuggestedTargetBranches(sourceCommit,
|
|
11
|
+
function getSuggestedTargetBranches(sourceCommit, targetPullRequestStates, branchLabelMapping) {
|
|
12
12
|
const missingPrs = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
13
13
|
sourceCommit,
|
|
14
14
|
branchLabelMapping,
|
|
15
15
|
}).filter((pr) => pr.state === 'NOT_CREATED' || pr.state === 'CLOSED');
|
|
16
|
-
const mergedPrs =
|
|
16
|
+
const mergedPrs = targetPullRequestStates.filter((pr) => pr.state === 'MERGED');
|
|
17
17
|
return (0, lodash_1.differenceBy)(missingPrs, mergedPrs, (pr) => pr.label).map((pr) => pr.branch);
|
|
18
18
|
}
|
|
19
19
|
function parseSourceCommit({ sourceCommit, options, }) {
|
|
20
|
-
const sourcePullRequest = sourceCommit
|
|
21
|
-
const sourceCommitBranchLabelMapping =
|
|
20
|
+
const sourcePullRequest = (0, getPullRequestStates_1.getSourcePullRequest)(sourceCommit);
|
|
21
|
+
const sourceCommitBranchLabelMapping = getSourceCommitBranchLabelMapping(sourceCommit);
|
|
22
22
|
const currentBranchLabelMapping = options.branchLabelMapping;
|
|
23
|
-
const
|
|
23
|
+
const targetPullRequestStates = (0, getPullRequestStates_1.getPullRequestStates)({
|
|
24
24
|
sourceCommit,
|
|
25
25
|
branchLabelMapping: sourceCommitBranchLabelMapping ?? currentBranchLabelMapping,
|
|
26
26
|
});
|
|
27
|
-
const suggestedTargetBranches = getSuggestedTargetBranches(sourceCommit,
|
|
27
|
+
const suggestedTargetBranches = getSuggestedTargetBranches(sourceCommit, targetPullRequestStates, currentBranchLabelMapping);
|
|
28
28
|
return {
|
|
29
29
|
author: sourceCommit.author,
|
|
30
30
|
sourceCommit: {
|
|
@@ -35,6 +35,7 @@ function parseSourceCommit({ sourceCommit, options, }) {
|
|
|
35
35
|
},
|
|
36
36
|
sourcePullRequest: sourcePullRequest
|
|
37
37
|
? {
|
|
38
|
+
labels: sourcePullRequest.labels.nodes.map((label) => label.name),
|
|
38
39
|
number: sourcePullRequest.number,
|
|
39
40
|
url: sourcePullRequest.url,
|
|
40
41
|
mergeCommit: {
|
|
@@ -45,7 +46,7 @@ function parseSourceCommit({ sourceCommit, options, }) {
|
|
|
45
46
|
: undefined,
|
|
46
47
|
sourceBranch: sourcePullRequest?.baseRefName ?? options.sourceBranch,
|
|
47
48
|
suggestedTargetBranches,
|
|
48
|
-
|
|
49
|
+
targetPullRequestStates: targetPullRequestStates,
|
|
49
50
|
};
|
|
50
51
|
}
|
|
51
52
|
exports.parseSourceCommit = parseSourceCommit;
|
|
@@ -136,3 +137,10 @@ exports.SourceCommitWithTargetPullRequestFragment = (0, graphql_tag_1.default) `
|
|
|
136
137
|
|
|
137
138
|
${remoteConfig_1.RemoteConfigHistoryFragment}
|
|
138
139
|
`;
|
|
140
|
+
function getSourceCommitBranchLabelMapping(sourceCommit) {
|
|
141
|
+
const sourcePullRequest = (0, getPullRequestStates_1.getSourcePullRequest)(sourceCommit);
|
|
142
|
+
const remoteConfig = sourcePullRequest?.mergeCommit.remoteConfigHistory.edges?.[0]?.remoteConfig;
|
|
143
|
+
if (remoteConfig) {
|
|
144
|
+
return (0, remoteConfig_1.parseRemoteConfig)(remoteConfig)?.branchLabelMapping;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -42,7 +42,7 @@ describe('parseSourceCommit', () => {
|
|
|
42
42
|
expect(commit.sourceBranch).toBe('sourcebranch-from-options');
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
|
-
describe('
|
|
45
|
+
describe('targetPullRequestStates', () => {
|
|
46
46
|
it('uses options.branchLabelMapping when sourceCommit is empty', () => {
|
|
47
47
|
const branchLabelMapping = {
|
|
48
48
|
'^v6.4.0$': 'main',
|
|
@@ -80,10 +80,11 @@ describe('parseSourceCommit', () => {
|
|
|
80
80
|
},
|
|
81
81
|
});
|
|
82
82
|
expect(commit.suggestedTargetBranches).toEqual(['6.1']);
|
|
83
|
-
expect(commit.
|
|
83
|
+
expect(commit.targetPullRequestStates).toEqual([
|
|
84
84
|
{
|
|
85
85
|
branch: 'main',
|
|
86
86
|
label: 'v6.4.0',
|
|
87
|
+
labelRegex: '^v6.4.0$',
|
|
87
88
|
isSourceBranch: true,
|
|
88
89
|
mergeCommit: {
|
|
89
90
|
message: 'My commit message (#66)',
|
|
@@ -96,6 +97,7 @@ describe('parseSourceCommit', () => {
|
|
|
96
97
|
{
|
|
97
98
|
branch: '6.3',
|
|
98
99
|
label: 'v6.3.0',
|
|
100
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
99
101
|
isSourceBranch: false,
|
|
100
102
|
number: 5678,
|
|
101
103
|
state: 'MERGED',
|
|
@@ -108,6 +110,7 @@ describe('parseSourceCommit', () => {
|
|
|
108
110
|
{
|
|
109
111
|
branch: '6.2',
|
|
110
112
|
label: 'v6.2.0',
|
|
113
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
111
114
|
isSourceBranch: false,
|
|
112
115
|
number: 9876,
|
|
113
116
|
state: 'OPEN',
|
|
@@ -116,6 +119,7 @@ describe('parseSourceCommit', () => {
|
|
|
116
119
|
{
|
|
117
120
|
branch: '6.1',
|
|
118
121
|
label: 'v6.1.0',
|
|
122
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
119
123
|
isSourceBranch: false,
|
|
120
124
|
state: 'NOT_CREATED',
|
|
121
125
|
},
|
|
@@ -160,11 +164,12 @@ describe('parseSourceCommit', () => {
|
|
|
160
164
|
},
|
|
161
165
|
});
|
|
162
166
|
expect(commit.suggestedTargetBranches).toEqual(['6.1']);
|
|
163
|
-
expect(commit.
|
|
167
|
+
expect(commit.targetPullRequestStates).toEqual([
|
|
164
168
|
{
|
|
165
169
|
branch: 'main',
|
|
166
170
|
isSourceBranch: true,
|
|
167
171
|
label: 'v6.3.0',
|
|
172
|
+
labelRegex: '^v6.3.0$',
|
|
168
173
|
mergeCommit: {
|
|
169
174
|
message: 'My commit message (#66)',
|
|
170
175
|
sha: 'DO NOT USE: default-source-commit-sha',
|
|
@@ -176,6 +181,7 @@ describe('parseSourceCommit', () => {
|
|
|
176
181
|
{
|
|
177
182
|
branch: '6.2',
|
|
178
183
|
label: 'v6.2.0',
|
|
184
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
179
185
|
isSourceBranch: false,
|
|
180
186
|
number: 9876,
|
|
181
187
|
state: 'OPEN',
|
|
@@ -184,6 +190,7 @@ describe('parseSourceCommit', () => {
|
|
|
184
190
|
{
|
|
185
191
|
branch: '6.1',
|
|
186
192
|
label: 'v6.1.0',
|
|
193
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
187
194
|
isSourceBranch: false,
|
|
188
195
|
state: 'NOT_CREATED',
|
|
189
196
|
},
|
|
@@ -237,6 +244,7 @@ describe('parseSourceCommit', () => {
|
|
|
237
244
|
branchLabelMapping,
|
|
238
245
|
},
|
|
239
246
|
sourcePullRequest: {
|
|
247
|
+
labels: ['v6.3.0', 'v6.2.0', 'v6.1.0'],
|
|
240
248
|
number: 1234,
|
|
241
249
|
url: 'https://github.com/elastic/kibana/pull/1234',
|
|
242
250
|
mergeCommit: {
|
|
@@ -245,10 +253,11 @@ describe('parseSourceCommit', () => {
|
|
|
245
253
|
},
|
|
246
254
|
},
|
|
247
255
|
sourceBranch: 'source-branch-from-associated-pull-request',
|
|
248
|
-
|
|
256
|
+
targetPullRequestStates: [
|
|
249
257
|
{
|
|
250
258
|
branch: '6.x',
|
|
251
259
|
label: 'v6.3.0',
|
|
260
|
+
labelRegex: '^v6.3.0$',
|
|
252
261
|
isSourceBranch: false,
|
|
253
262
|
number: 5678,
|
|
254
263
|
state: 'MERGED',
|
|
@@ -261,6 +270,7 @@ describe('parseSourceCommit', () => {
|
|
|
261
270
|
{
|
|
262
271
|
branch: '6.2',
|
|
263
272
|
label: 'v6.2.0',
|
|
273
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
264
274
|
isSourceBranch: false,
|
|
265
275
|
number: 9876,
|
|
266
276
|
state: 'OPEN',
|
|
@@ -269,6 +279,7 @@ describe('parseSourceCommit', () => {
|
|
|
269
279
|
{
|
|
270
280
|
branch: '6.1',
|
|
271
281
|
label: 'v6.1.0',
|
|
282
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
272
283
|
isSourceBranch: false,
|
|
273
284
|
state: 'NOT_CREATED',
|
|
274
285
|
},
|
package/dist/runSequentially.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runSequentially = void 0;
|
|
4
4
|
const BackportError_1 = require("./lib/BackportError");
|
|
5
|
-
const cherrypickAndCreateTargetPullRequest_1 = require("./lib/cherrypickAndCreateTargetPullRequest");
|
|
5
|
+
const cherrypickAndCreateTargetPullRequest_1 = require("./lib/cherrypickAndCreateTargetPullRequest/cherrypickAndCreateTargetPullRequest");
|
|
6
6
|
const logger_1 = require("./lib/logger");
|
|
7
7
|
const sequentially_1 = require("./lib/sequentially");
|
|
8
8
|
async function runSequentially({ options, commits, targetBranches, }) {
|
|
@@ -45,11 +45,11 @@ async function runSequentially({ options, commits, targetBranches, }) {
|
|
|
45
45
|
}
|
|
46
46
|
logger_1.logger.error('runSequentially failed', e);
|
|
47
47
|
if (isHandledError) {
|
|
48
|
-
// don't output anything
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
// don't output anything for `code: invalid-branch-exception`.
|
|
49
|
+
// Outputting is already handled
|
|
50
|
+
if (e.errorContext.code !== 'invalid-branch-exception') {
|
|
51
|
+
(0, logger_1.consoleLog)(e.message);
|
|
51
52
|
}
|
|
52
|
-
(0, logger_1.consoleLog)(e.message);
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
(0, logger_1.consoleLog)('An unhandled error occurred while backporting commit. Please see the logs for details');
|