backport 8.4.3 → 8.5.1
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.d.ts +2 -2
- package/dist/entrypoint.module.js +9 -8
- package/dist/entrypoint.module.private.test.js +79 -29
- package/dist/lib/cherrypickAndCreateTargetPullRequest.js +1 -1
- package/dist/lib/cherrypickAndCreateTargetPullRequest.test.js +12 -4
- package/dist/lib/child-process-promisified.d.ts +1 -1
- package/dist/lib/child-process-promisified.js +14 -3
- package/dist/lib/getCommits.js +14 -9
- package/dist/lib/getCommitsWithoutBackports.js +3 -3
- package/dist/lib/getCommitsWithoutBackports.test.js +38 -15
- package/dist/lib/getTargetBranches.d.ts +1 -1
- package/dist/lib/getTargetBranches.js +6 -10
- package/dist/lib/getTargetBranches.test.js +9 -5
- package/dist/lib/git.d.ts +2 -2
- package/dist/lib/git.js +1 -1
- package/dist/lib/git.private.test.js +18 -1
- package/dist/lib/git.test.js +3 -1
- package/dist/lib/github/v3/createPullRequest.test.js +39 -13
- package/dist/lib/github/v3/createStatusComment.js +5 -2
- package/dist/lib/github/v3/createStatusComment.test.js +7 -3
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +20 -1
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +32 -10
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.js +9 -1
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +49 -14
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +15 -5
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +41 -11
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -1
- package/dist/lib/prompt.test.js +37 -9
- package/dist/lib/prompts.js +5 -2
- package/dist/lib/setupRepo.js +3 -3
- package/dist/lib/setupRepo.test.js +5 -5
- package/dist/lib/sourceCommit/getPullRequestStates.d.ts +27 -0
- package/dist/lib/sourceCommit/{getExpectedTargetPullRequests.js → getPullRequestStates.js} +62 -27
- package/dist/lib/sourceCommit/{getExpectedTargetPullRequests.test.d.ts → getPullRequestStates.test.d.ts} +0 -0
- package/dist/lib/sourceCommit/{getExpectedTargetPullRequests.test.js → getPullRequestStates.test.js} +283 -87
- package/dist/lib/sourceCommit/parseSourceCommit.d.ts +4 -2
- package/dist/lib/sourceCommit/parseSourceCommit.js +20 -5
- package/dist/lib/sourceCommit/parseSourceCommit.test.js +78 -25
- package/dist/options/ConfigOptions.d.ts +1 -1
- package/dist/options/config/config.d.ts +1 -1
- package/dist/options/config/readConfigFile.d.ts +1 -1
- package/dist/options/options.d.ts +1 -1
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +2 -2
- package/dist/test/e2e/cli/repo-with-changing-branchLabelMapping.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/repo-with-changing-branchLabelMapping.private.test.js +95 -0
- package/dist/test/e2e/module/entrypoint.module.mutation.test.js +11 -4
- package/dist/test/handleUnbackportedPullRequests.private.test.js +10 -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 +13 -13
- package/yarn.lock +512 -425
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.d.ts +0 -16
|
@@ -10,7 +10,7 @@ export type { ConfigFileOptions } from './options/ConfigOptions';
|
|
|
10
10
|
export { fetchRemoteProjectConfig as getRemoteProjectConfig } from './lib/github/v4/fetchRemoteProjectConfig';
|
|
11
11
|
export { getGlobalConfig as getLocalGlobalConfig } from './options/config/globalConfig';
|
|
12
12
|
export declare function backportRun({ options, processArgs, exitCodeOnFailure, }: {
|
|
13
|
-
options
|
|
13
|
+
options?: ConfigFileOptions;
|
|
14
14
|
processArgs?: string[];
|
|
15
15
|
exitCodeOnFailure?: boolean;
|
|
16
16
|
}): Promise<BackportResponse>;
|
|
@@ -26,7 +26,7 @@ export declare function getCommits(options: {
|
|
|
26
26
|
maxNumber?: number;
|
|
27
27
|
onlyMissing?: boolean;
|
|
28
28
|
prFilter?: string;
|
|
29
|
-
pullNumber?: number;
|
|
29
|
+
pullNumber?: number | number[];
|
|
30
30
|
sha?: string | string[];
|
|
31
31
|
skipRemoteConfig?: boolean;
|
|
32
32
|
sourceBranch?: string;
|
|
@@ -15,7 +15,7 @@ var fetchRemoteProjectConfig_1 = require("./lib/github/v4/fetchRemoteProjectConf
|
|
|
15
15
|
Object.defineProperty(exports, "getRemoteProjectConfig", { enumerable: true, get: function () { return fetchRemoteProjectConfig_1.fetchRemoteProjectConfig; } });
|
|
16
16
|
var globalConfig_1 = require("./options/config/globalConfig");
|
|
17
17
|
Object.defineProperty(exports, "getLocalGlobalConfig", { enumerable: true, get: function () { return globalConfig_1.getGlobalConfig; } });
|
|
18
|
-
function backportRun({ options, processArgs = [], exitCodeOnFailure = true, }) {
|
|
18
|
+
function backportRun({ options = {}, processArgs = [], exitCodeOnFailure = true, }) {
|
|
19
19
|
return (0, backportRun_1.backportRun)({
|
|
20
20
|
optionsFromModule: (0, excludeUndefined_1.excludeUndefined)(options),
|
|
21
21
|
processArgs,
|
|
@@ -27,13 +27,14 @@ async function getCommits(options) {
|
|
|
27
27
|
(0, logger_1.initLogger)({ interactive: false, accessToken: options.accessToken });
|
|
28
28
|
const optionsFromGithub = await (0, getOptionsFromGithub_1.getOptionsFromGithub)(options);
|
|
29
29
|
if (options.pullNumber) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
const pullNumbers = Array.isArray(options.pullNumber)
|
|
31
|
+
? options.pullNumber
|
|
32
|
+
: [options.pullNumber];
|
|
33
|
+
return Promise.all(pullNumbers.map((pullNumber) => (0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)({
|
|
34
|
+
...optionsFromGithub,
|
|
35
|
+
...options,
|
|
36
|
+
pullNumber,
|
|
37
|
+
})));
|
|
37
38
|
}
|
|
38
39
|
if (options.sha) {
|
|
39
40
|
const shas = Array.isArray(options.sha) ? options.sha : [options.sha];
|
|
@@ -114,8 +114,14 @@ describe('entrypoint.module', () => {
|
|
|
114
114
|
email: 'sorenlouv@gmail.com',
|
|
115
115
|
name: 'Søren Louv-Jansen',
|
|
116
116
|
},
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
suggestedTargetBranches: ['7.x'],
|
|
118
|
+
pullRequestStates: [
|
|
119
|
+
{
|
|
120
|
+
branch: '7.x',
|
|
121
|
+
label: 'backport-to-7.x',
|
|
122
|
+
isSourceBranch: false,
|
|
123
|
+
state: 'NOT_CREATED',
|
|
124
|
+
},
|
|
119
125
|
],
|
|
120
126
|
sourceBranch: 'main',
|
|
121
127
|
sourceCommit: {
|
|
@@ -148,7 +154,13 @@ describe('entrypoint.module', () => {
|
|
|
148
154
|
const expectedCommits = [
|
|
149
155
|
{
|
|
150
156
|
author: { name: 'Søren Louv-Jansen', email: 'sorenlouv@gmail.com' },
|
|
157
|
+
suggestedTargetBranches: [],
|
|
151
158
|
sourceCommit: {
|
|
159
|
+
branchLabelMapping: {
|
|
160
|
+
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
161
|
+
'^v7.12.0$': '7.x',
|
|
162
|
+
'^v8.0.0$': 'master',
|
|
163
|
+
},
|
|
152
164
|
committedDate: '2021-01-13T20:01:44Z',
|
|
153
165
|
message: '[APM] Fix incorrect table column header (95th instead of avg) (#88188)',
|
|
154
166
|
sha: 'd1b348e6213c5ad48653dfaad6eaf4928b2c688b',
|
|
@@ -162,26 +174,28 @@ describe('entrypoint.module', () => {
|
|
|
162
174
|
},
|
|
163
175
|
},
|
|
164
176
|
sourceBranch: 'master',
|
|
165
|
-
|
|
177
|
+
pullRequestStates: [
|
|
166
178
|
{
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
state: 'MERGED',
|
|
179
|
+
branch: '7.11',
|
|
180
|
+
isSourceBranch: false,
|
|
181
|
+
label: 'v7.11.0',
|
|
171
182
|
mergeCommit: {
|
|
172
|
-
|
|
173
|
-
|
|
183
|
+
message: '[APM] Fix incorrect table column header (95th instead of avg) (#88188) (#88289)',
|
|
184
|
+
sha: 'b8194e9ec27d69f485d8b194d1cb5e4f6d8fef6d',
|
|
174
185
|
},
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
url: 'https://github.com/elastic/kibana/pull/88289',
|
|
178
186
|
number: 88289,
|
|
179
|
-
branch: '7.11',
|
|
180
187
|
state: 'MERGED',
|
|
188
|
+
url: 'https://github.com/elastic/kibana/pull/88289',
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
branch: '7.x',
|
|
181
192
|
mergeCommit: {
|
|
182
|
-
|
|
183
|
-
|
|
193
|
+
message: '[7.x] [APM] Fix incorrect table column header (95th instead of avg) (#88188) (#88288)\n\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>',
|
|
194
|
+
sha: '52710be7add6811ec4783c7d383d4159c0aa76f5',
|
|
184
195
|
},
|
|
196
|
+
number: 88288,
|
|
197
|
+
state: 'MERGED',
|
|
198
|
+
url: 'https://github.com/elastic/kibana/pull/88288',
|
|
185
199
|
},
|
|
186
200
|
],
|
|
187
201
|
},
|
|
@@ -198,7 +212,13 @@ describe('entrypoint.module', () => {
|
|
|
198
212
|
const expectedCommits = [
|
|
199
213
|
{
|
|
200
214
|
author: { name: 'Søren Louv-Jansen', email: 'sorenlouv@gmail.com' },
|
|
215
|
+
suggestedTargetBranches: [],
|
|
201
216
|
sourceCommit: {
|
|
217
|
+
branchLabelMapping: {
|
|
218
|
+
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
219
|
+
'^v7.12.0$': '7.x',
|
|
220
|
+
'^v8.0.0$': 'master',
|
|
221
|
+
},
|
|
202
222
|
committedDate: '2021-01-13T20:01:44Z',
|
|
203
223
|
message: '[APM] Fix incorrect table column header (95th instead of avg) (#88188)',
|
|
204
224
|
sha: 'd1b348e6213c5ad48653dfaad6eaf4928b2c688b',
|
|
@@ -212,27 +232,29 @@ describe('entrypoint.module', () => {
|
|
|
212
232
|
},
|
|
213
233
|
},
|
|
214
234
|
sourceBranch: 'master',
|
|
215
|
-
|
|
216
|
-
{
|
|
217
|
-
url: 'https://github.com/elastic/kibana/pull/88288',
|
|
218
|
-
number: 88288,
|
|
219
|
-
branch: '7.x',
|
|
220
|
-
state: 'MERGED',
|
|
221
|
-
mergeCommit: {
|
|
222
|
-
sha: '52710be7add6811ec4783c7d383d4159c0aa76f5',
|
|
223
|
-
message: '[7.x] [APM] Fix incorrect table column header (95th instead of avg) (#88188) (#88288)\n\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>',
|
|
224
|
-
},
|
|
225
|
-
},
|
|
235
|
+
pullRequestStates: [
|
|
226
236
|
{
|
|
227
237
|
url: 'https://github.com/elastic/kibana/pull/88289',
|
|
228
238
|
number: 88289,
|
|
229
239
|
branch: '7.11',
|
|
240
|
+
label: 'v7.11.0',
|
|
241
|
+
isSourceBranch: false,
|
|
230
242
|
state: 'MERGED',
|
|
231
243
|
mergeCommit: {
|
|
232
244
|
sha: 'b8194e9ec27d69f485d8b194d1cb5e4f6d8fef6d',
|
|
233
245
|
message: '[APM] Fix incorrect table column header (95th instead of avg) (#88188) (#88289)',
|
|
234
246
|
},
|
|
235
247
|
},
|
|
248
|
+
{
|
|
249
|
+
url: 'https://github.com/elastic/kibana/pull/88288',
|
|
250
|
+
number: 88288,
|
|
251
|
+
branch: '7.x',
|
|
252
|
+
state: 'MERGED',
|
|
253
|
+
mergeCommit: {
|
|
254
|
+
sha: '52710be7add6811ec4783c7d383d4159c0aa76f5',
|
|
255
|
+
message: '[7.x] [APM] Fix incorrect table column header (95th instead of avg) (#88188) (#88288)\n\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>',
|
|
256
|
+
},
|
|
257
|
+
},
|
|
236
258
|
],
|
|
237
259
|
},
|
|
238
260
|
];
|
|
@@ -251,21 +273,25 @@ describe('entrypoint.module', () => {
|
|
|
251
273
|
return {
|
|
252
274
|
...commit.sourceCommit,
|
|
253
275
|
message: (0, commitFormatters_1.getFirstLine)(commit.sourceCommit.message),
|
|
276
|
+
branchLabelMapping: undefined,
|
|
254
277
|
};
|
|
255
278
|
});
|
|
256
279
|
expect(commitMessage).toMatchInlineSnapshot(`
|
|
257
280
|
Array [
|
|
258
281
|
Object {
|
|
282
|
+
"branchLabelMapping": undefined,
|
|
259
283
|
"committedDate": "2021-05-28T12:41:42Z",
|
|
260
284
|
"message": "[Observability] Fix typo in readme for new navigation (#100861)",
|
|
261
285
|
"sha": "79945fe0275b2ec9c93747e26154110133ec51fb",
|
|
262
286
|
},
|
|
263
287
|
Object {
|
|
288
|
+
"branchLabelMapping": undefined,
|
|
264
289
|
"committedDate": "2021-05-28T19:43:30Z",
|
|
265
290
|
"message": "[APM] Move APM tutorial from apm_oss to x-pack/apm (#100780)",
|
|
266
291
|
"sha": "0bcd78b0e999feb95057f5e6eafdb572b9b2fe39",
|
|
267
292
|
},
|
|
268
293
|
Object {
|
|
294
|
+
"branchLabelMapping": undefined,
|
|
269
295
|
"committedDate": "2021-05-18T10:33:16Z",
|
|
270
296
|
"message": "Migrate from Joi to @kbn/config-schema in \\"home\\" and \\"features\\" plugins (#100201)",
|
|
271
297
|
"sha": "574f6595ad2e5452fa90e6a3111220a599e473c0",
|
|
@@ -289,9 +315,11 @@ describe('entrypoint.module', () => {
|
|
|
289
315
|
"email": "sorenlouv@gmail.com",
|
|
290
316
|
"name": "Søren Louv-Jansen",
|
|
291
317
|
},
|
|
292
|
-
"
|
|
318
|
+
"pullRequestStates": Array [
|
|
293
319
|
Object {
|
|
294
320
|
"branch": "7.x",
|
|
321
|
+
"isSourceBranch": false,
|
|
322
|
+
"label": "v7.11.0",
|
|
295
323
|
"mergeCommit": Object {
|
|
296
324
|
"message": "[APM] Fix broken link to ML when time range is not set (#85976) (#86227)
|
|
297
325
|
|
|
@@ -315,6 +343,11 @@ describe('entrypoint.module', () => {
|
|
|
315
343
|
],
|
|
316
344
|
"sourceBranch": "master",
|
|
317
345
|
"sourceCommit": Object {
|
|
346
|
+
"branchLabelMapping": Object {
|
|
347
|
+
"^v(\\\\d+).(\\\\d+).\\\\d+$": "$1.$2",
|
|
348
|
+
"^v7.11.0$": "7.x",
|
|
349
|
+
"^v8.0.0$": "master",
|
|
350
|
+
},
|
|
318
351
|
"committedDate": "2020-12-16T15:17:03Z",
|
|
319
352
|
"message": "[APM] Fix broken link to ML when time range is not set (#85976)",
|
|
320
353
|
"sha": "744d6809ded7e1055bfda280c351cee3e8c0e3bf",
|
|
@@ -327,15 +360,18 @@ describe('entrypoint.module', () => {
|
|
|
327
360
|
"number": 85976,
|
|
328
361
|
"url": "https://github.com/elastic/kibana/pull/85976",
|
|
329
362
|
},
|
|
363
|
+
"suggestedTargetBranches": Array [],
|
|
330
364
|
},
|
|
331
365
|
Object {
|
|
332
366
|
"author": Object {
|
|
333
367
|
"email": "sorenlouv@gmail.com",
|
|
334
368
|
"name": "Søren Louv-Jansen",
|
|
335
369
|
},
|
|
336
|
-
"
|
|
370
|
+
"pullRequestStates": Array [
|
|
337
371
|
Object {
|
|
338
372
|
"branch": "7.x",
|
|
373
|
+
"isSourceBranch": false,
|
|
374
|
+
"label": "v7.11.0",
|
|
339
375
|
"mergeCommit": Object {
|
|
340
376
|
"message": "[7.x] [APM] Correlations polish (#85116) (#85940)
|
|
341
377
|
|
|
@@ -349,6 +385,11 @@ describe('entrypoint.module', () => {
|
|
|
349
385
|
],
|
|
350
386
|
"sourceBranch": "master",
|
|
351
387
|
"sourceCommit": Object {
|
|
388
|
+
"branchLabelMapping": Object {
|
|
389
|
+
"^v(\\\\d+).(\\\\d+).\\\\d+$": "$1.$2",
|
|
390
|
+
"^v7.11.0$": "7.x",
|
|
391
|
+
"^v8.0.0$": "master",
|
|
392
|
+
},
|
|
352
393
|
"committedDate": "2020-12-15T12:15:00Z",
|
|
353
394
|
"message": "[APM] Correlations polish (#85116)
|
|
354
395
|
|
|
@@ -365,15 +406,18 @@ describe('entrypoint.module', () => {
|
|
|
365
406
|
"number": 85116,
|
|
366
407
|
"url": "https://github.com/elastic/kibana/pull/85116",
|
|
367
408
|
},
|
|
409
|
+
"suggestedTargetBranches": Array [],
|
|
368
410
|
},
|
|
369
411
|
Object {
|
|
370
412
|
"author": Object {
|
|
371
413
|
"email": "sorenlouv@gmail.com",
|
|
372
414
|
"name": "Søren Louv-Jansen",
|
|
373
415
|
},
|
|
374
|
-
"
|
|
416
|
+
"pullRequestStates": Array [
|
|
375
417
|
Object {
|
|
376
418
|
"branch": "7.x",
|
|
419
|
+
"isSourceBranch": false,
|
|
420
|
+
"label": "v7.11.0",
|
|
377
421
|
"mergeCommit": Object {
|
|
378
422
|
"message": "[7.x] [APM] Improve pointer event hook (#85117) (#85142)",
|
|
379
423
|
"sha": "3b72a4f3cc7c0abd0541073e1d0246b85cea3def",
|
|
@@ -385,6 +429,11 @@ describe('entrypoint.module', () => {
|
|
|
385
429
|
],
|
|
386
430
|
"sourceBranch": "master",
|
|
387
431
|
"sourceCommit": Object {
|
|
432
|
+
"branchLabelMapping": Object {
|
|
433
|
+
"^v(\\\\d+).(\\\\d+).\\\\d+$": "$1.$2",
|
|
434
|
+
"^v7.11.0$": "7.x",
|
|
435
|
+
"^v8.0.0$": "master",
|
|
436
|
+
},
|
|
388
437
|
"committedDate": "2020-12-07T14:43:58Z",
|
|
389
438
|
"message": "[APM] Improve pointer event hook (#85117)",
|
|
390
439
|
"sha": "cee681afb3c5f87371112fab9a7e5dddbafea0a8",
|
|
@@ -397,6 +446,7 @@ describe('entrypoint.module', () => {
|
|
|
397
446
|
"number": 85117,
|
|
398
447
|
"url": "https://github.com/elastic/kibana/pull/85117",
|
|
399
448
|
},
|
|
449
|
+
"suggestedTargetBranches": Array [],
|
|
400
450
|
},
|
|
401
451
|
]
|
|
402
452
|
`);
|
|
@@ -143,7 +143,7 @@ async function waitForCherrypick(options, commit, targetBranch, gitConfigAuthor)
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
async function cherrypickAndHandleConflicts({ options, commit, commitAuthor, targetBranch, cherrypickSpinner, }) {
|
|
146
|
-
const mergedTargetPullRequest = commit.
|
|
146
|
+
const mergedTargetPullRequest = commit.pullRequestStates.find((pr) => pr.state === 'MERGED' && pr.branch === targetBranch);
|
|
147
147
|
let conflictingFiles;
|
|
148
148
|
let unstagedFiles;
|
|
149
149
|
let needsResolving;
|
|
@@ -84,7 +84,9 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
84
84
|
name: 'Søren Louv-Jansen',
|
|
85
85
|
},
|
|
86
86
|
sourceBranch: '7.x',
|
|
87
|
+
suggestedTargetBranches: [],
|
|
87
88
|
sourceCommit: {
|
|
89
|
+
branchLabelMapping: {},
|
|
88
90
|
committedDate: 'fff',
|
|
89
91
|
sha: 'mySha',
|
|
90
92
|
message: 'My original commit message (#1000)',
|
|
@@ -97,7 +99,7 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
97
99
|
message: 'My original commit message (#1000)',
|
|
98
100
|
},
|
|
99
101
|
},
|
|
100
|
-
|
|
102
|
+
pullRequestStates: [],
|
|
101
103
|
},
|
|
102
104
|
{
|
|
103
105
|
author: {
|
|
@@ -105,7 +107,9 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
105
107
|
name: 'Søren Louv-Jansen',
|
|
106
108
|
},
|
|
107
109
|
sourceBranch: '7.x',
|
|
110
|
+
suggestedTargetBranches: [],
|
|
108
111
|
sourceCommit: {
|
|
112
|
+
branchLabelMapping: {},
|
|
109
113
|
committedDate: 'ggg',
|
|
110
114
|
sha: 'mySha2',
|
|
111
115
|
message: 'My other commit message (#2000)',
|
|
@@ -118,7 +122,7 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
118
122
|
message: 'My other commit message (#2000)',
|
|
119
123
|
},
|
|
120
124
|
},
|
|
121
|
-
|
|
125
|
+
pullRequestStates: [],
|
|
122
126
|
},
|
|
123
127
|
];
|
|
124
128
|
const scope = (0, nock_1.default)('https://api.github.com')
|
|
@@ -206,13 +210,15 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
206
210
|
email: 'soren.louv@elastic.co',
|
|
207
211
|
name: 'Søren Louv-Jansen',
|
|
208
212
|
},
|
|
213
|
+
suggestedTargetBranches: [],
|
|
209
214
|
sourceCommit: {
|
|
215
|
+
branchLabelMapping: {},
|
|
210
216
|
committedDate: 'hhh',
|
|
211
217
|
sha: 'mySha',
|
|
212
218
|
message: 'My original commit message',
|
|
213
219
|
},
|
|
214
220
|
sourceBranch: '7.x',
|
|
215
|
-
|
|
221
|
+
pullRequestStates: [],
|
|
216
222
|
},
|
|
217
223
|
];
|
|
218
224
|
const scope = (0, nock_1.default)('https://api.github.com')
|
|
@@ -282,13 +288,15 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
282
288
|
email: 'soren.louv@elastic.co',
|
|
283
289
|
name: 'Søren Louv-Jansen',
|
|
284
290
|
},
|
|
291
|
+
suggestedTargetBranches: [],
|
|
285
292
|
sourceCommit: {
|
|
293
|
+
branchLabelMapping: {},
|
|
286
294
|
committedDate: '2021-08-18T16:11:38Z',
|
|
287
295
|
sha: 'mySha',
|
|
288
296
|
message: 'My original commit message',
|
|
289
297
|
},
|
|
290
298
|
sourceBranch: '7.x',
|
|
291
|
-
|
|
299
|
+
pullRequestStates: [],
|
|
292
300
|
},
|
|
293
301
|
],
|
|
294
302
|
targetBranch: '6.x',
|
|
@@ -12,7 +12,7 @@ export declare function spawnPromise(cmd: string, cmdArgs: string[], cwd: string
|
|
|
12
12
|
stderr: string;
|
|
13
13
|
stdout: string;
|
|
14
14
|
}>;
|
|
15
|
-
export declare const
|
|
15
|
+
export declare const spawnStream: (cmd: string, cmdArgs: ReadonlyArray<string>) => childProcess.ChildProcessWithoutNullStreams;
|
|
16
16
|
export declare type SpawnErrorContext = {
|
|
17
17
|
cmdArgs: string[];
|
|
18
18
|
code: number;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SpawnError = exports.
|
|
6
|
+
exports.SpawnError = exports.spawnStream = exports.spawnPromise = exports.exec = void 0;
|
|
7
7
|
const child_process_1 = __importDefault(require("child_process"));
|
|
8
8
|
const util_1 = require("util");
|
|
9
9
|
const logger_1 = require("./logger");
|
|
@@ -12,6 +12,8 @@ async function exec(cmd, options) {
|
|
|
12
12
|
const res = await execPromisified(cmd, {
|
|
13
13
|
maxBuffer: 100 * 1024 * 1024,
|
|
14
14
|
...options,
|
|
15
|
+
// ensure that git commands return english error messages
|
|
16
|
+
env: { ...process.env, LANG: 'en_US' },
|
|
15
17
|
});
|
|
16
18
|
return res;
|
|
17
19
|
}
|
|
@@ -20,7 +22,11 @@ async function spawnPromise(cmd, cmdArgs, cwd) {
|
|
|
20
22
|
const fullCmd = `${cmd} ${cmdArgs.join(' ')}`;
|
|
21
23
|
logger_1.logger.info(`Running command: "${fullCmd}"`);
|
|
22
24
|
return new Promise(function (resolve, reject) {
|
|
23
|
-
const subprocess = child_process_1.default.spawn(cmd, cmdArgs, {
|
|
25
|
+
const subprocess = child_process_1.default.spawn(cmd, cmdArgs, {
|
|
26
|
+
cwd,
|
|
27
|
+
// ensure that git commands return english error messages
|
|
28
|
+
env: { ...process.env, LANG: 'en_US' },
|
|
29
|
+
});
|
|
24
30
|
let stderr = '';
|
|
25
31
|
let stdout = '';
|
|
26
32
|
subprocess.stdout.on('data', (data) => {
|
|
@@ -45,7 +51,12 @@ async function spawnPromise(cmd, cmdArgs, cwd) {
|
|
|
45
51
|
});
|
|
46
52
|
}
|
|
47
53
|
exports.spawnPromise = spawnPromise;
|
|
48
|
-
|
|
54
|
+
const spawnStream = (cmd, cmdArgs) => {
|
|
55
|
+
return child_process_1.default.spawn(cmd, cmdArgs, {
|
|
56
|
+
env: { ...process.env, LANG: 'en_US' },
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
exports.spawnStream = spawnStream;
|
|
49
60
|
class SpawnError extends Error {
|
|
50
61
|
constructor(context) {
|
|
51
62
|
const cmdArgs = context.cmdArgs.join(' ');
|
package/dist/lib/getCommits.js
CHANGED
|
@@ -24,21 +24,26 @@ async function getCommits(options) {
|
|
|
24
24
|
try {
|
|
25
25
|
if (options.sha) {
|
|
26
26
|
const shas = Array.isArray(options.sha) ? options.sha : [options.sha];
|
|
27
|
-
// TODO: use Intl.ListFormat to format the sha's
|
|
28
27
|
spinner.text = `Loading commit "${shas.map(commitFormatters_1.getShortSha)}"`;
|
|
29
28
|
const commits = await Promise.all(shas.map((sha) => (0, fetchCommitBySha_1.fetchCommitBySha)({ ...options, sha })));
|
|
30
|
-
spinner.stopAndPersist(getOraPersistsOption('Select commit', commits
|
|
29
|
+
spinner.stopAndPersist(getOraPersistsOption('Select commit', commits
|
|
30
|
+
.map((commit) => (0, commitFormatters_1.getFirstLine)(commit.sourceCommit.message))
|
|
31
|
+
.join(', ')));
|
|
31
32
|
return commits;
|
|
32
33
|
}
|
|
33
34
|
if (options.pullNumber) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const pullNumbers = Array.isArray(options.pullNumber)
|
|
36
|
+
? options.pullNumber
|
|
37
|
+
: [options.pullNumber];
|
|
38
|
+
spinner.text = `Loading pull request #${pullNumbers
|
|
39
|
+
.map((pullNumber) => `#${pullNumber}`)
|
|
40
|
+
.join(', ')}`;
|
|
41
|
+
const commits = await Promise.all(pullNumbers.map((pullNumber) => (0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)({ ...options, pullNumber })));
|
|
39
42
|
// add styles to make it look like a prompt question
|
|
40
|
-
spinner.stopAndPersist(getOraPersistsOption('Select pull request',
|
|
41
|
-
|
|
43
|
+
spinner.stopAndPersist(getOraPersistsOption('Select pull request', commits
|
|
44
|
+
.map((commit) => (0, commitFormatters_1.getFirstLine)(commit.sourceCommit.message))
|
|
45
|
+
.join(', ')));
|
|
46
|
+
return commits;
|
|
42
47
|
}
|
|
43
48
|
if (!options.interactive && !options.ls) {
|
|
44
49
|
throw new BackportError_1.BackportError('When "--interactive" is disabled either `--sha` or `--pr` must be specified');
|
|
@@ -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.pullRequestStates.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.pullRequestStates.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.pullRequestStates.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}`;
|