backport 6.0.0 → 6.1.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/README.md +158 -42
- 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 +33 -0
- package/dist/main.js +1 -2
- package/dist/options/ConfigOptions.d.ts +15 -6
- package/dist/options/cliArgs.d.ts +33 -34
- package/dist/options/cliArgs.js +19 -19
- package/dist/options/cliArgs.test.js +8 -5
- package/dist/options/config/config.d.ts +27 -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 +1 -4
- 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 +51 -0
- package/dist/options/config/readConfigFile.js +28 -2
- package/dist/options/options.d.ts +52 -33
- package/dist/options/options.js +98 -7
- package/dist/options/options.test.js +180 -73
- 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 +35 -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 +78 -0
- 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 +66 -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 +15 -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 +42 -34
- package/dist/test/integration/integration.private.test.js +104 -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 +67 -28
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +6 -3
- package/dist/ui/getCommits.d.ts +1 -1
- 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
|
@@ -44,6 +44,8 @@ export declare function getOptionsFromGithub(optionsFromConfigFiles: ConfigFileO
|
|
|
44
44
|
prFilter?: string | undefined;
|
|
45
45
|
prTitle?: string | undefined;
|
|
46
46
|
pullNumber?: number | undefined;
|
|
47
|
+
repoOwner?: string | undefined;
|
|
48
|
+
repoName?: string | undefined;
|
|
47
49
|
resetAuthor?: boolean | undefined;
|
|
48
50
|
reviewers?: string[] | undefined;
|
|
49
51
|
sha?: string | undefined;
|
|
@@ -52,10 +54,10 @@ export declare function getOptionsFromGithub(optionsFromConfigFiles: ConfigFileO
|
|
|
52
54
|
targetBranchChoices?: import("../../../../options/ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
53
55
|
targetBranches?: string[] | undefined;
|
|
54
56
|
targetPRLabels?: string[] | undefined;
|
|
55
|
-
upstream?: string | undefined;
|
|
56
57
|
username?: string | undefined;
|
|
57
58
|
verbose?: boolean | undefined;
|
|
58
59
|
branchLabelMapping?: Record<string, string> | undefined;
|
|
60
|
+
upstream?: string | undefined;
|
|
59
61
|
branches?: import("../../../../options/ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
60
62
|
labels?: string[] | undefined;
|
|
61
63
|
}>;
|
|
@@ -40,6 +40,24 @@ describe('getOptionsFromGithub', () => {
|
|
|
40
40
|
'^v7.9.0$': '7.x',
|
|
41
41
|
'^v8.0.0$': 'master',
|
|
42
42
|
},
|
|
43
|
+
historicalBranchLabelMappings: [
|
|
44
|
+
{
|
|
45
|
+
branchLabelMapping: {
|
|
46
|
+
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
47
|
+
'^v7.9.0$': '7.x',
|
|
48
|
+
'^v8.0.0$': 'master',
|
|
49
|
+
},
|
|
50
|
+
committedDate: '2020-08-15T10:33:06Z',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
branchLabelMapping: { '6.1': '6.1', '6.3': '6.3' },
|
|
54
|
+
committedDate: '2020-08-15T10:20:23Z',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
branchLabelMapping: { '6.1': '6.1', '6.3': '6.3' },
|
|
58
|
+
committedDate: '2020-08-15T10:17:57Z',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
43
61
|
sourceBranch: 'master',
|
|
44
62
|
targetBranchChoices: [
|
|
45
63
|
{ checked: true, name: 'master' },
|
|
@@ -120,7 +138,10 @@ describe('getOptionsFromGithub', () => {
|
|
|
120
138
|
};
|
|
121
139
|
const optionsFromCliArgs = {};
|
|
122
140
|
const options = await (0, _1.getOptionsFromGithub)(optionsFromConfigFiles, optionsFromCliArgs);
|
|
123
|
-
expect(options).toEqual({
|
|
141
|
+
expect(options).toEqual({
|
|
142
|
+
sourceBranch: 'main',
|
|
143
|
+
historicalBranchLabelMappings: [],
|
|
144
|
+
});
|
|
124
145
|
});
|
|
125
146
|
});
|
|
126
147
|
});
|
|
@@ -22,6 +22,9 @@ export declare type Repository = {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
export interface GithubConfigOptionsResponse {
|
|
25
|
+
viewer: {
|
|
26
|
+
login: string;
|
|
27
|
+
};
|
|
25
28
|
repository: {
|
|
26
29
|
isFork: true;
|
|
27
30
|
defaultBranchRef: null;
|
|
@@ -31,4 +34,4 @@ export interface GithubConfigOptionsResponse {
|
|
|
31
34
|
parent: null;
|
|
32
35
|
} & Repository);
|
|
33
36
|
}
|
|
34
|
-
export declare const query = "\n query GithubConfigOptions($repoOwner: String!, $repoName: String!) {\n repository(owner: $repoOwner, name: $repoName) {\n isFork\n ...Repo\n parent {\n ...Repo\n }\n }\n }\n\n fragment Repo on Repository {\n # check to see if a branch named \"backport\" exists\n ref(qualifiedName: \"refs/heads/backport\") {\n name\n }\n defaultBranchRef {\n name\n target {\n ... on Commit {\n history(first: 20, path: \".backportrc.json\") {\n edges {\n remoteConfig: node {\n committedDate\n file(path: \".backportrc.json\") {\n ... on TreeEntry {\n object {\n ... on Blob {\n text\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n";
|
|
37
|
+
export declare const query = "\n query GithubConfigOptions($repoOwner: String!, $repoName: String!) {\n viewer {\n login\n }\n repository(owner: $repoOwner, name: $repoName) {\n isFork\n ...Repo\n parent {\n ...Repo\n }\n }\n }\n\n fragment Repo on Repository {\n # check to see if a branch named \"backport\" exists\n ref(qualifiedName: \"refs/heads/backport\") {\n name\n }\n defaultBranchRef {\n name\n target {\n ... on Commit {\n history(first: 20, path: \".backportrc.json\") {\n edges {\n remoteConfig: node {\n committedDate\n file(path: \".backportrc.json\") {\n ... on TreeEntry {\n object {\n ... on Blob {\n text\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n";
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.query = void 0;
|
|
4
4
|
exports.query = `
|
|
5
5
|
query GithubConfigOptions($repoOwner: String!, $repoName: String!) {
|
|
6
|
+
viewer {
|
|
7
|
+
login
|
|
8
|
+
}
|
|
6
9
|
repository(owner: $repoOwner, name: $repoName) {
|
|
7
10
|
isFork
|
|
8
11
|
...Repo
|
|
@@ -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: [
|
|
@@ -291,7 +291,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
291
291
|
'label-(\\d+)': 'branch-$1',
|
|
292
292
|
};
|
|
293
293
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
294
|
-
|
|
294
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
295
295
|
sourcePullRequest: {
|
|
296
296
|
number: 1234,
|
|
297
297
|
labels: ['label-2'],
|
|
@@ -307,7 +307,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
307
307
|
'label-(\\d+)': 'branch-$1',
|
|
308
308
|
};
|
|
309
309
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
310
|
-
|
|
310
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
311
311
|
sourcePullRequest: {
|
|
312
312
|
number: 1234,
|
|
313
313
|
labels: ['label-1', 'label-2', 'label-3', 'label-4'],
|
|
@@ -339,7 +339,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
339
339
|
'label-(\\d+)': 'branch-$1',
|
|
340
340
|
};
|
|
341
341
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
342
|
-
|
|
342
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
343
343
|
sourcePullRequest: {
|
|
344
344
|
number: 1234,
|
|
345
345
|
labels: ['label-1', 'label-2', 'label-3', 'label-4'],
|
|
@@ -366,7 +366,7 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
366
366
|
'label-(\\d+)': 'branch-$1',
|
|
367
367
|
};
|
|
368
368
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
369
|
-
|
|
369
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
370
370
|
sourcePullRequest: {
|
|
371
371
|
number: 1234,
|
|
372
372
|
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,53 @@ 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
52
|
expect(res).toMatchInlineSnapshot(`
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
"? Select commit (Use arrow keys)
|
|
54
|
+
❯ 1. v6.0.0
|
|
55
|
+
2. Bump dependencies
|
|
56
|
+
3. Add support for historical branch label mappings (#282)
|
|
57
|
+
4. Add status comment (#281)
|
|
58
|
+
5. Add \`--reviewer\` option (#280)
|
|
59
|
+
6. By default append \\"(cherry picked from commit...)\\" to commit message. Disab
|
|
60
|
+
le with \`--no-cherrypick-ref\` (#279)
|
|
61
|
+
7. Improve git unit tests (#278)
|
|
62
|
+
8. Add tests for \`getCommitsWithoutBackports\`
|
|
63
|
+
9. Add Details View and \`--details\` flag (#277)
|
|
64
|
+
10.Feature: Show hint about missing backports (#276)"
|
|
61
65
|
`);
|
|
62
66
|
});
|
|
63
67
|
it('should return error when access token is invalid', async () => {
|
|
64
68
|
const res = await runBackportAsync([
|
|
65
69
|
'--branch',
|
|
66
70
|
'foo',
|
|
67
|
-
'--
|
|
68
|
-
'foo
|
|
69
|
-
'--
|
|
71
|
+
'--repo-owner',
|
|
72
|
+
'foo',
|
|
73
|
+
'--repo-name',
|
|
74
|
+
'bar',
|
|
75
|
+
'--author',
|
|
70
76
|
'some-user',
|
|
71
77
|
'--accessToken',
|
|
72
78
|
'some-token',
|
|
@@ -77,9 +83,11 @@ describe('inquirer cli', () => {
|
|
|
77
83
|
const res = await runBackportAsync([
|
|
78
84
|
'--branch',
|
|
79
85
|
'foo',
|
|
80
|
-
'--
|
|
81
|
-
'foo
|
|
82
|
-
'--
|
|
86
|
+
'--repo-owner',
|
|
87
|
+
'foo',
|
|
88
|
+
'--repo-name',
|
|
89
|
+
'bar',
|
|
90
|
+
'--author',
|
|
83
91
|
'sqren',
|
|
84
92
|
'--accessToken',
|
|
85
93
|
devAccessToken,
|
|
@@ -91,14 +99,14 @@ describe('inquirer cli', () => {
|
|
|
91
99
|
const output = await runBackportAsync([
|
|
92
100
|
'--branch',
|
|
93
101
|
'foo',
|
|
94
|
-
'--
|
|
95
|
-
'backport-org
|
|
96
|
-
'--
|
|
102
|
+
'--repo-owner',
|
|
103
|
+
'backport-org',
|
|
104
|
+
'--repo-name',
|
|
105
|
+
'backport-e2e',
|
|
106
|
+
'--author',
|
|
97
107
|
'sqren',
|
|
98
108
|
'--accessToken',
|
|
99
109
|
devAccessToken,
|
|
100
|
-
'--author',
|
|
101
|
-
'sqren',
|
|
102
110
|
'--max-number',
|
|
103
111
|
'6',
|
|
104
112
|
], { waitForString: 'Select commit' });
|
|
@@ -116,14 +124,14 @@ describe('inquirer cli', () => {
|
|
|
116
124
|
const output = await runBackportAsync([
|
|
117
125
|
'--branch',
|
|
118
126
|
'foo',
|
|
119
|
-
'--
|
|
120
|
-
'backport-org
|
|
121
|
-
'--
|
|
127
|
+
'--repo-owner',
|
|
128
|
+
'backport-org',
|
|
129
|
+
'--repo-name',
|
|
130
|
+
'backport-e2e',
|
|
131
|
+
'--author',
|
|
122
132
|
'sqren',
|
|
123
133
|
'--accessToken',
|
|
124
134
|
devAccessToken,
|
|
125
|
-
'--author',
|
|
126
|
-
'sqren',
|
|
127
135
|
'--max-number',
|
|
128
136
|
'6',
|
|
129
137
|
'--source-branch',
|