backport 6.1.0 → 6.1.4
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 +45 -34
- package/dist/entrypoint.module.d.ts +2 -0
- package/dist/entrypoint.module.js +5 -1
- package/dist/entrypoint.module.private.test.js +16 -12
- package/dist/main.js +1 -1
- package/dist/options/ConfigOptions.d.ts +1 -0
- package/dist/options/cliArgs.d.ts +5 -3
- package/dist/options/cliArgs.js +20 -6
- package/dist/options/cliArgs.test.js +0 -7
- package/dist/options/config/config.d.ts +1 -0
- package/dist/options/config/globalConfig.js +1 -1
- package/dist/options/config/readConfigFile.d.ts +1 -0
- package/dist/options/options.d.ts +8 -0
- package/dist/options/options.js +9 -4
- package/dist/options/options.test.js +150 -104
- package/dist/runSequentially.test.js +13 -6
- package/dist/services/HandledError.d.ts +1 -1
- package/dist/services/git.d.ts +2 -1
- package/dist/services/git.js +4 -2
- package/dist/services/github/v3/createPullRequest.js +1 -1
- package/dist/services/github/v3/createPullRequest.test.js +38 -6
- package/dist/services/github/v3/createStatusComment.d.ts +1 -1
- package/dist/services/github/v3/createStatusComment.js +43 -25
- 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/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -0
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +16 -5
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +4 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +8 -2
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +37 -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 +14 -4
- package/dist/test/nockHelpers.js +1 -3
- package/dist/test/setupFiles/automatic-mocks.js +1 -0
- package/dist/ui/cherrypickAndCreatePullRequest.test.js +19 -6
- 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/utils/excludeUndefined.js +1 -1
- package/dist/utils/excludeUndefined.test.js +3 -3
- package/package.json +3 -3
- package/yarn.lock +462 -284
|
@@ -1,12 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
2
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
3
26
|
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
27
|
+
const apiRequestV4Module = __importStar(require("../apiRequestV4"));
|
|
4
28
|
const fetchCommitBySha_1 = require("./fetchCommitBySha");
|
|
5
29
|
describe('fetchCommitBySha', () => {
|
|
6
30
|
let devAccessToken;
|
|
7
31
|
beforeEach(async () => {
|
|
8
32
|
devAccessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
33
|
});
|
|
34
|
+
describe('snapshot request/response', () => {
|
|
35
|
+
let spy;
|
|
36
|
+
let commit;
|
|
37
|
+
beforeEach(async () => {
|
|
38
|
+
spy = jest.spyOn(apiRequestV4Module, 'apiRequestV4');
|
|
39
|
+
commit = await (0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
40
|
+
repoOwner: 'elastic',
|
|
41
|
+
repoName: 'kibana',
|
|
42
|
+
accessToken: devAccessToken,
|
|
43
|
+
sha: 'd421ddcf6157150596581c7885afa3690cec6339',
|
|
44
|
+
sourceBranch: 'main',
|
|
45
|
+
historicalBranchLabelMappings: [],
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
it('makes the right queries', () => {
|
|
49
|
+
const queries = spy.mock.calls.reduce((acc, call) => {
|
|
50
|
+
const query = call[0].query;
|
|
51
|
+
const ast = (0, graphql_tag_1.default)(query);
|
|
52
|
+
//@ts-expect-error
|
|
53
|
+
const name = ast.definitions[0].name.value;
|
|
54
|
+
return { ...acc, [name]: query };
|
|
55
|
+
}, {});
|
|
56
|
+
const queryNames = Object.keys(queries);
|
|
57
|
+
expect(queryNames).toEqual(['CommitsBySha']);
|
|
58
|
+
queryNames.forEach((name) => {
|
|
59
|
+
expect(queries[name]).toMatchSnapshot(`Query: ${name}`);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
it('returns the correct response', async () => {
|
|
63
|
+
expect(commit).toMatchSnapshot();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
10
66
|
it('should return single commit with pull request', async () => {
|
|
11
67
|
await expect(await (0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
12
68
|
repoOwner: 'elastic',
|
|
@@ -28,6 +84,10 @@ describe('fetchCommitBySha', () => {
|
|
|
28
84
|
state: 'MERGED',
|
|
29
85
|
number: 71014,
|
|
30
86
|
url: 'https://github.com/elastic/kibana/pull/71014',
|
|
87
|
+
mergeCommit: {
|
|
88
|
+
message: '[APM] Add API tests (#70740) (#71014)',
|
|
89
|
+
sha: 'd15242be682582e58cd69f6b7707565434e99293',
|
|
90
|
+
},
|
|
31
91
|
},
|
|
32
92
|
],
|
|
33
93
|
});
|
|
@@ -11,6 +11,8 @@ export declare function fetchCommitsByAuthor(options: {
|
|
|
11
11
|
repoName: string;
|
|
12
12
|
repoOwner: string;
|
|
13
13
|
sourceBranch: string;
|
|
14
|
+
dateSince: string | null;
|
|
15
|
+
dateUntil: string | null;
|
|
14
16
|
}): Promise<Commit[]>;
|
|
15
17
|
export interface CommitByAuthorResponse {
|
|
16
18
|
repository: {
|
|
@@ -8,7 +8,7 @@ const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
|
8
8
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
9
9
|
const fetchAuthorId_1 = require("../fetchAuthorId");
|
|
10
10
|
function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
11
|
-
const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', maxNumber = 10, repoName, repoOwner, sourceBranch, } = options;
|
|
11
|
+
const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', maxNumber = 10, repoName, repoOwner, sourceBranch, dateSince, dateUntil, } = options;
|
|
12
12
|
const query = /* GraphQL */ `
|
|
13
13
|
query CommitsByAuthor(
|
|
14
14
|
$repoOwner: String!
|
|
@@ -17,6 +17,8 @@ function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
|
17
17
|
$sourceBranch: String!
|
|
18
18
|
$authorId: ID
|
|
19
19
|
$commitPath: String
|
|
20
|
+
$dateSince: GitTimestamp
|
|
21
|
+
$dateUntil: GitTimestamp
|
|
20
22
|
) {
|
|
21
23
|
repository(owner: $repoOwner, name: $repoName) {
|
|
22
24
|
ref(qualifiedName: $sourceBranch) {
|
|
@@ -26,10 +28,12 @@ function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
|
26
28
|
first: $maxNumber
|
|
27
29
|
author: { id: $authorId }
|
|
28
30
|
path: $commitPath
|
|
31
|
+
since: $dateSince
|
|
32
|
+
until: $dateUntil
|
|
29
33
|
) {
|
|
30
34
|
edges {
|
|
31
35
|
node {
|
|
32
|
-
|
|
36
|
+
...SourceCommitWithTargetPullRequest
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
}
|
|
@@ -41,18 +45,21 @@ function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
|
41
45
|
|
|
42
46
|
${parseSourceCommit_1.sourceCommitWithTargetPullRequestFragment.source}
|
|
43
47
|
`;
|
|
48
|
+
const variables = {
|
|
49
|
+
repoOwner,
|
|
50
|
+
repoName,
|
|
51
|
+
sourceBranch,
|
|
52
|
+
maxNumber,
|
|
53
|
+
authorId,
|
|
54
|
+
commitPath,
|
|
55
|
+
dateSince,
|
|
56
|
+
dateUntil,
|
|
57
|
+
};
|
|
44
58
|
return (0, apiRequestV4_1.apiRequestV4)({
|
|
45
59
|
githubApiBaseUrlV4,
|
|
46
60
|
accessToken,
|
|
47
61
|
query,
|
|
48
|
-
variables
|
|
49
|
-
repoOwner,
|
|
50
|
-
repoName,
|
|
51
|
-
sourceBranch,
|
|
52
|
-
maxNumber,
|
|
53
|
-
authorId,
|
|
54
|
-
commitPath,
|
|
55
|
-
},
|
|
62
|
+
variables,
|
|
56
63
|
});
|
|
57
64
|
}
|
|
58
65
|
async function fetchCommitsByAuthor(options) {
|
|
@@ -1,12 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
2
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
3
26
|
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
27
|
+
const apiRequestV4Module = __importStar(require("../apiRequestV4"));
|
|
4
28
|
const fetchCommitsByAuthor_1 = require("./fetchCommitsByAuthor");
|
|
5
29
|
describe('fetchCommitsByAuthor', () => {
|
|
6
30
|
let devAccessToken;
|
|
7
31
|
beforeAll(async () => {
|
|
8
32
|
devAccessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
33
|
});
|
|
34
|
+
describe('snapshot request/response', () => {
|
|
35
|
+
let spy;
|
|
36
|
+
let commits;
|
|
37
|
+
beforeEach(async () => {
|
|
38
|
+
spy = jest.spyOn(apiRequestV4Module, 'apiRequestV4');
|
|
39
|
+
commits = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
40
|
+
accessToken: devAccessToken,
|
|
41
|
+
author: 'sqren',
|
|
42
|
+
historicalBranchLabelMappings: [],
|
|
43
|
+
maxNumber: 10,
|
|
44
|
+
repoName: 'kibana',
|
|
45
|
+
repoOwner: 'elastic',
|
|
46
|
+
sourceBranch: 'main',
|
|
47
|
+
dateSince: '2021-01-10T00:00:00Z',
|
|
48
|
+
dateUntil: '2022-01-01T00:00:00Z',
|
|
49
|
+
commitPaths: [],
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
it('makes the right queries', () => {
|
|
53
|
+
const queries = spy.mock.calls.reduce((acc, call) => {
|
|
54
|
+
const query = call[0].query;
|
|
55
|
+
const ast = (0, graphql_tag_1.default)(query);
|
|
56
|
+
//@ts-expect-error
|
|
57
|
+
const name = ast.definitions[0].name.value;
|
|
58
|
+
return { ...acc, [name]: query };
|
|
59
|
+
}, {});
|
|
60
|
+
const queryNames = Object.keys(queries);
|
|
61
|
+
expect(queryNames).toEqual(['AuthorId', 'CommitsByAuthor']);
|
|
62
|
+
queryNames.forEach((name) => {
|
|
63
|
+
expect(queries[name]).toMatchSnapshot(`Query: ${name}`);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
it('returns the correct response', async () => {
|
|
67
|
+
expect(commits).toMatchSnapshot();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
10
70
|
describe('commitPaths', () => {
|
|
11
71
|
const getOptions = () => ({
|
|
12
72
|
accessToken: devAccessToken,
|
|
@@ -16,6 +76,8 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
16
76
|
repoName: 'repo-with-different-commit-paths',
|
|
17
77
|
repoOwner: 'backport-org',
|
|
18
78
|
sourceBranch: 'main',
|
|
79
|
+
dateSince: null,
|
|
80
|
+
dateUntil: null,
|
|
19
81
|
});
|
|
20
82
|
const getCommitMessages = (commits) => {
|
|
21
83
|
return commits.map((c) => c.originalMessage.replace(/(\r\n|\n|\r)/gm, ''));
|
|
@@ -90,6 +152,8 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
90
152
|
repoOwner: 'backport-org',
|
|
91
153
|
sourceBranch: 'master',
|
|
92
154
|
author: null,
|
|
155
|
+
dateSince: null,
|
|
156
|
+
dateUntil: null,
|
|
93
157
|
});
|
|
94
158
|
});
|
|
95
159
|
it('returns related OPEN PRs', async () => {
|
|
@@ -111,12 +175,20 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
111
175
|
state: 'MERGED',
|
|
112
176
|
number: 6,
|
|
113
177
|
url: 'https://github.com/backport-org/backport-e2e/pull/6',
|
|
178
|
+
mergeCommit: {
|
|
179
|
+
message: 'Add 🍏 emoji (#5) (#6)',
|
|
180
|
+
sha: '4bcd876d4ceaa73cf437bfc89b74d1a4e704c0a6',
|
|
181
|
+
},
|
|
114
182
|
},
|
|
115
183
|
{
|
|
116
184
|
branch: '7.8',
|
|
117
185
|
state: 'MERGED',
|
|
118
186
|
number: 7,
|
|
119
187
|
url: 'https://github.com/backport-org/backport-e2e/pull/7',
|
|
188
|
+
mergeCommit: {
|
|
189
|
+
message: 'Add 🍏 emoji (#5) (#7)',
|
|
190
|
+
sha: '46cd6f9999effdf894a36dbc7db90e890f4be840',
|
|
191
|
+
},
|
|
120
192
|
},
|
|
121
193
|
]);
|
|
122
194
|
});
|
|
@@ -16,6 +16,8 @@ const defaultOptions = {
|
|
|
16
16
|
repoName: 'kibana',
|
|
17
17
|
repoOwner: 'elastic',
|
|
18
18
|
sourceBranch: 'source-branch-from-options',
|
|
19
|
+
dateSince: null,
|
|
20
|
+
dateUntil: null,
|
|
19
21
|
};
|
|
20
22
|
const authorIdMockData = { user: { id: 'myUserId' } };
|
|
21
23
|
describe('fetchCommitsByAuthor', () => {
|
|
@@ -72,6 +74,10 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
72
74
|
state: 'MERGED',
|
|
73
75
|
number: 99,
|
|
74
76
|
url: 'https://github.com/elastic/kibana/pull/99',
|
|
77
|
+
mergeCommit: {
|
|
78
|
+
message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
|
|
79
|
+
sha: 'target-merge-commit-sha',
|
|
80
|
+
},
|
|
75
81
|
},
|
|
76
82
|
],
|
|
77
83
|
sourceBranch: 'master',
|
|
@@ -13,7 +13,7 @@ async function fetchPullRequestBySearchQuery(options) {
|
|
|
13
13
|
nodes {
|
|
14
14
|
... on PullRequest {
|
|
15
15
|
mergeCommit {
|
|
16
|
-
|
|
16
|
+
...SourceCommitWithTargetPullRequest
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -22,16 +22,17 @@ async function fetchPullRequestBySearchQuery(options) {
|
|
|
22
22
|
|
|
23
23
|
${parseSourceCommit_1.sourceCommitWithTargetPullRequestFragment.source}
|
|
24
24
|
`;
|
|
25
|
-
const authorFilter = author ? `author:${author}` : '';
|
|
26
|
-
const searchQuery = `type:pr is:merged sort:updated-desc repo:${repoOwner}/${repoName}
|
|
25
|
+
const authorFilter = author ? ` author:${author}` : '';
|
|
26
|
+
const searchQuery = `type:pr is:merged sort:updated-desc repo:${repoOwner}/${repoName}${authorFilter} ${prFilter} base:${sourceBranch}`;
|
|
27
|
+
const variables = {
|
|
28
|
+
query: searchQuery,
|
|
29
|
+
maxNumber: maxNumber,
|
|
30
|
+
};
|
|
27
31
|
const res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
28
32
|
githubApiBaseUrlV4,
|
|
29
33
|
accessToken,
|
|
30
34
|
query,
|
|
31
|
-
variables
|
|
32
|
-
query: searchQuery,
|
|
33
|
-
maxNumber: maxNumber,
|
|
34
|
-
},
|
|
35
|
+
variables,
|
|
35
36
|
});
|
|
36
37
|
const commits = res.search.nodes.map((pullRequestNode) => {
|
|
37
38
|
const sourceCommit = pullRequestNode.mergeCommit;
|
|
@@ -57,12 +57,20 @@ describe('fetchPullRequestBySearchQuery', () => {
|
|
|
57
57
|
state: 'MERGED',
|
|
58
58
|
number: 6,
|
|
59
59
|
url: 'https://github.com/backport-org/backport-e2e/pull/6',
|
|
60
|
+
mergeCommit: {
|
|
61
|
+
message: 'Add 🍏 emoji (#5) (#6)',
|
|
62
|
+
sha: '4bcd876d4ceaa73cf437bfc89b74d1a4e704c0a6',
|
|
63
|
+
},
|
|
60
64
|
},
|
|
61
65
|
{
|
|
62
66
|
branch: '7.8',
|
|
63
67
|
state: 'MERGED',
|
|
64
68
|
number: 7,
|
|
65
69
|
url: 'https://github.com/backport-org/backport-e2e/pull/7',
|
|
70
|
+
mergeCommit: {
|
|
71
|
+
message: 'Add 🍏 emoji (#5) (#7)',
|
|
72
|
+
sha: '46cd6f9999effdf894a36dbc7db90e890f4be840',
|
|
73
|
+
},
|
|
66
74
|
},
|
|
67
75
|
],
|
|
68
76
|
originalMessage: 'Add 🍏 emoji (#5)',
|
|
@@ -28,6 +28,7 @@ export declare function getOptionsFromGithub(options: {
|
|
|
28
28
|
}) => boolean | Promise<boolean>) | undefined;
|
|
29
29
|
autoMerge?: boolean | undefined;
|
|
30
30
|
autoMergeMethod?: string | undefined;
|
|
31
|
+
backportBinary?: string | undefined;
|
|
31
32
|
cherrypickRef?: boolean | undefined;
|
|
32
33
|
ci?: boolean | undefined;
|
|
33
34
|
commitPaths?: string[] | undefined;
|
|
@@ -40,6 +40,10 @@ exports.commitsByAuthorMock = {
|
|
|
40
40
|
nodes: [{ name: 'my-label-b' }],
|
|
41
41
|
},
|
|
42
42
|
number: 85,
|
|
43
|
+
sourceMergeCommit: {
|
|
44
|
+
oid: 'f3b618b9421fdecdb36862f907afbdd6344b361d',
|
|
45
|
+
message: 'Add witch (#85)',
|
|
46
|
+
},
|
|
43
47
|
timelineItems: {
|
|
44
48
|
edges: [],
|
|
45
49
|
},
|
|
@@ -68,12 +72,24 @@ exports.commitsByAuthorMock = {
|
|
|
68
72
|
},
|
|
69
73
|
baseRefName: 'master',
|
|
70
74
|
number: 80,
|
|
75
|
+
sourceMergeCommit: {
|
|
76
|
+
oid: '79cf18453ec32a4677009dcbab1c9c8c73fc14fe',
|
|
77
|
+
message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
|
|
78
|
+
},
|
|
71
79
|
timelineItems: {
|
|
72
80
|
edges: [
|
|
73
81
|
{
|
|
74
82
|
node: {
|
|
75
83
|
targetPullRequest: {
|
|
76
84
|
__typename: 'PullRequest',
|
|
85
|
+
targetMergeCommit: {
|
|
86
|
+
oid: 'target-merge-commit-sha',
|
|
87
|
+
message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
|
|
88
|
+
},
|
|
89
|
+
repository: {
|
|
90
|
+
name: 'kibana',
|
|
91
|
+
owner: { login: 'elastic' },
|
|
92
|
+
},
|
|
77
93
|
url: 'https://github.com/elastic/kibana/pull/99',
|
|
78
94
|
title: 'some title',
|
|
79
95
|
state: 'MERGED',
|
|
@@ -84,11 +100,6 @@ exports.commitsByAuthorMock = {
|
|
|
84
100
|
{
|
|
85
101
|
node: {
|
|
86
102
|
targetCommit: {
|
|
87
|
-
repository: {
|
|
88
|
-
name: 'kibana',
|
|
89
|
-
owner: { login: 'elastic' },
|
|
90
|
-
},
|
|
91
|
-
committedDate: '2021-12-23T00:00:00Z',
|
|
92
103
|
oid: 'abc',
|
|
93
104
|
message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
|
|
94
105
|
},
|
|
@@ -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
|
]);
|
|
@@ -285,6 +301,23 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
285
301
|
{ branch: 'master', state: 'MISSING' },
|
|
286
302
|
]);
|
|
287
303
|
});
|
|
304
|
+
it(`should support "backport-to" format`, () => {
|
|
305
|
+
const branchLabelMapping = {
|
|
306
|
+
'^backport-to-(.+)$': '$1',
|
|
307
|
+
};
|
|
308
|
+
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
309
|
+
sourceCommit: { message: 'identical messages (#1234)' },
|
|
310
|
+
sourcePullRequest: {
|
|
311
|
+
number: 1234,
|
|
312
|
+
labels: ['backport-to-dev', 'backport-to-v3.1.0'],
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
const expectedTargetPullRequests = (0, getExpectedTargetPullRequests_1.getExpectedTargetPullRequests)(mockSourceCommit, branchLabelMapping);
|
|
316
|
+
expect(expectedTargetPullRequests).toEqual([
|
|
317
|
+
{ branch: 'dev', state: 'MISSING' },
|
|
318
|
+
{ branch: 'v3.1.0', state: 'MISSING' },
|
|
319
|
+
]);
|
|
320
|
+
});
|
|
288
321
|
it('should only get first match', () => {
|
|
289
322
|
const branchLabelMapping = {
|
|
290
323
|
'label-2': 'branch-b',
|
|
@@ -387,6 +420,10 @@ describe('getExpectedTargetPullRequests', () => {
|
|
|
387
420
|
number: 5678,
|
|
388
421
|
state: 'MERGED',
|
|
389
422
|
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
423
|
+
mergeCommit: {
|
|
424
|
+
message: 'identical messages (#1234)',
|
|
425
|
+
sha: 'target-merge-commit-sha',
|
|
426
|
+
},
|
|
390
427
|
},
|
|
391
428
|
{ branch: 'branch-1', state: 'MISSING' },
|
|
392
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
|
}
|