backport 8.6.0 → 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/commit-author.private.test.js +3 -3
- 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
|
@@ -108,7 +108,7 @@ describe('entrypoint.module', () => {
|
|
|
108
108
|
status: 'success',
|
|
109
109
|
didUpdate: false,
|
|
110
110
|
pullRequestNumber: 1337,
|
|
111
|
-
pullRequestUrl: '
|
|
111
|
+
pullRequestUrl: 'this-is-a-dry-run',
|
|
112
112
|
targetBranch: '7.x',
|
|
113
113
|
},
|
|
114
114
|
],
|
|
@@ -119,10 +119,11 @@ describe('entrypoint.module', () => {
|
|
|
119
119
|
name: 'Søren Louv-Jansen',
|
|
120
120
|
},
|
|
121
121
|
suggestedTargetBranches: ['7.x'],
|
|
122
|
-
|
|
122
|
+
targetPullRequestStates: [
|
|
123
123
|
{
|
|
124
124
|
branch: '7.x',
|
|
125
125
|
label: 'backport-to-7.x',
|
|
126
|
+
labelRegex: '^backport-to-(.*)$',
|
|
126
127
|
isSourceBranch: false,
|
|
127
128
|
state: 'NOT_CREATED',
|
|
128
129
|
},
|
|
@@ -134,6 +135,7 @@ describe('entrypoint.module', () => {
|
|
|
134
135
|
sha: '343402a748be2375325b2730fa979bcea5b96ba1',
|
|
135
136
|
},
|
|
136
137
|
sourcePullRequest: {
|
|
138
|
+
labels: ['backport-to-7.x'],
|
|
137
139
|
mergeCommit: {
|
|
138
140
|
message: 'Change Barca to Braithwaite (#8)',
|
|
139
141
|
sha: '343402a748be2375325b2730fa979bcea5b96ba1',
|
|
@@ -170,6 +172,7 @@ describe('entrypoint.module', () => {
|
|
|
170
172
|
sha: 'd1b348e6213c5ad48653dfaad6eaf4928b2c688b',
|
|
171
173
|
},
|
|
172
174
|
sourcePullRequest: {
|
|
175
|
+
labels: ['Team:apm', 'release_note:skip', 'v7.11.0'],
|
|
173
176
|
number: 88188,
|
|
174
177
|
url: 'https://github.com/elastic/kibana/pull/88188',
|
|
175
178
|
mergeCommit: {
|
|
@@ -178,11 +181,12 @@ describe('entrypoint.module', () => {
|
|
|
178
181
|
},
|
|
179
182
|
},
|
|
180
183
|
sourceBranch: 'master',
|
|
181
|
-
|
|
184
|
+
targetPullRequestStates: [
|
|
182
185
|
{
|
|
183
186
|
branch: '7.11',
|
|
184
187
|
isSourceBranch: false,
|
|
185
188
|
label: 'v7.11.0',
|
|
189
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
186
190
|
mergeCommit: {
|
|
187
191
|
message: '[APM] Fix incorrect table column header (95th instead of avg) (#88188) (#88289)',
|
|
188
192
|
sha: 'b8194e9ec27d69f485d8b194d1cb5e4f6d8fef6d',
|
|
@@ -228,6 +232,7 @@ describe('entrypoint.module', () => {
|
|
|
228
232
|
sha: 'd1b348e6213c5ad48653dfaad6eaf4928b2c688b',
|
|
229
233
|
},
|
|
230
234
|
sourcePullRequest: {
|
|
235
|
+
labels: ['Team:apm', 'release_note:skip', 'v7.11.0'],
|
|
231
236
|
number: 88188,
|
|
232
237
|
url: 'https://github.com/elastic/kibana/pull/88188',
|
|
233
238
|
mergeCommit: {
|
|
@@ -236,12 +241,13 @@ describe('entrypoint.module', () => {
|
|
|
236
241
|
},
|
|
237
242
|
},
|
|
238
243
|
sourceBranch: 'master',
|
|
239
|
-
|
|
244
|
+
targetPullRequestStates: [
|
|
240
245
|
{
|
|
241
246
|
url: 'https://github.com/elastic/kibana/pull/88289',
|
|
242
247
|
number: 88289,
|
|
243
248
|
branch: '7.11',
|
|
244
249
|
label: 'v7.11.0',
|
|
250
|
+
labelRegex: '^v(\\d+).(\\d+).\\d+$',
|
|
245
251
|
isSourceBranch: false,
|
|
246
252
|
state: 'MERGED',
|
|
247
253
|
mergeCommit: {
|
|
@@ -319,32 +325,6 @@ describe('entrypoint.module', () => {
|
|
|
319
325
|
"email": "sorenlouv@gmail.com",
|
|
320
326
|
"name": "Søren Louv-Jansen",
|
|
321
327
|
},
|
|
322
|
-
"pullRequestStates": Array [
|
|
323
|
-
Object {
|
|
324
|
-
"branch": "7.x",
|
|
325
|
-
"isSourceBranch": false,
|
|
326
|
-
"label": "v7.11.0",
|
|
327
|
-
"mergeCommit": Object {
|
|
328
|
-
"message": "[APM] Fix broken link to ML when time range is not set (#85976) (#86227)
|
|
329
|
-
|
|
330
|
-
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>",
|
|
331
|
-
"sha": "2d361f018e0776c237d03b84ca8aa24615d16d99",
|
|
332
|
-
},
|
|
333
|
-
"number": 86227,
|
|
334
|
-
"state": "MERGED",
|
|
335
|
-
"url": "https://github.com/elastic/kibana/pull/86227",
|
|
336
|
-
},
|
|
337
|
-
Object {
|
|
338
|
-
"branch": "7.11",
|
|
339
|
-
"mergeCommit": Object {
|
|
340
|
-
"message": "[APM] Fix broken link to ML when time range is not set (#85976) (#86228)",
|
|
341
|
-
"sha": "c6c0015e01601cd852730d5cd20e1a906cbee900",
|
|
342
|
-
},
|
|
343
|
-
"number": 86228,
|
|
344
|
-
"state": "MERGED",
|
|
345
|
-
"url": "https://github.com/elastic/kibana/pull/86228",
|
|
346
|
-
},
|
|
347
|
-
],
|
|
348
328
|
"sourceBranch": "master",
|
|
349
329
|
"sourceCommit": Object {
|
|
350
330
|
"branchLabelMapping": Object {
|
|
@@ -357,6 +337,13 @@ describe('entrypoint.module', () => {
|
|
|
357
337
|
"sha": "744d6809ded7e1055bfda280c351cee3e8c0e3bf",
|
|
358
338
|
},
|
|
359
339
|
"sourcePullRequest": Object {
|
|
340
|
+
"labels": Array [
|
|
341
|
+
"release_note:fix",
|
|
342
|
+
"Team:apm",
|
|
343
|
+
"apm:test-plan-done",
|
|
344
|
+
"v7.11.0",
|
|
345
|
+
"apm:test-plan-7.11.0",
|
|
346
|
+
],
|
|
360
347
|
"mergeCommit": Object {
|
|
361
348
|
"message": "[APM] Fix broken link to ML when time range is not set (#85976)",
|
|
362
349
|
"sha": "744d6809ded7e1055bfda280c351cee3e8c0e3bf",
|
|
@@ -365,28 +352,39 @@ describe('entrypoint.module', () => {
|
|
|
365
352
|
"url": "https://github.com/elastic/kibana/pull/85976",
|
|
366
353
|
},
|
|
367
354
|
"suggestedTargetBranches": Array [],
|
|
368
|
-
|
|
369
|
-
Object {
|
|
370
|
-
"author": Object {
|
|
371
|
-
"email": "sorenlouv@gmail.com",
|
|
372
|
-
"name": "Søren Louv-Jansen",
|
|
373
|
-
},
|
|
374
|
-
"pullRequestStates": Array [
|
|
355
|
+
"targetPullRequestStates": Array [
|
|
375
356
|
Object {
|
|
376
357
|
"branch": "7.x",
|
|
377
358
|
"isSourceBranch": false,
|
|
378
359
|
"label": "v7.11.0",
|
|
360
|
+
"labelRegex": "^v7.11.0$",
|
|
379
361
|
"mergeCommit": Object {
|
|
380
|
-
"message": "[
|
|
362
|
+
"message": "[APM] Fix broken link to ML when time range is not set (#85976) (#86227)
|
|
381
363
|
|
|
382
364
|
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>",
|
|
383
|
-
"sha": "
|
|
365
|
+
"sha": "2d361f018e0776c237d03b84ca8aa24615d16d99",
|
|
384
366
|
},
|
|
385
|
-
"number":
|
|
367
|
+
"number": 86227,
|
|
386
368
|
"state": "MERGED",
|
|
387
|
-
"url": "https://github.com/elastic/kibana/pull/
|
|
369
|
+
"url": "https://github.com/elastic/kibana/pull/86227",
|
|
370
|
+
},
|
|
371
|
+
Object {
|
|
372
|
+
"branch": "7.11",
|
|
373
|
+
"mergeCommit": Object {
|
|
374
|
+
"message": "[APM] Fix broken link to ML when time range is not set (#85976) (#86228)",
|
|
375
|
+
"sha": "c6c0015e01601cd852730d5cd20e1a906cbee900",
|
|
376
|
+
},
|
|
377
|
+
"number": 86228,
|
|
378
|
+
"state": "MERGED",
|
|
379
|
+
"url": "https://github.com/elastic/kibana/pull/86228",
|
|
388
380
|
},
|
|
389
381
|
],
|
|
382
|
+
},
|
|
383
|
+
Object {
|
|
384
|
+
"author": Object {
|
|
385
|
+
"email": "sorenlouv@gmail.com",
|
|
386
|
+
"name": "Søren Louv-Jansen",
|
|
387
|
+
},
|
|
390
388
|
"sourceBranch": "master",
|
|
391
389
|
"sourceCommit": Object {
|
|
392
390
|
"branchLabelMapping": Object {
|
|
@@ -401,6 +399,11 @@ describe('entrypoint.module', () => {
|
|
|
401
399
|
"sha": "20638a64e2a895d4e4a6597d4a37b5db7003f1e9",
|
|
402
400
|
},
|
|
403
401
|
"sourcePullRequest": Object {
|
|
402
|
+
"labels": Array [
|
|
403
|
+
"Team:apm",
|
|
404
|
+
"release_note:skip",
|
|
405
|
+
"v7.11.0",
|
|
406
|
+
],
|
|
404
407
|
"mergeCommit": Object {
|
|
405
408
|
"message": "[APM] Correlations polish (#85116)
|
|
406
409
|
|
|
@@ -411,26 +414,29 @@ describe('entrypoint.module', () => {
|
|
|
411
414
|
"url": "https://github.com/elastic/kibana/pull/85116",
|
|
412
415
|
},
|
|
413
416
|
"suggestedTargetBranches": Array [],
|
|
414
|
-
|
|
415
|
-
Object {
|
|
416
|
-
"author": Object {
|
|
417
|
-
"email": "sorenlouv@gmail.com",
|
|
418
|
-
"name": "Søren Louv-Jansen",
|
|
419
|
-
},
|
|
420
|
-
"pullRequestStates": Array [
|
|
417
|
+
"targetPullRequestStates": Array [
|
|
421
418
|
Object {
|
|
422
419
|
"branch": "7.x",
|
|
423
420
|
"isSourceBranch": false,
|
|
424
421
|
"label": "v7.11.0",
|
|
422
|
+
"labelRegex": "^v7.11.0$",
|
|
425
423
|
"mergeCommit": Object {
|
|
426
|
-
"message": "[7.x] [APM]
|
|
427
|
-
|
|
424
|
+
"message": "[7.x] [APM] Correlations polish (#85116) (#85940)
|
|
425
|
+
|
|
426
|
+
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>",
|
|
427
|
+
"sha": "42b3ecb40c344cd57800b8fa387ae32bad24bfc4",
|
|
428
428
|
},
|
|
429
|
-
"number":
|
|
429
|
+
"number": 85940,
|
|
430
430
|
"state": "MERGED",
|
|
431
|
-
"url": "https://github.com/elastic/kibana/pull/
|
|
431
|
+
"url": "https://github.com/elastic/kibana/pull/85940",
|
|
432
432
|
},
|
|
433
433
|
],
|
|
434
|
+
},
|
|
435
|
+
Object {
|
|
436
|
+
"author": Object {
|
|
437
|
+
"email": "sorenlouv@gmail.com",
|
|
438
|
+
"name": "Søren Louv-Jansen",
|
|
439
|
+
},
|
|
434
440
|
"sourceBranch": "master",
|
|
435
441
|
"sourceCommit": Object {
|
|
436
442
|
"branchLabelMapping": Object {
|
|
@@ -443,6 +449,11 @@ describe('entrypoint.module', () => {
|
|
|
443
449
|
"sha": "cee681afb3c5f87371112fab9a7e5dddbafea0a8",
|
|
444
450
|
},
|
|
445
451
|
"sourcePullRequest": Object {
|
|
452
|
+
"labels": Array [
|
|
453
|
+
"Team:apm",
|
|
454
|
+
"release_note:skip",
|
|
455
|
+
"v7.11.0",
|
|
456
|
+
],
|
|
446
457
|
"mergeCommit": Object {
|
|
447
458
|
"message": "[APM] Improve pointer event hook (#85117)",
|
|
448
459
|
"sha": "cee681afb3c5f87371112fab9a7e5dddbafea0a8",
|
|
@@ -451,6 +462,21 @@ describe('entrypoint.module', () => {
|
|
|
451
462
|
"url": "https://github.com/elastic/kibana/pull/85117",
|
|
452
463
|
},
|
|
453
464
|
"suggestedTargetBranches": Array [],
|
|
465
|
+
"targetPullRequestStates": Array [
|
|
466
|
+
Object {
|
|
467
|
+
"branch": "7.x",
|
|
468
|
+
"isSourceBranch": false,
|
|
469
|
+
"label": "v7.11.0",
|
|
470
|
+
"labelRegex": "^v7.11.0$",
|
|
471
|
+
"mergeCommit": Object {
|
|
472
|
+
"message": "[7.x] [APM] Improve pointer event hook (#85117) (#85142)",
|
|
473
|
+
"sha": "3b72a4f3cc7c0abd0541073e1d0246b85cea3def",
|
|
474
|
+
},
|
|
475
|
+
"number": 85142,
|
|
476
|
+
"state": "MERGED",
|
|
477
|
+
"url": "https://github.com/elastic/kibana/pull/85142",
|
|
478
|
+
},
|
|
479
|
+
],
|
|
454
480
|
},
|
|
455
481
|
]
|
|
456
482
|
`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ValidConfigOptions } from '
|
|
2
|
-
import { Commit } from '
|
|
1
|
+
import { ValidConfigOptions } from '../../options/options';
|
|
2
|
+
import { Commit } from '../sourceCommit/parseSourceCommit';
|
|
3
3
|
export declare function cherrypickAndCreateTargetPullRequest({ options, commits, targetBranch, }: {
|
|
4
4
|
options: ValidConfigOptions;
|
|
5
5
|
commits: Commit[];
|
|
@@ -0,0 +1,98 @@
|
|
|
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.cherrypickAndCreateTargetPullRequest = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const lodash_1 = require("lodash");
|
|
9
|
+
const getSourceBranchFromCommits_1 = require("../getSourceBranchFromCommits");
|
|
10
|
+
const git_1 = require("../git");
|
|
11
|
+
const addAssigneesToPullRequest_1 = require("../github/v3/addAssigneesToPullRequest");
|
|
12
|
+
const addLabelsToPullRequest_1 = require("../github/v3/addLabelsToPullRequest");
|
|
13
|
+
const addReviewersToPullRequest_1 = require("../github/v3/addReviewersToPullRequest");
|
|
14
|
+
const createPullRequest_1 = require("../github/v3/createPullRequest");
|
|
15
|
+
const enablePullRequestAutoMerge_1 = require("../github/v4/enablePullRequestAutoMerge");
|
|
16
|
+
const validateTargetBranch_1 = require("../github/v4/validateTargetBranch");
|
|
17
|
+
const logger_1 = require("../logger");
|
|
18
|
+
const sequentially_1 = require("../sequentially");
|
|
19
|
+
const getBackportBranchName_1 = require("./getBackportBranchName");
|
|
20
|
+
const getMergeCommit_1 = require("./getMergeCommit");
|
|
21
|
+
const getTargetPRLabels_1 = require("./getTargetPRLabels");
|
|
22
|
+
const waitForCherrypick_1 = require("./waitForCherrypick");
|
|
23
|
+
async function cherrypickAndCreateTargetPullRequest({ options, commits, targetBranch, }) {
|
|
24
|
+
const backportBranch = (0, getBackportBranchName_1.getBackportBranchName)(targetBranch, commits);
|
|
25
|
+
const repoForkOwner = (0, git_1.getRepoForkOwner)(options);
|
|
26
|
+
(0, logger_1.consoleLog)(`\n${chalk_1.default.bold(`Backporting to ${targetBranch}:`)}`);
|
|
27
|
+
await (0, validateTargetBranch_1.validateTargetBranch)({ ...options, branchName: targetBranch });
|
|
28
|
+
await (0, git_1.createBackportBranch)({
|
|
29
|
+
options,
|
|
30
|
+
sourceBranch: (0, getSourceBranchFromCommits_1.getSourceBranchFromCommits)(commits),
|
|
31
|
+
targetBranch,
|
|
32
|
+
backportBranch,
|
|
33
|
+
});
|
|
34
|
+
const commitsFlattened = (0, lodash_1.flatten)(await Promise.all(commits.map((c) => (0, getMergeCommit_1.getMergeCommits)(options, c))));
|
|
35
|
+
await (0, sequentially_1.sequentially)(commitsFlattened, (commit) => (0, waitForCherrypick_1.waitForCherrypick)(options, commit, targetBranch));
|
|
36
|
+
if (!options.dryRun) {
|
|
37
|
+
await (0, git_1.pushBackportBranch)({ options, backportBranch });
|
|
38
|
+
await (0, git_1.deleteBackportBranch)({ options, backportBranch });
|
|
39
|
+
}
|
|
40
|
+
const prPayload = {
|
|
41
|
+
owner: options.repoOwner,
|
|
42
|
+
repo: options.repoName,
|
|
43
|
+
title: (0, createPullRequest_1.getTitle)({ options, commits, targetBranch }),
|
|
44
|
+
body: (0, createPullRequest_1.getPullRequestBody)({ options, commits, targetBranch }),
|
|
45
|
+
head: `${repoForkOwner}:${backportBranch}`,
|
|
46
|
+
base: targetBranch, // eg. 7.x
|
|
47
|
+
};
|
|
48
|
+
const targetPullRequest = await (0, createPullRequest_1.createPullRequest)({ options, prPayload });
|
|
49
|
+
// add assignees to target pull request
|
|
50
|
+
const assignees = options.autoAssign
|
|
51
|
+
? [options.authenticatedUsername]
|
|
52
|
+
: options.assignees;
|
|
53
|
+
if (options.assignees.length > 0) {
|
|
54
|
+
await (0, addAssigneesToPullRequest_1.addAssigneesToPullRequest)({
|
|
55
|
+
...options,
|
|
56
|
+
pullNumber: targetPullRequest.number,
|
|
57
|
+
assignees,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// add reviewers to target pull request
|
|
61
|
+
if (options.reviewers.length > 0) {
|
|
62
|
+
await (0, addReviewersToPullRequest_1.addReviewersToPullRequest)(options, targetPullRequest.number, options.reviewers);
|
|
63
|
+
}
|
|
64
|
+
// add labels to target pull request
|
|
65
|
+
if (options.targetPRLabels.length > 0) {
|
|
66
|
+
const labels = (0, getTargetPRLabels_1.getTargetPRLabels)({
|
|
67
|
+
interactive: options.interactive,
|
|
68
|
+
targetPRLabels: options.targetPRLabels,
|
|
69
|
+
commits,
|
|
70
|
+
targetBranch,
|
|
71
|
+
});
|
|
72
|
+
await (0, addLabelsToPullRequest_1.addLabelsToPullRequest)({
|
|
73
|
+
...options,
|
|
74
|
+
pullNumber: targetPullRequest.number,
|
|
75
|
+
labels,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
// make PR auto mergable
|
|
79
|
+
if (options.autoMerge) {
|
|
80
|
+
await (0, enablePullRequestAutoMerge_1.enablePullRequestAutoMerge)(options, targetPullRequest.number);
|
|
81
|
+
}
|
|
82
|
+
// add labels to source pull requests
|
|
83
|
+
if (options.sourcePRLabels.length > 0) {
|
|
84
|
+
const promises = commits.map((commit) => {
|
|
85
|
+
if (commit.sourcePullRequest) {
|
|
86
|
+
return (0, addLabelsToPullRequest_1.addLabelsToPullRequest)({
|
|
87
|
+
...options,
|
|
88
|
+
pullNumber: commit.sourcePullRequest.number,
|
|
89
|
+
labels: options.sourcePRLabels,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
await Promise.all(promises);
|
|
94
|
+
}
|
|
95
|
+
(0, logger_1.consoleLog)(`View pull request: ${targetPullRequest.url}`);
|
|
96
|
+
return targetPullRequest;
|
|
97
|
+
}
|
|
98
|
+
exports.cherrypickAndCreateTargetPullRequest = cherrypickAndCreateTargetPullRequest;
|
|
File without changes
|
|
@@ -29,10 +29,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
const os_1 = __importDefault(require("os"));
|
|
30
30
|
const nock_1 = __importDefault(require("nock"));
|
|
31
31
|
const ora_1 = __importDefault(require("ora"));
|
|
32
|
-
const nockHelpers_1 = require("
|
|
32
|
+
const nockHelpers_1 = require("../../test/nockHelpers");
|
|
33
|
+
const childProcess = __importStar(require("../child-process-promisified"));
|
|
34
|
+
const logger = __importStar(require("../logger"));
|
|
33
35
|
const cherrypickAndCreateTargetPullRequest_1 = require("./cherrypickAndCreateTargetPullRequest");
|
|
34
|
-
const childProcess = __importStar(require("./child-process-promisified"));
|
|
35
|
-
const logger = __importStar(require("./logger"));
|
|
36
36
|
describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
37
37
|
let execSpy;
|
|
38
38
|
let addLabelsScope;
|
|
@@ -63,10 +63,11 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
63
63
|
const options = {
|
|
64
64
|
assignees: [],
|
|
65
65
|
authenticatedUsername: 'sqren_authenticated',
|
|
66
|
-
gitAuthorName: 'Soren L',
|
|
67
|
-
gitAuthorEmail: 'soren@louv.dk',
|
|
68
66
|
author: 'sqren',
|
|
69
67
|
fork: true,
|
|
68
|
+
gitAuthorEmail: 'soren@louv.dk',
|
|
69
|
+
gitAuthorName: 'Soren L',
|
|
70
|
+
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
70
71
|
interactive: true,
|
|
71
72
|
prTitle: '[{targetBranch}] {commitMessages}',
|
|
72
73
|
repoForkOwner: 'sqren',
|
|
@@ -76,7 +77,6 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
76
77
|
sourceBranch: 'myDefaultSourceBranch',
|
|
77
78
|
sourcePRLabels: [],
|
|
78
79
|
targetPRLabels: ['backport'],
|
|
79
|
-
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
80
80
|
};
|
|
81
81
|
const commits = [
|
|
82
82
|
{
|
|
@@ -93,6 +93,7 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
93
93
|
message: 'My original commit message (#1000)',
|
|
94
94
|
},
|
|
95
95
|
sourcePullRequest: {
|
|
96
|
+
labels: [],
|
|
96
97
|
url: 'foo',
|
|
97
98
|
number: 1000,
|
|
98
99
|
mergeCommit: {
|
|
@@ -100,7 +101,7 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
100
101
|
message: 'My original commit message (#1000)',
|
|
101
102
|
},
|
|
102
103
|
},
|
|
103
|
-
|
|
104
|
+
targetPullRequestStates: [],
|
|
104
105
|
},
|
|
105
106
|
{
|
|
106
107
|
author: {
|
|
@@ -116,6 +117,7 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
116
117
|
message: 'My other commit message (#2000)',
|
|
117
118
|
},
|
|
118
119
|
sourcePullRequest: {
|
|
120
|
+
labels: [],
|
|
119
121
|
url: 'foo',
|
|
120
122
|
number: 2000,
|
|
121
123
|
mergeCommit: {
|
|
@@ -123,7 +125,7 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
123
125
|
message: 'My other commit message (#2000)',
|
|
124
126
|
},
|
|
125
127
|
},
|
|
126
|
-
|
|
128
|
+
targetPullRequestStates: [],
|
|
127
129
|
},
|
|
128
130
|
];
|
|
129
131
|
(0, nockHelpers_1.mockGqlRequest)({
|
|
@@ -226,7 +228,7 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
226
228
|
message: 'My original commit message',
|
|
227
229
|
},
|
|
228
230
|
sourceBranch: '7.x',
|
|
229
|
-
|
|
231
|
+
targetPullRequestStates: [],
|
|
230
232
|
},
|
|
231
233
|
];
|
|
232
234
|
(0, nockHelpers_1.mockGqlRequest)({
|
|
@@ -314,7 +316,7 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
314
316
|
message: 'My original commit message',
|
|
315
317
|
},
|
|
316
318
|
sourceBranch: '7.x',
|
|
317
|
-
|
|
319
|
+
targetPullRequestStates: [],
|
|
318
320
|
},
|
|
319
321
|
],
|
|
320
322
|
targetBranch: '6.x',
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBackportBranchName = void 0;
|
|
4
|
+
const commitFormatters_1 = require("../github/commitFormatters");
|
|
5
|
+
/*
|
|
6
|
+
* Returns the name of the backport branch without remote name
|
|
7
|
+
*
|
|
8
|
+
* Examples:
|
|
9
|
+
* For a single PR: `backport/7.x/pr-1234`
|
|
10
|
+
* For a single commit: `backport/7.x/commit-abcdef`
|
|
11
|
+
* For multiple: `backport/7.x/pr-1234_commit-abcdef`
|
|
12
|
+
*/
|
|
13
|
+
function getBackportBranchName(targetBranch, commits) {
|
|
14
|
+
const refValues = commits
|
|
15
|
+
.map((commit) => commit.sourcePullRequest
|
|
16
|
+
? `pr-${commit.sourcePullRequest.number}`
|
|
17
|
+
: `commit-${(0, commitFormatters_1.getShortSha)(commit.sourceCommit.sha)}`)
|
|
18
|
+
.join('_')
|
|
19
|
+
.slice(0, 200);
|
|
20
|
+
return `backport/${targetBranch}/${refValues}`;
|
|
21
|
+
}
|
|
22
|
+
exports.getBackportBranchName = getBackportBranchName;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Commit } from '
|
|
2
|
-
import { ValidConfigOptions } from '
|
|
1
|
+
import { Commit } from '../../entrypoint.module';
|
|
2
|
+
import { ValidConfigOptions } from '../../options/options';
|
|
3
3
|
export declare function getCommitsWithoutBackports({ options, commit, targetBranch, conflictingFiles, }: {
|
|
4
4
|
options: ValidConfigOptions;
|
|
5
5
|
commit: Commit;
|
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getCommitsWithoutBackports = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const git_1 = require("
|
|
9
|
-
const commitFormatters_1 = require("
|
|
10
|
-
const fetchCommitsByAuthor_1 = require("
|
|
8
|
+
const git_1 = require("../git");
|
|
9
|
+
const commitFormatters_1 = require("../github/commitFormatters");
|
|
10
|
+
const fetchCommitsByAuthor_1 = require("../github/v4/fetchCommits/fetchCommitsByAuthor");
|
|
11
11
|
// when the user is facing a git conflict we should help them understand
|
|
12
12
|
// why the conflict occurs. In many cases it's because one or more commits haven't been backported yet
|
|
13
13
|
async function getCommitsWithoutBackports({ options,
|
|
@@ -40,12 +40,12 @@ conflictingFiles, }) {
|
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
42
|
// only include commit if it has an unmerged PR for the given target branch
|
|
43
|
-
const hasUnmergedPr = c.
|
|
43
|
+
const hasUnmergedPr = c.targetPullRequestStates.some((pr) => pr.branch === targetBranch && pr.state !== 'MERGED');
|
|
44
44
|
return hasUnmergedPr;
|
|
45
45
|
})
|
|
46
46
|
.slice(0, 10) // limit to max 10 commits
|
|
47
47
|
.map(async (c) => {
|
|
48
|
-
const results = await Promise.all(c.
|
|
48
|
+
const results = await Promise.all(c.targetPullRequestStates.map(async (targetPr) => {
|
|
49
49
|
if (!targetPr.mergeCommit) {
|
|
50
50
|
return false;
|
|
51
51
|
}
|
|
@@ -58,7 +58,7 @@ conflictingFiles, }) {
|
|
|
58
58
|
.filter(({ isCommitInBranch }) => !isCommitInBranch)
|
|
59
59
|
.map(({ c }) => {
|
|
60
60
|
// get pull request for the target branch (if it exists)
|
|
61
|
-
const pendingBackportPr = c.
|
|
61
|
+
const pendingBackportPr = c.targetPullRequestStates.find((pr) => pr.branch === targetBranch && pr.state === 'OPEN');
|
|
62
62
|
const formatted = pendingBackportPr
|
|
63
63
|
? ` - ${(0, commitFormatters_1.getFirstLine)(c.sourceCommit.message)} ${chalk_1.default.gray('(backport pending)')}\n ${pendingBackportPr.url}`
|
|
64
64
|
: ` - ${(0, commitFormatters_1.getFirstLine)(c.sourceCommit.message)} ${chalk_1.default.red('(backport missing)')}\n ${c.sourcePullRequest?.url}`;
|