backport 6.0.0 → 6.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +179 -52
- package/dist/entrypoint.cli.js +2 -0
- package/dist/entrypoint.module.d.ts +16 -4
- package/dist/entrypoint.module.js +41 -13
- package/dist/entrypoint.module.private.test.d.ts +1 -0
- package/dist/entrypoint.module.private.test.js +34 -0
- package/dist/main.js +1 -2
- package/dist/options/ConfigOptions.d.ts +16 -6
- package/dist/options/cliArgs.d.ts +36 -37
- package/dist/options/cliArgs.js +25 -24
- package/dist/options/cliArgs.test.js +6 -10
- package/dist/options/config/config.d.ts +28 -52
- package/dist/options/config/config.js +2 -36
- package/dist/options/config/config.test.js +10 -27
- package/dist/options/config/getOptionsFromGit.d.ts +3 -2
- package/dist/options/config/getOptionsFromGit.js +1 -3
- package/dist/options/config/globalConfig.js +2 -5
- package/dist/options/config/globalConfig.test.js +0 -2
- package/dist/options/config/projectConfig.test.js +51 -14
- package/dist/options/config/readConfigFile.d.ts +52 -0
- package/dist/options/config/readConfigFile.js +28 -2
- package/dist/options/options.d.ts +55 -32
- package/dist/options/options.js +101 -7
- package/dist/options/options.test.js +248 -97
- package/dist/options/parseRequiredOptions.d.ts +3 -3
- package/dist/options/parseRequiredOptions.js +2 -4
- package/dist/options/parseRequiredOptions.test.js +6 -11
- package/dist/runSequentially.test.js +40 -78
- package/dist/services/git.d.ts +5 -2
- package/dist/services/git.js +11 -10
- package/dist/services/git.test.js +12 -9
- package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.js +2 -3
- package/dist/services/github/v3/addAssigneesToPullRequest.test.js +4 -5
- package/dist/services/github/v3/createPullRequest.js +10 -13
- package/dist/services/github/v3/createPullRequest.test.d.ts +1 -0
- package/dist/services/github/v3/createPullRequest.test.js +110 -0
- package/dist/services/github/v3/createStatusComment.js +12 -14
- package/dist/services/github/v3/createStatusComment.test.js +58 -29
- package/dist/services/github/v4/apiRequestV4.d.ts +1 -1
- package/dist/services/github/v4/apiRequestV4.js +1 -1
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +1 -1
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +0 -1
- package/dist/services/github/v4/fetchAuthorId.d.ts +5 -2
- package/dist/services/github/v4/fetchAuthorId.js +5 -6
- package/dist/services/github/v4/fetchAuthorId.private.test.js +3 -6
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +8 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +1 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +6 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +8 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +1 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +3 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +12 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +6 -8
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +10 -12
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +5 -7
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.d.ts +3 -0
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.js +55 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +5 -5
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +2 -6
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -2
- package/dist/services/github/v4/fetchProjectConfig.d.ts +8 -0
- package/dist/services/github/v4/fetchProjectConfig.js +56 -0
- package/dist/services/github/v4/fetchProjectConfig.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchProjectConfig.private.test.js +52 -0
- package/dist/services/github/v4/fetchProjectConfig.test.d.ts +1 -0
- package/dist/services/github/v4/fetchProjectConfig.test.js +37 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +67 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +130 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +130 -0
- package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +3 -1
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +22 -1
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +4 -1
- package/dist/services/github/v4/getOptionsFromGithub/query.js +3 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +32 -15
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +5 -1
- package/dist/services/sourceCommit/parseSourceCommit.js +2 -2
- package/dist/services/sourceCommit/parseSourceCommit.test.js +120 -5
- package/dist/test/inquirer.private.test.js +33 -36
- package/dist/test/integration/integration.private.test.js +114 -95
- package/dist/test/mockConfigFiles.d.ts +5 -0
- package/dist/test/mockConfigFiles.js +37 -0
- package/dist/test/nockHelpers.d.ts +1 -1
- package/dist/test/nockHelpers.js +4 -4
- package/dist/test/private/getDevAccessToken.js +1 -1
- package/dist/test/setupFiles/automatic-mocks.js +1 -29
- package/dist/ui/cherrypickAndCreatePullRequest.test.js +80 -28
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -9
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +13 -48
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +222 -260
- package/dist/ui/getCommits.d.ts +1 -1
- package/dist/ui/getCommitsWithoutBackports.d.ts +11 -0
- package/dist/ui/getCommitsWithoutBackports.js +53 -0
- package/dist/ui/getCommitsWithoutBackports.test.d.ts +1 -0
- package/dist/ui/getCommitsWithoutBackports.test.js +259 -0
- package/dist/ui/getTargetBranches.d.ts +2 -1
- package/dist/ui/getTargetBranches.js +17 -1
- package/dist/ui/maybeSetupRepo.js +4 -3
- package/dist/ui/maybeSetupRepo.test.js +49 -3
- package/dist/utils/excludeUndefined.d.ts +6 -0
- package/dist/utils/excludeUndefined.js +7 -0
- package/dist/utils/excludeUndefined.test.d.ts +1 -0
- package/dist/utils/excludeUndefined.test.js +24 -0
- package/package.json +9 -8
- package/yarn.lock +98 -77
|
@@ -12,7 +12,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
12
12
|
});
|
|
13
13
|
it('should return empty when there is no associated PR', () => {
|
|
14
14
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
15
|
-
|
|
15
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
16
16
|
sourcePullRequest: null,
|
|
17
17
|
});
|
|
18
18
|
const branchLabelMapping = {};
|
|
@@ -21,7 +21,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
21
21
|
});
|
|
22
22
|
it('should return a result when sourceCommit message matches the commit of the target pull request', () => {
|
|
23
23
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
24
|
-
|
|
24
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
25
25
|
sourcePullRequest: { number: 1234 },
|
|
26
26
|
timelineItems: [
|
|
27
27
|
{
|
|
@@ -45,7 +45,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
45
45
|
});
|
|
46
46
|
it('should return empty when repoName does not match', () => {
|
|
47
47
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
48
|
-
|
|
48
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
49
49
|
sourcePullRequest: { number: 1234 },
|
|
50
50
|
timelineItems: [
|
|
51
51
|
{
|
|
@@ -63,7 +63,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
63
63
|
});
|
|
64
64
|
it('should return empty when repoOwner does not match', () => {
|
|
65
65
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
66
|
-
|
|
66
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
67
67
|
sourcePullRequest: { number: 1234 },
|
|
68
68
|
timelineItems: [
|
|
69
69
|
{
|
|
@@ -81,7 +81,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
81
81
|
});
|
|
82
82
|
it('should return empty when commit messages do not match', () => {
|
|
83
83
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
84
|
-
|
|
84
|
+
sourceCommit: { message: 'message one (#1234)' },
|
|
85
85
|
sourcePullRequest: {
|
|
86
86
|
number: 1234,
|
|
87
87
|
},
|
|
@@ -100,7 +100,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
100
100
|
});
|
|
101
101
|
it('should return a result if commits messages are different but title includes message and number', () => {
|
|
102
102
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
103
|
-
|
|
103
|
+
sourceCommit: { message: 'message one (#1234)' },
|
|
104
104
|
sourcePullRequest: {
|
|
105
105
|
number: 1234,
|
|
106
106
|
},
|
|
@@ -127,7 +127,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
127
127
|
});
|
|
128
128
|
it('should return empty when only pull request title (but not pull number) matches', () => {
|
|
129
129
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
130
|
-
|
|
130
|
+
sourceCommit: { message: 'message one (#1234)' },
|
|
131
131
|
sourcePullRequest: {
|
|
132
132
|
number: 1234,
|
|
133
133
|
},
|
|
@@ -147,7 +147,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
147
147
|
});
|
|
148
148
|
it('should return a result when first line of a multiline commit message matches', () => {
|
|
149
149
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
150
|
-
|
|
150
|
+
sourceCommit: { message: 'message one (#1234)' },
|
|
151
151
|
sourcePullRequest: {
|
|
152
152
|
number: 1234,
|
|
153
153
|
},
|
|
@@ -173,7 +173,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
173
173
|
});
|
|
174
174
|
it('should return missing target pull requests', () => {
|
|
175
175
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
176
|
-
|
|
176
|
+
sourceCommit: { message: 'message one (#1234)' },
|
|
177
177
|
sourcePullRequest: {
|
|
178
178
|
number: 1234,
|
|
179
179
|
labels: ['v7.2.0', 'v7.1.0'],
|
|
@@ -192,7 +192,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
192
192
|
});
|
|
193
193
|
it('should not show merged PRs as missing', () => {
|
|
194
194
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
195
|
-
|
|
195
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
196
196
|
sourcePullRequest: {
|
|
197
197
|
number: 1234,
|
|
198
198
|
labels: ['v7.2.0', 'v7.1.0'],
|
|
@@ -229,7 +229,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
229
229
|
'^v(\\d+).(\\d+).\\d+$': '$1.$2', // all other branches
|
|
230
230
|
};
|
|
231
231
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
232
|
-
|
|
232
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
233
233
|
sourcePullRequest: {
|
|
234
234
|
number: 1234,
|
|
235
235
|
labels: [
|
|
@@ -285,13 +285,30 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
285
285
|
{ branch: 'master', state: 'MISSING' },
|
|
286
286
|
]);
|
|
287
287
|
});
|
|
288
|
+
it(`should support "backport-to" format`, () => {
|
|
289
|
+
const branchLabelMapping = {
|
|
290
|
+
'^backport-to-(.+)$': '$1',
|
|
291
|
+
};
|
|
292
|
+
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
293
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
294
|
+
sourcePullRequest: {
|
|
295
|
+
number: 1234,
|
|
296
|
+
labels: ['backport-to-dev', 'backport-to-v3.1.0'],
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
const expectedTargetPullRequests = (0, getExpectedTargetPullRequests_1.getExpectedTargetPullRequests)(mockSourceCommit, branchLabelMapping);
|
|
300
|
+
expect(expectedTargetPullRequests).toEqual([
|
|
301
|
+
{ branch: 'dev', state: 'MISSING' },
|
|
302
|
+
{ branch: 'v3.1.0', state: 'MISSING' },
|
|
303
|
+
]);
|
|
304
|
+
});
|
|
288
305
|
it('should only get first match', () => {
|
|
289
306
|
const branchLabelMapping = {
|
|
290
307
|
'label-2': 'branch-b',
|
|
291
308
|
'label-(\\d+)': 'branch-$1',
|
|
292
309
|
};
|
|
293
310
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
294
|
-
|
|
311
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
295
312
|
sourcePullRequest: {
|
|
296
313
|
number: 1234,
|
|
297
314
|
labels: ['label-2'],
|
|
@@ -307,7 +324,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
307
324
|
'label-(\\d+)': 'branch-$1',
|
|
308
325
|
};
|
|
309
326
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
310
|
-
|
|
327
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
311
328
|
sourcePullRequest: {
|
|
312
329
|
number: 1234,
|
|
313
330
|
labels: ['label-1', 'label-2', 'label-3', 'label-4'],
|
|
@@ -339,7 +356,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
339
356
|
'label-(\\d+)': 'branch-$1',
|
|
340
357
|
};
|
|
341
358
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
342
|
-
|
|
359
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
343
360
|
sourcePullRequest: {
|
|
344
361
|
number: 1234,
|
|
345
362
|
labels: ['label-1', 'label-2', 'label-3', 'label-4'],
|
|
@@ -366,7 +383,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
366
383
|
'label-(\\d+)': 'branch-$1',
|
|
367
384
|
};
|
|
368
385
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
369
|
-
|
|
386
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
370
387
|
sourcePullRequest: {
|
|
371
388
|
number: 1234,
|
|
372
389
|
labels: ['label-1', 'label-2', 'label-3', 'label-4'],
|
|
@@ -69,7 +69,11 @@ export declare type SourceCommitWithTargetPullRequest = InnerCommitNode & {
|
|
|
69
69
|
};
|
|
70
70
|
export declare function parseSourceCommit({ sourceCommit, options, }: {
|
|
71
71
|
sourceCommit: SourceCommitWithTargetPullRequest;
|
|
72
|
-
options:
|
|
72
|
+
options: {
|
|
73
|
+
branchLabelMapping?: ValidConfigOptions['branchLabelMapping'];
|
|
74
|
+
historicalBranchLabelMappings: ValidConfigOptions['historicalBranchLabelMappings'];
|
|
75
|
+
sourceBranch: string;
|
|
76
|
+
};
|
|
73
77
|
}): Commit;
|
|
74
78
|
export declare const sourceCommitWithTargetPullRequestFragment: {
|
|
75
79
|
name: string;
|
|
@@ -86,11 +86,11 @@ exports.sourceCommitWithTargetPullRequestFragment = {
|
|
|
86
86
|
}
|
|
87
87
|
`,
|
|
88
88
|
};
|
|
89
|
-
function getBranchLabelMappingForCommit(sourceCommit, branchLabelMapping, historicalBranchLabelMappings) {
|
|
89
|
+
function getBranchLabelMappingForCommit(sourceCommit, branchLabelMapping, historicalBranchLabelMappings = []) {
|
|
90
90
|
if ((0, lodash_1.isEmpty)(historicalBranchLabelMappings)) {
|
|
91
91
|
return branchLabelMapping;
|
|
92
92
|
}
|
|
93
93
|
const match = historicalBranchLabelMappings.find((branchLabelMapping) => sourceCommit.committedDate > branchLabelMapping.committedDate);
|
|
94
94
|
return (match?.branchLabelMapping ??
|
|
95
|
-
historicalBranchLabelMappings[0]
|
|
95
|
+
historicalBranchLabelMappings[0].branchLabelMapping);
|
|
96
96
|
}
|
|
@@ -6,7 +6,7 @@ describe('parseSourceCommit', () => {
|
|
|
6
6
|
describe('pullNumber', () => {
|
|
7
7
|
it('receives `pullNumber` from the associated pull request', () => {
|
|
8
8
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
9
|
-
|
|
9
|
+
sourceCommit: { message: 'My commit message (#1234)' },
|
|
10
10
|
sourcePullRequest: { number: 55 },
|
|
11
11
|
});
|
|
12
12
|
const commit = (0, parseSourceCommit_1.parseSourceCommit)({
|
|
@@ -17,7 +17,7 @@ describe('parseSourceCommit', () => {
|
|
|
17
17
|
});
|
|
18
18
|
it('extracts `pullNumber` from commit message if it doesnt have any associated PRs', () => {
|
|
19
19
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
20
|
-
|
|
20
|
+
sourceCommit: { message: 'My commit message (#66)' },
|
|
21
21
|
sourcePullRequest: null,
|
|
22
22
|
});
|
|
23
23
|
const commit = (0, parseSourceCommit_1.parseSourceCommit)({
|
|
@@ -30,7 +30,7 @@ describe('parseSourceCommit', () => {
|
|
|
30
30
|
describe('sourceBranch', () => {
|
|
31
31
|
it('sets sourceBranch based on `baseRefName` from associated PR', () => {
|
|
32
32
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
33
|
-
|
|
33
|
+
sourceCommit: { message: 'My commit message (#66)' },
|
|
34
34
|
sourcePullRequest: { number: 55, sourceBranch: 'a sourcebranch' },
|
|
35
35
|
});
|
|
36
36
|
const commit = (0, parseSourceCommit_1.parseSourceCommit)({
|
|
@@ -41,7 +41,7 @@ describe('parseSourceCommit', () => {
|
|
|
41
41
|
});
|
|
42
42
|
it('sets uses options.sourceBranch as fallback', () => {
|
|
43
43
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
44
|
-
|
|
44
|
+
sourceCommit: { message: 'My commit message (#66)' },
|
|
45
45
|
sourcePullRequest: null,
|
|
46
46
|
});
|
|
47
47
|
const commit = (0, parseSourceCommit_1.parseSourceCommit)({
|
|
@@ -53,9 +53,124 @@ describe('parseSourceCommit', () => {
|
|
|
53
53
|
expect(commit.sourceBranch).toBe('sourcebranch-from-options');
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
|
+
describe('expectedTargetPullRequests', () => {
|
|
57
|
+
it('uses options.branchLabelMapping when historicalBranchLabelMappings is empty', () => {
|
|
58
|
+
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
59
|
+
sourceCommit: {
|
|
60
|
+
message: 'My commit message (#66)',
|
|
61
|
+
commitedDate: '2021-03-03T00:00:00Z',
|
|
62
|
+
},
|
|
63
|
+
sourcePullRequest: {
|
|
64
|
+
sourceBranch: 'main',
|
|
65
|
+
number: 55,
|
|
66
|
+
labels: ['v6.4.0', 'v6.3.0', 'v6.2.0', 'v6.1.0'],
|
|
67
|
+
},
|
|
68
|
+
timelineItems: [
|
|
69
|
+
{
|
|
70
|
+
state: 'MERGED',
|
|
71
|
+
targetBranch: '6.3',
|
|
72
|
+
commitMessages: ['My commit message (#66)'],
|
|
73
|
+
number: 5678,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
state: 'OPEN',
|
|
77
|
+
targetBranch: '6.2',
|
|
78
|
+
commitMessages: ['My commit message (#66)'],
|
|
79
|
+
number: 9876,
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
});
|
|
83
|
+
const commit = (0, parseSourceCommit_1.parseSourceCommit)({
|
|
84
|
+
sourceCommit: mockSourceCommit,
|
|
85
|
+
options: {
|
|
86
|
+
branchLabelMapping: {
|
|
87
|
+
'^v6.4.0$': 'main',
|
|
88
|
+
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
89
|
+
},
|
|
90
|
+
historicalBranchLabelMappings: [],
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
expect(commit.expectedTargetPullRequests).toEqual([
|
|
94
|
+
{
|
|
95
|
+
branch: '6.3',
|
|
96
|
+
number: 5678,
|
|
97
|
+
state: 'MERGED',
|
|
98
|
+
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
branch: '6.2',
|
|
102
|
+
number: 9876,
|
|
103
|
+
state: 'OPEN',
|
|
104
|
+
url: 'https://github.com/elastic/kibana/pull/9876',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
branch: '6.1',
|
|
108
|
+
state: 'MISSING',
|
|
109
|
+
},
|
|
110
|
+
]);
|
|
111
|
+
});
|
|
112
|
+
it('uses the historical branchLabelMapping from 2021-02-02', () => {
|
|
113
|
+
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
114
|
+
sourceCommit: {
|
|
115
|
+
message: 'My commit message (#66)',
|
|
116
|
+
commitedDate: '2021-03-03T00:00:00Z',
|
|
117
|
+
},
|
|
118
|
+
sourcePullRequest: {
|
|
119
|
+
sourceBranch: 'main',
|
|
120
|
+
number: 55,
|
|
121
|
+
labels: ['v6.3.0', 'v6.2.0', 'v6.1.0'],
|
|
122
|
+
},
|
|
123
|
+
timelineItems: [
|
|
124
|
+
{
|
|
125
|
+
state: 'OPEN',
|
|
126
|
+
targetBranch: '6.2',
|
|
127
|
+
commitMessages: ['My commit message (#66)'],
|
|
128
|
+
number: 9876,
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
});
|
|
132
|
+
const commit = (0, parseSourceCommit_1.parseSourceCommit)({
|
|
133
|
+
sourceCommit: mockSourceCommit,
|
|
134
|
+
options: {
|
|
135
|
+
branchLabelMapping: {
|
|
136
|
+
'^v6.4.0$': 'main',
|
|
137
|
+
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
138
|
+
},
|
|
139
|
+
historicalBranchLabelMappings: [
|
|
140
|
+
{
|
|
141
|
+
branchLabelMapping: {
|
|
142
|
+
'^v6.4.0$': 'main',
|
|
143
|
+
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
144
|
+
},
|
|
145
|
+
committedDate: '2021-04-04T00:00:00Z',
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
branchLabelMapping: {
|
|
149
|
+
'^v6.3.0$': 'main',
|
|
150
|
+
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
151
|
+
},
|
|
152
|
+
committedDate: '2021-02-02T00:00:00Z',
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
expect(commit.expectedTargetPullRequests).toEqual([
|
|
158
|
+
{
|
|
159
|
+
branch: '6.2',
|
|
160
|
+
number: 9876,
|
|
161
|
+
state: 'OPEN',
|
|
162
|
+
url: 'https://github.com/elastic/kibana/pull/9876',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
branch: '6.1',
|
|
166
|
+
state: 'MISSING',
|
|
167
|
+
},
|
|
168
|
+
]);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
56
171
|
it('returns the correct source commit', () => {
|
|
57
172
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
58
|
-
|
|
173
|
+
sourceCommit: { message: 'My commit message (#1234)' },
|
|
59
174
|
sourcePullRequest: {
|
|
60
175
|
number: 1234,
|
|
61
176
|
labels: ['v6.3.0', 'v6.2.0', 'v6.1.0'],
|
|
@@ -26,47 +26,42 @@ describe('inquirer cli', () => {
|
|
|
26
26
|
});
|
|
27
27
|
it('should return error when branch is missing', async () => {
|
|
28
28
|
const res = await runBackportAsync([
|
|
29
|
-
'--
|
|
30
|
-
'--
|
|
31
|
-
'backport-org
|
|
32
|
-
'--
|
|
29
|
+
'--skip-remote-config',
|
|
30
|
+
'--repo-owner',
|
|
31
|
+
'backport-org',
|
|
32
|
+
'--repo-name',
|
|
33
|
+
'backport-e2e',
|
|
34
|
+
'--author',
|
|
33
35
|
'sqren',
|
|
34
36
|
'--accessToken',
|
|
35
37
|
devAccessToken,
|
|
36
38
|
]);
|
|
37
39
|
expect(res).toMatchInlineSnapshot(`
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
- Config file (recommended): \\".backportrc.json\\". Read more: https://github.com/sqren/backport/blob/e119d71d6dc03cd061f6ad9b9a8b1cd995f98961/docs/configuration.md#project-config-backportrcjson
|
|
41
|
-
- CLI: \\"--branch 6.1\\""
|
|
40
|
+
"Please specify a target branch: \\"--branch 6.1\\".
|
|
41
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
42
42
|
`);
|
|
43
43
|
});
|
|
44
|
-
it('should
|
|
44
|
+
it('should list commits based on .git/config when `repoOwner`/`repoName` is missing', async () => {
|
|
45
45
|
const res = await runBackportAsync([
|
|
46
|
-
'--
|
|
46
|
+
'--skip-remote-config',
|
|
47
47
|
'--branch',
|
|
48
48
|
'foo',
|
|
49
|
-
'--upstream',
|
|
50
|
-
'',
|
|
51
|
-
'--username',
|
|
52
|
-
'sqren',
|
|
53
49
|
'--accessToken',
|
|
54
50
|
devAccessToken,
|
|
55
51
|
]);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- Config file (recommended): \\".backportrc.json\\". Read more: https://github.com/sqren/backport/blob/e119d71d6dc03cd061f6ad9b9a8b1cd995f98961/docs/configuration.md#project-config-backportrcjson
|
|
60
|
-
- CLI: \\"--upstream elastic/kibana\\""
|
|
61
|
-
`);
|
|
52
|
+
const lineCount = res.split('\n').length;
|
|
53
|
+
expect(lineCount).toBe(11);
|
|
54
|
+
expect(res.includes('Select commit (Use arrow keys)')).toBe(true);
|
|
62
55
|
});
|
|
63
56
|
it('should return error when access token is invalid', async () => {
|
|
64
57
|
const res = await runBackportAsync([
|
|
65
58
|
'--branch',
|
|
66
59
|
'foo',
|
|
67
|
-
'--
|
|
68
|
-
'foo
|
|
69
|
-
'--
|
|
60
|
+
'--repo-owner',
|
|
61
|
+
'foo',
|
|
62
|
+
'--repo-name',
|
|
63
|
+
'bar',
|
|
64
|
+
'--author',
|
|
70
65
|
'some-user',
|
|
71
66
|
'--accessToken',
|
|
72
67
|
'some-token',
|
|
@@ -77,9 +72,11 @@ describe('inquirer cli', () => {
|
|
|
77
72
|
const res = await runBackportAsync([
|
|
78
73
|
'--branch',
|
|
79
74
|
'foo',
|
|
80
|
-
'--
|
|
81
|
-
'foo
|
|
82
|
-
'--
|
|
75
|
+
'--repo-owner',
|
|
76
|
+
'foo',
|
|
77
|
+
'--repo-name',
|
|
78
|
+
'bar',
|
|
79
|
+
'--author',
|
|
83
80
|
'sqren',
|
|
84
81
|
'--accessToken',
|
|
85
82
|
devAccessToken,
|
|
@@ -91,14 +88,14 @@ describe('inquirer cli', () => {
|
|
|
91
88
|
const output = await runBackportAsync([
|
|
92
89
|
'--branch',
|
|
93
90
|
'foo',
|
|
94
|
-
'--
|
|
95
|
-
'backport-org
|
|
96
|
-
'--
|
|
91
|
+
'--repo-owner',
|
|
92
|
+
'backport-org',
|
|
93
|
+
'--repo-name',
|
|
94
|
+
'backport-e2e',
|
|
95
|
+
'--author',
|
|
97
96
|
'sqren',
|
|
98
97
|
'--accessToken',
|
|
99
98
|
devAccessToken,
|
|
100
|
-
'--author',
|
|
101
|
-
'sqren',
|
|
102
99
|
'--max-number',
|
|
103
100
|
'6',
|
|
104
101
|
], { waitForString: 'Select commit' });
|
|
@@ -116,14 +113,14 @@ describe('inquirer cli', () => {
|
|
|
116
113
|
const output = await runBackportAsync([
|
|
117
114
|
'--branch',
|
|
118
115
|
'foo',
|
|
119
|
-
'--
|
|
120
|
-
'backport-org
|
|
121
|
-
'--
|
|
116
|
+
'--repo-owner',
|
|
117
|
+
'backport-org',
|
|
118
|
+
'--repo-name',
|
|
119
|
+
'backport-e2e',
|
|
120
|
+
'--author',
|
|
122
121
|
'sqren',
|
|
123
122
|
'--accessToken',
|
|
124
123
|
devAccessToken,
|
|
125
|
-
'--author',
|
|
126
|
-
'sqren',
|
|
127
124
|
'--max-number',
|
|
128
125
|
'6',
|
|
129
126
|
'--source-branch',
|