backport 6.1.1 → 6.1.5
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 +83 -70
- package/dist/entrypoint.module.d.ts +4 -1
- package/dist/entrypoint.module.js +10 -4
- package/dist/entrypoint.module.private.test.js +4 -1
- package/dist/main.js +5 -1
- package/dist/options/ConfigOptions.d.ts +3 -0
- package/dist/options/cliArgs.d.ts +5 -1
- package/dist/options/cliArgs.js +24 -2
- package/dist/options/cliArgs.test.js +0 -7
- package/dist/options/config/config.d.ts +7 -1
- package/dist/options/config/config.js +2 -2
- package/dist/options/config/config.test.js +1 -1
- package/dist/options/config/globalConfig.d.ts +1 -1
- package/dist/options/config/globalConfig.js +4 -8
- package/dist/options/config/readConfigFile.d.ts +4 -1
- package/dist/options/options.d.ts +10 -1
- package/dist/options/options.js +10 -2
- package/dist/options/options.test.js +113 -123
- package/dist/runSequentially.test.js +8 -5
- package/dist/services/HandledError.d.ts +1 -1
- package/dist/services/env.d.ts +2 -3
- package/dist/services/env.js +9 -10
- package/dist/services/env.test.js +0 -6
- package/dist/services/git.d.ts +2 -1
- package/dist/services/git.js +5 -3
- package/dist/services/github/v3/createPullRequest.js +1 -1
- package/dist/services/github/v3/createPullRequest.test.js +3 -3
- package/dist/services/github/v3/createStatusComment.d.ts +1 -1
- package/dist/services/github/v3/createStatusComment.js +50 -27
- package/dist/services/github/v3/createStatusComment.test.js +155 -73
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +78 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +1 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +64 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +5 -5
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +60 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +2 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +17 -10
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +72 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +6 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +8 -7
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +8 -0
- package/dist/services/github/v4/fetchProjectConfig.d.ts +1 -1
- package/dist/services/github/v4/fetchProjectConfig.js +3 -3
- package/dist/services/github/v4/fetchProjectConfig.private.test.js +5 -5
- package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +8 -0
- package/dist/services/github/v4/fetchRemoteProjectConfig.js +56 -0
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +52 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +3 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +0 -7
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +16 -5
- package/dist/services/logger.d.ts +0 -1
- package/dist/services/logger.js +3 -3
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +4 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +8 -2
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +20 -0
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +1 -0
- package/dist/services/sourceCommit/getMockSourceCommit.js +72 -46
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +22 -8
- package/dist/services/sourceCommit/parseSourceCommit.js +29 -10
- package/dist/services/sourceCommit/parseSourceCommit.test.js +10 -2
- package/dist/test/inquirer.private.test.js +4 -15
- package/dist/test/integration/integration.private.test.js +2 -2
- package/dist/test/nockHelpers.js +1 -3
- package/dist/test/setupFiles/automatic-mocks.js +1 -0
- package/dist/todo-delete.d.ts +1 -0
- package/dist/todo-delete.js +17 -0
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -9
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +11 -48
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +224 -260
- package/dist/ui/getCommits.js +1 -1
- package/dist/ui/getCommitsWithoutBackports.d.ts +11 -0
- package/dist/ui/getCommitsWithoutBackports.js +68 -0
- package/dist/ui/getCommitsWithoutBackports.test.d.ts +1 -0
- package/dist/ui/getCommitsWithoutBackports.test.js +259 -0
- package/dist/ui/maybeSetupRepo.js +0 -6
- package/dist/utils/redact.d.ts +1 -0
- package/dist/utils/redact.js +7 -0
- package/package.json +3 -3
- package/yarn.lock +462 -284
package/dist/services/logger.js
CHANGED
|
@@ -22,11 +22,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.initLogger = exports.
|
|
25
|
+
exports.initLogger = exports.updateLogger = exports.logger = exports.consoleLog = void 0;
|
|
26
26
|
const dedent_1 = __importDefault(require("dedent"));
|
|
27
27
|
const lodash_1 = require("lodash");
|
|
28
28
|
const safe_json_stringify_1 = __importDefault(require("safe-json-stringify"));
|
|
29
29
|
const winston_1 = __importStar(require("winston"));
|
|
30
|
+
const redact_1 = require("../utils/redact");
|
|
30
31
|
const env_1 = require("./env");
|
|
31
32
|
const { combine } = winston_1.format;
|
|
32
33
|
let winstonInstance;
|
|
@@ -68,11 +69,10 @@ exports.updateLogger = updateLogger;
|
|
|
68
69
|
function redactAccessToken(str) {
|
|
69
70
|
// `redactAccessToken` might be called before access token is set
|
|
70
71
|
if (accessToken) {
|
|
71
|
-
return
|
|
72
|
+
return (0, redact_1.redact)(accessToken, str);
|
|
72
73
|
}
|
|
73
74
|
return str;
|
|
74
75
|
}
|
|
75
|
-
exports.redactAccessToken = redactAccessToken;
|
|
76
76
|
function initLogger() {
|
|
77
77
|
winstonInstance = winston_1.default.createLogger({
|
|
78
78
|
transports: [
|
|
@@ -5,5 +5,9 @@ export declare type ExpectedTargetPullRequest = {
|
|
|
5
5
|
number?: number;
|
|
6
6
|
branch: string;
|
|
7
7
|
state: 'OPEN' | 'CLOSED' | 'MERGED' | 'MISSING';
|
|
8
|
+
mergeCommit?: {
|
|
9
|
+
sha: string;
|
|
10
|
+
message: string;
|
|
11
|
+
};
|
|
8
12
|
};
|
|
9
13
|
export declare function getExpectedTargetPullRequests(sourceCommit: SourceCommitWithTargetPullRequest, branchLabelMapping: ValidConfigOptions['branchLabelMapping']): ExpectedTargetPullRequest[];
|
|
@@ -34,9 +34,9 @@ function getExistingTargetPullRequests(sourceCommit, sourcePullRequest) {
|
|
|
34
34
|
// at least one of the commits in `targetPullRequest` should match the merge commit from the source pull request
|
|
35
35
|
const didCommitMatch = targetPullRequest.commits.edges.some((commitEdge) => {
|
|
36
36
|
const { targetCommit } = commitEdge.node;
|
|
37
|
-
const matchingRepoName = sourceCommit.repository.name ===
|
|
37
|
+
const matchingRepoName = sourceCommit.repository.name === targetPullRequest.repository.name;
|
|
38
38
|
const matchingRepoOwner = sourceCommit.repository.owner.login ===
|
|
39
|
-
|
|
39
|
+
targetPullRequest.repository.owner.login;
|
|
40
40
|
const targetCommitMessage = (0, commitFormatters_1.getFirstLine)(targetCommit.message);
|
|
41
41
|
const matchingMessage = targetCommitMessage === sourceCommitMessage;
|
|
42
42
|
return matchingRepoName && matchingRepoOwner && matchingMessage;
|
|
@@ -52,6 +52,12 @@ function getExistingTargetPullRequests(sourceCommit, sourcePullRequest) {
|
|
|
52
52
|
number: targetPullRequest.number,
|
|
53
53
|
branch: targetPullRequest.baseRefName,
|
|
54
54
|
state: targetPullRequest.state,
|
|
55
|
+
mergeCommit: targetPullRequest.targetMergeCommit
|
|
56
|
+
? {
|
|
57
|
+
sha: targetPullRequest.targetMergeCommit.oid,
|
|
58
|
+
message: targetPullRequest.targetMergeCommit.message,
|
|
59
|
+
}
|
|
60
|
+
: undefined,
|
|
55
61
|
};
|
|
56
62
|
});
|
|
57
63
|
}
|
|
@@ -40,6 +40,10 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
40
40
|
state: 'MERGED',
|
|
41
41
|
number: 5678,
|
|
42
42
|
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
43
|
+
mergeCommit: {
|
|
44
|
+
message: 'identical messages (#1234)',
|
|
45
|
+
sha: 'target-merge-commit-sha',
|
|
46
|
+
},
|
|
43
47
|
},
|
|
44
48
|
]);
|
|
45
49
|
});
|
|
@@ -122,6 +126,10 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
122
126
|
state: 'MERGED',
|
|
123
127
|
number: 5678,
|
|
124
128
|
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
129
|
+
mergeCommit: {
|
|
130
|
+
message: 'message two (#1234)',
|
|
131
|
+
sha: 'target-merge-commit-sha',
|
|
132
|
+
},
|
|
125
133
|
},
|
|
126
134
|
]);
|
|
127
135
|
});
|
|
@@ -168,6 +176,10 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
168
176
|
state: 'MERGED',
|
|
169
177
|
number: 5678,
|
|
170
178
|
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
179
|
+
mergeCommit: {
|
|
180
|
+
message: 'message one (#1234)\n\nsomething else',
|
|
181
|
+
sha: 'target-merge-commit-sha',
|
|
182
|
+
},
|
|
171
183
|
},
|
|
172
184
|
]);
|
|
173
185
|
});
|
|
@@ -218,6 +230,10 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
218
230
|
state: 'MERGED',
|
|
219
231
|
number: 5678,
|
|
220
232
|
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
233
|
+
mergeCommit: {
|
|
234
|
+
message: 'identical messages (#1234)',
|
|
235
|
+
sha: 'target-merge-commit-sha',
|
|
236
|
+
},
|
|
221
237
|
},
|
|
222
238
|
{ branch: '7.1', state: 'MISSING' },
|
|
223
239
|
]);
|
|
@@ -404,6 +420,10 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
404
420
|
number: 5678,
|
|
405
421
|
state: 'MERGED',
|
|
406
422
|
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
423
|
+
mergeCommit: {
|
|
424
|
+
message: 'identical messages (#1234)',
|
|
425
|
+
sha: 'target-merge-commit-sha',
|
|
426
|
+
},
|
|
407
427
|
},
|
|
408
428
|
{ branch: 'branch-1', state: 'MISSING' },
|
|
409
429
|
{ branch: 'branch-2', state: 'MISSING' },
|
|
@@ -2,65 +2,91 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getMockSourceCommit = void 0;
|
|
4
4
|
function getMockSourceCommit({ sourceCommit, sourcePullRequest, timelineItems = [], }) {
|
|
5
|
+
const defaultTargetPullRequestTitle = 'DO NOT USE: Default Pull Request Title';
|
|
6
|
+
const defaultSourceCommitSha = 'DO NOT USE: default-source-commit-sha';
|
|
7
|
+
const baseMockCommit = {
|
|
8
|
+
repository: {
|
|
9
|
+
name: 'kibana',
|
|
10
|
+
owner: { login: 'elastic' },
|
|
11
|
+
},
|
|
12
|
+
committedDate: sourceCommit.commitedDate ?? '2021-12-22T00:00:00Z',
|
|
13
|
+
oid: sourceCommit.sha ?? defaultSourceCommitSha,
|
|
14
|
+
message: sourceCommit.message,
|
|
15
|
+
};
|
|
16
|
+
if (!sourcePullRequest) {
|
|
17
|
+
return {
|
|
18
|
+
...baseMockCommit,
|
|
19
|
+
associatedPullRequests: {
|
|
20
|
+
edges: null,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
5
24
|
return {
|
|
6
25
|
repository: {
|
|
7
26
|
name: 'kibana',
|
|
8
27
|
owner: { login: 'elastic' },
|
|
9
28
|
},
|
|
10
29
|
committedDate: sourceCommit.commitedDate ?? '2021-12-22T00:00:00Z',
|
|
11
|
-
oid:
|
|
30
|
+
oid: sourceCommit.sha ?? defaultSourceCommitSha,
|
|
12
31
|
message: sourceCommit.message,
|
|
13
32
|
associatedPullRequests: {
|
|
14
|
-
edges:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
message: message,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
})),
|
|
33
|
+
edges: [
|
|
34
|
+
{
|
|
35
|
+
node: {
|
|
36
|
+
sourceMergeCommit: {
|
|
37
|
+
oid: sourceCommit.sha ?? defaultSourceCommitSha,
|
|
38
|
+
message: sourceCommit.message,
|
|
39
|
+
},
|
|
40
|
+
url: `https://github.com/elastic/kibana/pull/${sourcePullRequest.number}`,
|
|
41
|
+
labels: {
|
|
42
|
+
nodes: (sourcePullRequest.labels ?? []).map((name) => ({
|
|
43
|
+
name,
|
|
44
|
+
})),
|
|
45
|
+
},
|
|
46
|
+
baseRefName: sourcePullRequest.sourceBranch ??
|
|
47
|
+
'source-branch-from-associated-pull-request',
|
|
48
|
+
number: sourcePullRequest.number,
|
|
49
|
+
timelineItems: {
|
|
50
|
+
edges: timelineItems.map((timelineItem) => {
|
|
51
|
+
return {
|
|
52
|
+
node: {
|
|
53
|
+
targetPullRequest: {
|
|
54
|
+
__typename: 'PullRequest',
|
|
55
|
+
url: `https://github.com/elastic/kibana/pull/${timelineItem.number}`,
|
|
56
|
+
title: timelineItem.title ?? defaultTargetPullRequestTitle,
|
|
57
|
+
number: timelineItem.number,
|
|
58
|
+
state: timelineItem.state,
|
|
59
|
+
baseRefName: timelineItem.targetBranch,
|
|
60
|
+
targetMergeCommit: timelineItem.state === 'MERGED'
|
|
61
|
+
? {
|
|
62
|
+
message: timelineItem.commitMessages[0],
|
|
63
|
+
oid: 'target-merge-commit-sha',
|
|
64
|
+
}
|
|
65
|
+
: null,
|
|
66
|
+
repository: {
|
|
67
|
+
name: timelineItem.repoName ?? 'kibana',
|
|
68
|
+
owner: {
|
|
69
|
+
login: timelineItem.repoOwner ?? 'elastic',
|
|
55
70
|
},
|
|
56
71
|
},
|
|
72
|
+
commits: {
|
|
73
|
+
edges: timelineItem.commitMessages.map((message) => ({
|
|
74
|
+
node: {
|
|
75
|
+
targetCommit: {
|
|
76
|
+
oid: 'abc',
|
|
77
|
+
message: message,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
})),
|
|
81
|
+
},
|
|
57
82
|
},
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
}),
|
|
61
86
|
},
|
|
62
87
|
},
|
|
63
|
-
|
|
88
|
+
},
|
|
89
|
+
],
|
|
64
90
|
},
|
|
65
91
|
};
|
|
66
92
|
}
|
|
@@ -9,7 +9,7 @@ export interface Commit {
|
|
|
9
9
|
pullUrl?: string;
|
|
10
10
|
expectedTargetPullRequests: ExpectedTargetPullRequest[];
|
|
11
11
|
}
|
|
12
|
-
export interface
|
|
12
|
+
export interface SourcePullRequestNode {
|
|
13
13
|
baseRefName: string;
|
|
14
14
|
url: string;
|
|
15
15
|
number: number;
|
|
@@ -18,8 +18,12 @@ export interface PullRequestNode {
|
|
|
18
18
|
name: string;
|
|
19
19
|
}[];
|
|
20
20
|
};
|
|
21
|
+
sourceMergeCommit: {
|
|
22
|
+
oid: string;
|
|
23
|
+
message: string;
|
|
24
|
+
};
|
|
21
25
|
timelineItems: {
|
|
22
|
-
edges:
|
|
26
|
+
edges: TimelineEdge[];
|
|
23
27
|
};
|
|
24
28
|
}
|
|
25
29
|
export declare type TimelineEdge = TimelinePullRequestEdge | TimelineIssueEdge;
|
|
@@ -32,10 +36,23 @@ export interface TimelinePullRequestEdge {
|
|
|
32
36
|
state: 'OPEN' | 'CLOSED' | 'MERGED';
|
|
33
37
|
baseRefName: string;
|
|
34
38
|
number: number;
|
|
39
|
+
targetMergeCommit: {
|
|
40
|
+
oid: string;
|
|
41
|
+
message: string;
|
|
42
|
+
} | null;
|
|
43
|
+
repository: {
|
|
44
|
+
name: string;
|
|
45
|
+
owner: {
|
|
46
|
+
login: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
35
49
|
commits: {
|
|
36
50
|
edges: Array<{
|
|
37
51
|
node: {
|
|
38
|
-
targetCommit:
|
|
52
|
+
targetCommit: {
|
|
53
|
+
message: string;
|
|
54
|
+
oid: string;
|
|
55
|
+
};
|
|
39
56
|
};
|
|
40
57
|
}>;
|
|
41
58
|
};
|
|
@@ -49,7 +66,7 @@ interface TimelineIssueEdge {
|
|
|
49
66
|
};
|
|
50
67
|
};
|
|
51
68
|
}
|
|
52
|
-
declare type
|
|
69
|
+
export declare type SourceCommitWithTargetPullRequest = {
|
|
53
70
|
repository: {
|
|
54
71
|
name: string;
|
|
55
72
|
owner: {
|
|
@@ -59,11 +76,9 @@ declare type InnerCommitNode = {
|
|
|
59
76
|
oid: string;
|
|
60
77
|
message: string;
|
|
61
78
|
committedDate: string;
|
|
62
|
-
};
|
|
63
|
-
export declare type SourceCommitWithTargetPullRequest = InnerCommitNode & {
|
|
64
79
|
associatedPullRequests: {
|
|
65
80
|
edges: {
|
|
66
|
-
node:
|
|
81
|
+
node: SourcePullRequestNode;
|
|
67
82
|
}[] | null;
|
|
68
83
|
};
|
|
69
84
|
};
|
|
@@ -76,7 +91,6 @@ export declare function parseSourceCommit({ sourceCommit, options, }: {
|
|
|
76
91
|
};
|
|
77
92
|
}): Commit;
|
|
78
93
|
export declare const sourceCommitWithTargetPullRequestFragment: {
|
|
79
|
-
name: string;
|
|
80
94
|
source: string;
|
|
81
95
|
};
|
|
82
96
|
export {};
|
|
@@ -6,7 +6,9 @@ const commitFormatters_1 = require("../github/commitFormatters");
|
|
|
6
6
|
const getExpectedTargetPullRequests_1 = require("./getExpectedTargetPullRequests");
|
|
7
7
|
function parseSourceCommit({ sourceCommit, options, }) {
|
|
8
8
|
const sourcePullRequest = sourceCommit.associatedPullRequests.edges?.[0]?.node;
|
|
9
|
-
|
|
9
|
+
// use info from associated pull request if available. Fall back to commit info
|
|
10
|
+
const commitMessage = sourcePullRequest?.sourceMergeCommit.message ?? sourceCommit.message;
|
|
11
|
+
const commitSha = sourcePullRequest?.sourceMergeCommit.oid ?? sourceCommit.oid;
|
|
10
12
|
const pullNumber = sourcePullRequest?.number ?? (0, commitFormatters_1.extractPullNumber)(commitMessage);
|
|
11
13
|
const sourceBranch = sourcePullRequest?.baseRefName ?? options.sourceBranch;
|
|
12
14
|
const branchLabelMapping = getBranchLabelMappingForCommit(sourceCommit, options.branchLabelMapping, options.historicalBranchLabelMappings);
|
|
@@ -14,7 +16,7 @@ function parseSourceCommit({ sourceCommit, options, }) {
|
|
|
14
16
|
return {
|
|
15
17
|
committedDate: sourceCommit.committedDate,
|
|
16
18
|
sourceBranch,
|
|
17
|
-
sha:
|
|
19
|
+
sha: commitSha,
|
|
18
20
|
originalMessage: commitMessage,
|
|
19
21
|
pullNumber,
|
|
20
22
|
pullUrl: sourcePullRequest?.url,
|
|
@@ -23,9 +25,9 @@ function parseSourceCommit({ sourceCommit, options, }) {
|
|
|
23
25
|
}
|
|
24
26
|
exports.parseSourceCommit = parseSourceCommit;
|
|
25
27
|
exports.sourceCommitWithTargetPullRequestFragment = {
|
|
26
|
-
name: 'SourceCommitWithTargetPullRequest',
|
|
27
28
|
source: /* GraphQL */ `
|
|
28
|
-
fragment
|
|
29
|
+
fragment SourceCommitWithTargetPullRequest on Commit {
|
|
30
|
+
# Source Commit
|
|
29
31
|
repository {
|
|
30
32
|
name
|
|
31
33
|
owner {
|
|
@@ -35,14 +37,11 @@ exports.sourceCommitWithTargetPullRequestFragment = {
|
|
|
35
37
|
oid
|
|
36
38
|
message
|
|
37
39
|
committedDate
|
|
38
|
-
}
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
...InnerCommitNode
|
|
41
|
+
# Source pull request: PR where source commit was merged in
|
|
42
42
|
associatedPullRequests(first: 1) {
|
|
43
43
|
edges {
|
|
44
44
|
node {
|
|
45
|
-
# Source PR
|
|
46
45
|
url
|
|
47
46
|
number
|
|
48
47
|
labels(first: 50) {
|
|
@@ -51,6 +50,14 @@ exports.sourceCommitWithTargetPullRequestFragment = {
|
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
baseRefName
|
|
53
|
+
|
|
54
|
+
# source merge commit (the commit that actually went into the source branch)
|
|
55
|
+
sourceMergeCommit: mergeCommit {
|
|
56
|
+
oid
|
|
57
|
+
message
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# (possible) backport pull requests referenced in the source pull request
|
|
54
61
|
timelineItems(last: 20, itemTypes: CROSS_REFERENCED_EVENT) {
|
|
55
62
|
edges {
|
|
56
63
|
node {
|
|
@@ -58,8 +65,19 @@ exports.sourceCommitWithTargetPullRequestFragment = {
|
|
|
58
65
|
targetPullRequest: source {
|
|
59
66
|
__typename
|
|
60
67
|
|
|
61
|
-
# Target PRs
|
|
68
|
+
# Target PRs (backport PRs)
|
|
62
69
|
... on PullRequest {
|
|
70
|
+
# target merge commit: the backport commit that was merged into the target branch
|
|
71
|
+
targetMergeCommit: mergeCommit {
|
|
72
|
+
oid
|
|
73
|
+
message
|
|
74
|
+
}
|
|
75
|
+
repository {
|
|
76
|
+
name
|
|
77
|
+
owner {
|
|
78
|
+
login
|
|
79
|
+
}
|
|
80
|
+
}
|
|
63
81
|
url
|
|
64
82
|
title
|
|
65
83
|
state
|
|
@@ -69,7 +87,8 @@ exports.sourceCommitWithTargetPullRequestFragment = {
|
|
|
69
87
|
edges {
|
|
70
88
|
node {
|
|
71
89
|
targetCommit: commit {
|
|
72
|
-
|
|
90
|
+
message
|
|
91
|
+
oid
|
|
73
92
|
}
|
|
74
93
|
}
|
|
75
94
|
}
|
|
@@ -96,6 +96,10 @@ describe('parseSourceCommit', () => {
|
|
|
96
96
|
number: 5678,
|
|
97
97
|
state: 'MERGED',
|
|
98
98
|
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
99
|
+
mergeCommit: {
|
|
100
|
+
message: 'My commit message (#66)',
|
|
101
|
+
sha: 'target-merge-commit-sha',
|
|
102
|
+
},
|
|
99
103
|
},
|
|
100
104
|
{
|
|
101
105
|
branch: '6.2',
|
|
@@ -170,7 +174,7 @@ describe('parseSourceCommit', () => {
|
|
|
170
174
|
});
|
|
171
175
|
it('returns the correct source commit', () => {
|
|
172
176
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
173
|
-
sourceCommit: { message: 'My commit message (#1234)' },
|
|
177
|
+
sourceCommit: { message: 'My commit message (#1234)', sha: 'my-sha' },
|
|
174
178
|
sourcePullRequest: {
|
|
175
179
|
number: 1234,
|
|
176
180
|
labels: ['v6.3.0', 'v6.2.0', 'v6.1.0'],
|
|
@@ -207,6 +211,10 @@ describe('parseSourceCommit', () => {
|
|
|
207
211
|
number: 5678,
|
|
208
212
|
state: 'MERGED',
|
|
209
213
|
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
214
|
+
mergeCommit: {
|
|
215
|
+
message: 'My commit message (#1234)',
|
|
216
|
+
sha: 'target-merge-commit-sha',
|
|
217
|
+
},
|
|
210
218
|
},
|
|
211
219
|
{
|
|
212
220
|
branch: '6.2',
|
|
@@ -222,7 +230,7 @@ describe('parseSourceCommit', () => {
|
|
|
222
230
|
originalMessage: 'My commit message (#1234)',
|
|
223
231
|
pullNumber: 1234,
|
|
224
232
|
pullUrl: 'https://github.com/elastic/kibana/pull/1234',
|
|
225
|
-
sha: '
|
|
233
|
+
sha: 'my-sha',
|
|
226
234
|
sourceBranch: 'source-branch-from-associated-pull-request',
|
|
227
235
|
});
|
|
228
236
|
});
|
|
@@ -38,7 +38,7 @@ describe('inquirer cli', () => {
|
|
|
38
38
|
]);
|
|
39
39
|
expect(res).toMatchInlineSnapshot(`
|
|
40
40
|
"Please specify a target branch: \\"--branch 6.1\\".
|
|
41
|
-
|
|
41
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
42
42
|
`);
|
|
43
43
|
});
|
|
44
44
|
it('should list commits based on .git/config when `repoOwner`/`repoName` is missing', async () => {
|
|
@@ -49,20 +49,9 @@ describe('inquirer cli', () => {
|
|
|
49
49
|
'--accessToken',
|
|
50
50
|
devAccessToken,
|
|
51
51
|
]);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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)"
|
|
65
|
-
`);
|
|
52
|
+
const lineCount = res.split('\n').length;
|
|
53
|
+
expect(lineCount).toBe(11);
|
|
54
|
+
expect(res.includes('Select commit (Use arrow keys)')).toBe(true);
|
|
66
55
|
});
|
|
67
56
|
it('should return error when access token is invalid', async () => {
|
|
68
57
|
const res = await runBackportAsync([
|
|
@@ -78,7 +78,7 @@ describe('integration', () => {
|
|
|
78
78
|
"base": "7.x",
|
|
79
79
|
"body": "# Backport
|
|
80
80
|
|
|
81
|
-
This is an automatic backport to 7.x of:
|
|
81
|
+
This is an automatic backport to \`7.x\` of:
|
|
82
82
|
- Add ❤️ emoji (5bf29b7d)
|
|
83
83
|
|
|
84
84
|
### Questions ?
|
|
@@ -214,7 +214,7 @@ describe('integration', () => {
|
|
|
214
214
|
"base": "7.x",
|
|
215
215
|
"body": "# Backport
|
|
216
216
|
|
|
217
|
-
This is an automatic backport to 7.x of:
|
|
217
|
+
This is an automatic backport to \`7.x\` of:
|
|
218
218
|
- Add ❤️ emoji (5bf29b7d)
|
|
219
219
|
|
|
220
220
|
### Questions ?
|
package/dist/test/nockHelpers.js
CHANGED
|
@@ -18,9 +18,7 @@ function mockGqlRequest({ name, statusCode, body, headers, apiBaseUrl, }) {
|
|
|
18
18
|
}
|
|
19
19
|
exports.mockGqlRequest = mockGqlRequest;
|
|
20
20
|
function getGqlName(query) {
|
|
21
|
-
const obj = (0, graphql_tag_1.default)
|
|
22
|
-
${query}
|
|
23
|
-
`;
|
|
21
|
+
const obj = (0, graphql_tag_1.default)(query);
|
|
24
22
|
// @ts-expect-error
|
|
25
23
|
return obj.definitions[0].name.value;
|
|
26
24
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const entrypoint_module_1 = require("./entrypoint.module");
|
|
4
|
+
async function init() {
|
|
5
|
+
const { accessToken } = await (0, entrypoint_module_1.getLocalGlobalConfig)();
|
|
6
|
+
if (!accessToken) {
|
|
7
|
+
throw new Error('Missing access token');
|
|
8
|
+
}
|
|
9
|
+
const commit = await (0, entrypoint_module_1.getCommits)({
|
|
10
|
+
accessToken: accessToken,
|
|
11
|
+
repoOwner: 'backport-org',
|
|
12
|
+
repoName: 'repo-with-conflicts',
|
|
13
|
+
pullNumber: 8,
|
|
14
|
+
});
|
|
15
|
+
console.log({ commit });
|
|
16
|
+
}
|
|
17
|
+
init();
|
|
@@ -9,13 +9,4 @@ export declare function cherrypickAndCreateTargetPullRequest({ options, commits,
|
|
|
9
9
|
number: number;
|
|
10
10
|
didUpdate: boolean;
|
|
11
11
|
}>;
|
|
12
|
-
export declare function getCommitsWithoutBackports({ options, commit, targetBranch, conflictingFiles, }: {
|
|
13
|
-
options: ValidConfigOptions;
|
|
14
|
-
commit: Commit;
|
|
15
|
-
targetBranch: string;
|
|
16
|
-
conflictingFiles: string[];
|
|
17
|
-
}): Promise<{
|
|
18
|
-
formatted: string;
|
|
19
|
-
commit: Commit;
|
|
20
|
-
}[]>;
|
|
21
12
|
export declare function getBackportBranchName(targetBranch: string, commits: Commit[]): string;
|