backport 7.0.0 → 7.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 +2 -1
- package/dist/backportRun.d.ts +1 -0
- package/dist/backportRun.js +4 -3
- package/dist/entrypoint.cli.e2e.private.test.js +58 -19
- package/dist/entrypoint.cli.js +12 -1
- package/dist/options/ConfigOptions.d.ts +1 -0
- package/dist/options/cliArgs.d.ts +1 -1
- package/dist/options/cliArgs.test.js +12 -0
- package/dist/options/config/config.d.ts +1 -0
- package/dist/options/config/projectConfig.js +2 -2
- package/dist/options/config/readConfigFile.d.ts +2 -1
- package/dist/options/options.d.ts +2 -5
- package/dist/options/options.test.js +26 -28
- package/dist/runSequentially.test.js +1 -2
- package/dist/services/HandledError.js +3 -1
- package/dist/services/git.js +5 -8
- package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.js +3 -6
- package/dist/services/github/v3/addLabelsToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addLabelsToPullRequest.js +3 -6
- package/dist/services/github/v3/addReviewersToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addReviewersToPullRequest.js +3 -6
- package/dist/services/github/v3/createPullRequest.js +2 -5
- package/dist/services/github/v3/createPullRequest.test.js +5 -5
- package/dist/services/github/v3/createStatusComment.test.js +7 -7
- package/dist/services/github/v4/FetchPullRequestId.js +5 -1
- package/dist/services/github/v4/apiRequestV4.d.ts +3 -1
- package/dist/services/github/v4/apiRequestV4.js +7 -7
- package/dist/services/github/v4/apiRequestV4.test.js +38 -11
- package/dist/services/github/v4/disablePullRequestAutoMerge.js +5 -1
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +4 -3
- package/dist/services/github/v4/fetchAuthorId.js +5 -1
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +6 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +3 -12
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +6 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +3 -11
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +6 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +7 -12
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +6 -2
- package/dist/services/github/v4/fetchExistingPullRequest.js +5 -1
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +5 -1
- package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +1 -1
- package/dist/services/github/v4/fetchRemoteProjectConfig.js +13 -20
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -4
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +14 -55
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -19
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +3 -16
- package/dist/services/github/v4/getOptionsFromGithub/query.js +9 -19
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +5 -1
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +5 -0
- package/dist/services/logger.d.ts +5 -5
- package/dist/services/logger.js +24 -23
- package/dist/services/remoteConfig.d.ts +18 -0
- package/dist/services/remoteConfig.js +39 -0
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +4 -0
- package/dist/services/sourceCommit/getMockSourceCommit.js +20 -6
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +3 -4
- package/dist/services/sourceCommit/parseSourceCommit.js +73 -71
- package/dist/services/sourceCommit/parseSourceCommit.test.js +7 -17
- package/dist/test/backport-e2e.mutation.test.js +3 -3
- package/dist/test/nockHelpers.js +6 -2
- package/dist/test/setupFiles/automatic-mocks.js +5 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +4 -4
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +3 -3
- package/dist/ui/getCommits.js +2 -2
- package/dist/ui/ora.d.ts +9 -0
- package/dist/ui/ora.js +21 -0
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +2 -2
|
@@ -31,7 +31,7 @@ describe('getPullRequestBody', () => {
|
|
|
31
31
|
This will backport the following commits from \`master\` to \`7.x\`:
|
|
32
32
|
- [My commit message (#55)](https://github.com/backport-org/different-merge-strategies/pull/55)
|
|
33
33
|
|
|
34
|
-
<!--- Backport version: 1.2.3 -->
|
|
34
|
+
<!--- Backport version: 1.2.3-mocked -->
|
|
35
35
|
|
|
36
36
|
### Questions ?
|
|
37
37
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)"
|
|
@@ -58,7 +58,7 @@ describe('getPullRequestBody', () => {
|
|
|
58
58
|
This will backport the following commits from \`main\` to \`7.x\`:
|
|
59
59
|
- My commit message (abcdefgh)
|
|
60
60
|
|
|
61
|
-
<!--- Backport version: 1.2.3 -->
|
|
61
|
+
<!--- Backport version: 1.2.3-mocked -->
|
|
62
62
|
|
|
63
63
|
### Questions ?
|
|
64
64
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)"
|
|
@@ -103,7 +103,7 @@ describe('getPullRequestBody', () => {
|
|
|
103
103
|
- [My commit message (#55)](https://github.com/backport-org/different-merge-strategies/pull/55)
|
|
104
104
|
- Another commit message (qwertyui)
|
|
105
105
|
|
|
106
|
-
<!--- Backport version: 1.2.3 -->
|
|
106
|
+
<!--- Backport version: 1.2.3-mocked -->
|
|
107
107
|
|
|
108
108
|
### Questions ?
|
|
109
109
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)"
|
|
@@ -156,7 +156,7 @@ describe('getPullRequestBody', () => {
|
|
|
156
156
|
- [Merge strategy: Second commit](https://github.com/backport-org/different-merge-strategies/pull/1)
|
|
157
157
|
- [Merge strategy: First commit](https://github.com/backport-org/different-merge-strategies/pull/1)
|
|
158
158
|
|
|
159
|
-
<!--- Backport version: 1.2.3 -->
|
|
159
|
+
<!--- Backport version: 1.2.3-mocked -->
|
|
160
160
|
|
|
161
161
|
### Questions ?
|
|
162
162
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)"
|
|
@@ -243,7 +243,7 @@ describe('getPullRequestBody', () => {
|
|
|
243
243
|
- [My commit message (#55)](https://github.com/backport-org/different-merge-strategies/pull/55)
|
|
244
244
|
- Another commit message (qwertyui)
|
|
245
245
|
|
|
246
|
-
<!--- Backport version: 1.2.3 -->
|
|
246
|
+
<!--- Backport version: 1.2.3-mocked -->
|
|
247
247
|
|
|
248
248
|
### Questions ?
|
|
249
249
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
@@ -65,7 +65,7 @@ describe('getCommentBody', () => {
|
|
|
65
65
|
|
|
66
66
|
### Questions ?
|
|
67
67
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
68
|
-
<!--- Backport version: 1.2.3 -->"
|
|
68
|
+
<!--- Backport version: 1.2.3-mocked -->"
|
|
69
69
|
`);
|
|
70
70
|
});
|
|
71
71
|
it('does not post a comment when running manually', () => {
|
|
@@ -114,7 +114,7 @@ describe('getCommentBody', () => {
|
|
|
114
114
|
|
|
115
115
|
### Questions ?
|
|
116
116
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
117
|
-
<!--- Backport version: 1.2.3 -->"
|
|
117
|
+
<!--- Backport version: 1.2.3-mocked -->"
|
|
118
118
|
`);
|
|
119
119
|
});
|
|
120
120
|
it('posts a comment when running locally', () => {
|
|
@@ -131,7 +131,7 @@ describe('getCommentBody', () => {
|
|
|
131
131
|
|
|
132
132
|
### Questions ?
|
|
133
133
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
134
|
-
<!--- Backport version: 1.2.3 -->"
|
|
134
|
+
<!--- Backport version: 1.2.3-mocked -->"
|
|
135
135
|
`);
|
|
136
136
|
});
|
|
137
137
|
});
|
|
@@ -179,7 +179,7 @@ describe('getCommentBody', () => {
|
|
|
179
179
|
|
|
180
180
|
### Questions ?
|
|
181
181
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
182
|
-
<!--- Backport version: 1.2.3 -->"
|
|
182
|
+
<!--- Backport version: 1.2.3-mocked -->"
|
|
183
183
|
`);
|
|
184
184
|
});
|
|
185
185
|
it('does not post a comment when running manaully', () => {
|
|
@@ -233,7 +233,7 @@ describe('getCommentBody', () => {
|
|
|
233
233
|
|
|
234
234
|
### Questions ?
|
|
235
235
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
236
|
-
<!--- Backport version: 1.2.3 -->"
|
|
236
|
+
<!--- Backport version: 1.2.3-mocked -->"
|
|
237
237
|
`);
|
|
238
238
|
});
|
|
239
239
|
it('does not post a comment when running manually because some backports failed', () => {
|
|
@@ -338,7 +338,7 @@ describe('getCommentBody', () => {
|
|
|
338
338
|
|
|
339
339
|
### Questions ?
|
|
340
340
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
341
|
-
<!--- Backport version: 1.2.3 -->"
|
|
341
|
+
<!--- Backport version: 1.2.3-mocked -->"
|
|
342
342
|
`);
|
|
343
343
|
});
|
|
344
344
|
it('does not post a comment when running manually because some backports failed', () => {
|
|
@@ -375,7 +375,7 @@ describe('getCommentBody', () => {
|
|
|
375
375
|
|
|
376
376
|
### Questions ?
|
|
377
377
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
378
|
-
<!--- Backport version: 1.2.3 -->"
|
|
378
|
+
<!--- Backport version: 1.2.3-mocked -->"
|
|
379
379
|
`);
|
|
380
380
|
});
|
|
381
381
|
it('does not post a comment when running manually', () => {
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.fetchPullRequestId = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
4
8
|
const apiRequestV4_1 = require("./apiRequestV4");
|
|
5
9
|
async function fetchPullRequestId(options, pullNumber) {
|
|
6
10
|
const { accessToken, githubApiBaseUrlV4, repoName, repoOwner } = options;
|
|
7
|
-
const prQuery =
|
|
11
|
+
const prQuery = (0, graphql_tag_1.default) `
|
|
8
12
|
query PullRequestId(
|
|
9
13
|
$repoOwner: String!
|
|
10
14
|
$repoName: String!
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
+
import { DocumentNode } from 'graphql';
|
|
2
3
|
interface GithubError {
|
|
3
4
|
type: string;
|
|
4
5
|
path: string[];
|
|
@@ -16,7 +17,7 @@ declare type Variables = Record<string, string | number | null>;
|
|
|
16
17
|
export declare function apiRequestV4<DataResponse>({ githubApiBaseUrlV4, accessToken, query, variables, }: {
|
|
17
18
|
githubApiBaseUrlV4?: string;
|
|
18
19
|
accessToken: string;
|
|
19
|
-
query:
|
|
20
|
+
query: DocumentNode;
|
|
20
21
|
variables?: Variables;
|
|
21
22
|
}): Promise<DataResponse>;
|
|
22
23
|
declare type AxiosGithubResponse<DataResponse> = AxiosResponse<GithubV4Response<DataResponse | null>, any>;
|
|
@@ -25,4 +26,5 @@ export declare class GithubV4Exception<DataResponse> extends Error {
|
|
|
25
26
|
axiosResponse: AxiosGithubResponse<DataResponse>;
|
|
26
27
|
constructor(message: string, axiosResponse: AxiosGithubResponse<DataResponse>);
|
|
27
28
|
}
|
|
29
|
+
export declare function getQueryName(query: DocumentNode): string;
|
|
28
30
|
export {};
|
|
@@ -3,14 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GithubV4Exception = exports.apiRequestV4 = void 0;
|
|
6
|
+
exports.getQueryName = exports.GithubV4Exception = exports.apiRequestV4 = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const
|
|
8
|
+
const printer_1 = require("graphql/language/printer");
|
|
9
9
|
const HandledError_1 = require("../../HandledError");
|
|
10
10
|
const logger_1 = require("../../logger");
|
|
11
11
|
async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graphql', accessToken, query, variables, }) {
|
|
12
12
|
try {
|
|
13
|
-
const response = await axios_1.default.post(githubApiBaseUrlV4, { query, variables }, {
|
|
13
|
+
const response = await axios_1.default.post(githubApiBaseUrlV4, { query: (0, printer_1.print)(query), variables }, {
|
|
14
14
|
headers: {
|
|
15
15
|
'Content-Type': 'application/json',
|
|
16
16
|
Authorization: `bearer ${accessToken}`,
|
|
@@ -47,7 +47,7 @@ async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graph
|
|
|
47
47
|
}
|
|
48
48
|
exports.apiRequestV4 = apiRequestV4;
|
|
49
49
|
function addDebugLogs({ githubApiBaseUrlV4, query, variables, axiosResponse, didSucceed, }) {
|
|
50
|
-
const gqlQueryName =
|
|
50
|
+
const gqlQueryName = getQueryName(query);
|
|
51
51
|
logger_1.logger.info(`POST ${githubApiBaseUrlV4} (name:${gqlQueryName}, status: ${axiosResponse.status})`);
|
|
52
52
|
const logMethod = didSucceed ? logger_1.logger.verbose : logger_1.logger.info;
|
|
53
53
|
logMethod(`Query name ${gqlQueryName}`);
|
|
@@ -66,8 +66,8 @@ class GithubV4Exception extends Error {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
exports.GithubV4Exception = GithubV4Exception;
|
|
69
|
-
function
|
|
70
|
-
const ast = (0, graphql_tag_1.default)(query);
|
|
69
|
+
function getQueryName(query) {
|
|
71
70
|
//@ts-expect-error
|
|
72
|
-
return
|
|
71
|
+
return query.definitions[0].name?.value;
|
|
73
72
|
}
|
|
73
|
+
exports.getQueryName = getQueryName;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
6
7
|
const nock_1 = __importDefault(require("nock"));
|
|
7
8
|
const nockHelpers_1 = require("../../../test/nockHelpers");
|
|
8
9
|
const HandledError_1 = require("../../HandledError");
|
|
@@ -18,25 +19,39 @@ describe('apiRequestV4', () => {
|
|
|
18
19
|
commitsByAuthorCalls = (0, nockHelpers_1.mockGqlRequest)({
|
|
19
20
|
name: 'MyQuery',
|
|
20
21
|
statusCode: 200,
|
|
21
|
-
body: { data: {
|
|
22
|
+
body: { data: { viewer: { login: 'sqren' } } },
|
|
22
23
|
});
|
|
23
24
|
res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
24
25
|
accessToken: 'myAccessToken',
|
|
25
26
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
26
|
-
query:
|
|
27
|
+
query: (0, graphql_tag_1.default) `
|
|
28
|
+
query MyQuery {
|
|
29
|
+
viewer {
|
|
30
|
+
login
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
`,
|
|
27
34
|
variables: { foo: 'bar' },
|
|
28
35
|
});
|
|
29
36
|
});
|
|
30
37
|
it('should return correct response', async () => {
|
|
31
|
-
expect(res).toEqual({
|
|
38
|
+
expect(res).toEqual({ viewer: { login: 'sqren' } });
|
|
32
39
|
});
|
|
33
40
|
it('should call with correct args', async () => {
|
|
34
|
-
expect(commitsByAuthorCalls).
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
expect(commitsByAuthorCalls).toMatchInlineSnapshot(`
|
|
42
|
+
Array [
|
|
43
|
+
Object {
|
|
44
|
+
"query": "query MyQuery {
|
|
45
|
+
viewer {
|
|
46
|
+
login
|
|
47
|
+
}
|
|
48
|
+
}",
|
|
49
|
+
"variables": Object {
|
|
50
|
+
"foo": "bar",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
]
|
|
54
|
+
`);
|
|
40
55
|
});
|
|
41
56
|
});
|
|
42
57
|
describe('when request fails with error messages', () => {
|
|
@@ -53,7 +68,13 @@ describe('apiRequestV4', () => {
|
|
|
53
68
|
return expect((0, apiRequestV4_1.apiRequestV4)({
|
|
54
69
|
accessToken: 'myAccessToken',
|
|
55
70
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
56
|
-
query:
|
|
71
|
+
query: (0, graphql_tag_1.default) `
|
|
72
|
+
query MyQuery {
|
|
73
|
+
viewer {
|
|
74
|
+
login
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
`,
|
|
57
78
|
variables: {
|
|
58
79
|
foo: 'bar',
|
|
59
80
|
},
|
|
@@ -72,7 +93,13 @@ describe('apiRequestV4', () => {
|
|
|
72
93
|
return expect((0, apiRequestV4_1.apiRequestV4)({
|
|
73
94
|
accessToken: 'myAccessToken',
|
|
74
95
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
75
|
-
query:
|
|
96
|
+
query: (0, graphql_tag_1.default) `
|
|
97
|
+
query MyQuery {
|
|
98
|
+
viewer {
|
|
99
|
+
login
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
`,
|
|
76
103
|
variables: {
|
|
77
104
|
foo: 'bar',
|
|
78
105
|
},
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.disablePullRequestAutoMerge = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
4
8
|
const FetchPullRequestId_1 = require("./FetchPullRequestId");
|
|
5
9
|
const apiRequestV4_1 = require("./apiRequestV4");
|
|
6
10
|
async function disablePullRequestAutoMerge(options, pullNumber) {
|
|
7
11
|
const { accessToken, githubApiBaseUrlV4 } = options;
|
|
8
12
|
const pullRequestId = await (0, FetchPullRequestId_1.fetchPullRequestId)(options, pullNumber);
|
|
9
|
-
const query =
|
|
13
|
+
const query = (0, graphql_tag_1.default) `
|
|
10
14
|
mutation DisablePullRequestAutoMerge($pullRequestId: ID!) {
|
|
11
15
|
disablePullRequestAutoMerge(input: { pullRequestId: $pullRequestId }) {
|
|
12
16
|
pullRequest {
|
|
@@ -4,7 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.enablePullRequestAutoMerge = void 0;
|
|
7
|
-
const
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
+
const ora_1 = require("../../../ui/ora");
|
|
8
9
|
const logger_1 = require("../../logger");
|
|
9
10
|
const FetchPullRequestId_1 = require("./FetchPullRequestId");
|
|
10
11
|
const apiRequestV4_1 = require("./apiRequestV4");
|
|
@@ -12,9 +13,9 @@ async function enablePullRequestAutoMerge(options, targetPullRequestNumber) {
|
|
|
12
13
|
const { accessToken, githubApiBaseUrlV4, autoMergeMethod = 'merge', } = options;
|
|
13
14
|
const text = `Enabling auto merging via ${options.autoMergeMethod}`;
|
|
14
15
|
logger_1.logger.info(text);
|
|
15
|
-
const spinner = (0, ora_1.
|
|
16
|
+
const spinner = (0, ora_1.ora)(options.ci, text).start();
|
|
16
17
|
const pullRequestId = await (0, FetchPullRequestId_1.fetchPullRequestId)(options, targetPullRequestNumber);
|
|
17
|
-
const query =
|
|
18
|
+
const query = (0, graphql_tag_1.default) `
|
|
18
19
|
mutation EnablePullRequestAutoMerge(
|
|
19
20
|
$pullRequestId: ID!
|
|
20
21
|
$mergeMethod: PullRequestMergeMethod!
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.fetchAuthorId = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
4
8
|
const apiRequestV4_1 = require("./apiRequestV4");
|
|
5
9
|
async function fetchAuthorId({ accessToken, author, githubApiBaseUrlV4 = 'https://api.github.com/graphql', }) {
|
|
6
10
|
if (author === null) {
|
|
7
11
|
return null;
|
|
8
12
|
}
|
|
9
|
-
const query =
|
|
13
|
+
const query = (0, graphql_tag_1.default) `
|
|
10
14
|
query AuthorId($author: String!) {
|
|
11
15
|
user(login: $author) {
|
|
12
16
|
id
|
|
@@ -13,7 +13,6 @@ describe('allFetchers', () => {
|
|
|
13
13
|
const commitsByAuthor = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
14
14
|
accessToken: devAccessToken,
|
|
15
15
|
author: 'sqren',
|
|
16
|
-
historicalBranchLabelMappings: [],
|
|
17
16
|
maxNumber: 1,
|
|
18
17
|
repoName: 'kibana',
|
|
19
18
|
repoOwner: 'elastic',
|
|
@@ -34,7 +33,6 @@ describe('allFetchers', () => {
|
|
|
34
33
|
accessToken: devAccessToken,
|
|
35
34
|
pullNumber: commitByAuthor.sourcePullRequest.number,
|
|
36
35
|
sourceBranch: 'master',
|
|
37
|
-
historicalBranchLabelMappings: [],
|
|
38
36
|
});
|
|
39
37
|
expect(commitByAuthor).toEqual(commitByPullNumber);
|
|
40
38
|
});
|
|
@@ -45,7 +43,6 @@ describe('allFetchers', () => {
|
|
|
45
43
|
accessToken: devAccessToken,
|
|
46
44
|
sha: commitByAuthor.sourceCommit.sha,
|
|
47
45
|
sourceBranch: 'main',
|
|
48
|
-
historicalBranchLabelMappings: [],
|
|
49
46
|
});
|
|
50
47
|
expect(commitByAuthor).toEqual(commitBySha);
|
|
51
48
|
});
|
|
@@ -4,7 +4,6 @@ export declare function fetchCommitByPullNumber(options: {
|
|
|
4
4
|
accessToken: string;
|
|
5
5
|
branchLabelMapping?: ValidConfigOptions['branchLabelMapping'];
|
|
6
6
|
githubApiBaseUrlV4?: string;
|
|
7
|
-
historicalBranchLabelMappings: ValidConfigOptions['historicalBranchLabelMappings'];
|
|
8
7
|
pullNumber: number;
|
|
9
8
|
repoName: string;
|
|
10
9
|
repoOwner: string;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.fetchCommitByPullNumber = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
4
8
|
const HandledError_1 = require("../../../HandledError");
|
|
5
9
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
6
10
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
7
11
|
async function fetchCommitByPullNumber(options) {
|
|
8
12
|
const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', pullNumber, repoName, repoOwner, } = options;
|
|
9
|
-
const query =
|
|
13
|
+
const query = (0, graphql_tag_1.default) `
|
|
10
14
|
query CommitByPullNumber(
|
|
11
15
|
$repoOwner: String!
|
|
12
16
|
$repoName: String!
|
|
@@ -21,7 +25,7 @@ async function fetchCommitByPullNumber(options) {
|
|
|
21
25
|
}
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
${parseSourceCommit_1.sourceCommitWithTargetPullRequestFragment
|
|
28
|
+
${parseSourceCommit_1.sourceCommitWithTargetPullRequestFragment}
|
|
25
29
|
`;
|
|
26
30
|
const res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
27
31
|
githubApiBaseUrlV4,
|
|
@@ -18,11 +18,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const
|
|
22
|
+
const graphql_1 = require("graphql");
|
|
26
23
|
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
27
24
|
const apiRequestV4Module = __importStar(require("../apiRequestV4"));
|
|
28
25
|
const fetchCommitByPullNumber_1 = require("./fetchCommitByPullNumber");
|
|
@@ -42,16 +39,13 @@ describe('fetchCommitByPullNumber', () => {
|
|
|
42
39
|
accessToken: devAccessToken,
|
|
43
40
|
pullNumber: 121633,
|
|
44
41
|
sourceBranch: 'master',
|
|
45
|
-
historicalBranchLabelMappings: [],
|
|
46
42
|
});
|
|
47
43
|
});
|
|
48
44
|
it('makes the right queries', () => {
|
|
49
45
|
const queries = spy.mock.calls.reduce((acc, call) => {
|
|
50
46
|
const query = call[0].query;
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
const name = ast.definitions[0].name.value;
|
|
54
|
-
return { ...acc, [name]: query };
|
|
47
|
+
const name = apiRequestV4Module.getQueryName(query);
|
|
48
|
+
return { ...acc, [name]: (0, graphql_1.print)(query) };
|
|
55
49
|
}, {});
|
|
56
50
|
const queryNames = Object.keys(queries);
|
|
57
51
|
expect(queryNames).toEqual(['CommitByPullNumber']);
|
|
@@ -71,7 +65,6 @@ describe('fetchCommitByPullNumber', () => {
|
|
|
71
65
|
repoName: 'backport-e2e',
|
|
72
66
|
repoOwner: 'backport-org',
|
|
73
67
|
sourceBranch: 'main',
|
|
74
|
-
historicalBranchLabelMappings: [],
|
|
75
68
|
};
|
|
76
69
|
const expectedCommit = {
|
|
77
70
|
sourceCommit: {
|
|
@@ -122,7 +115,6 @@ describe('fetchCommitByPullNumber', () => {
|
|
|
122
115
|
repoName: 'backport-e2e',
|
|
123
116
|
repoOwner: 'backport-org',
|
|
124
117
|
sourceBranch: 'main',
|
|
125
|
-
historicalBranchLabelMappings: [],
|
|
126
118
|
};
|
|
127
119
|
await expect((0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)(options)).rejects.toThrowError(`The PR #11 is not merged`);
|
|
128
120
|
});
|
|
@@ -135,7 +127,6 @@ describe('fetchCommitByPullNumber', () => {
|
|
|
135
127
|
repoName: 'backport-e2e',
|
|
136
128
|
repoOwner: 'backport-org',
|
|
137
129
|
sourceBranch: 'main',
|
|
138
|
-
historicalBranchLabelMappings: [],
|
|
139
130
|
};
|
|
140
131
|
await expect((0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)(options)).rejects.toThrowError(`Could not resolve to a PullRequest with the number of 9999999999999. (Github API v4)`);
|
|
141
132
|
});
|
|
@@ -4,7 +4,6 @@ export declare function fetchCommitBySha(options: {
|
|
|
4
4
|
accessToken: string;
|
|
5
5
|
branchLabelMapping?: ValidConfigOptions['branchLabelMapping'];
|
|
6
6
|
githubApiBaseUrlV4?: string;
|
|
7
|
-
historicalBranchLabelMappings: ValidConfigOptions['historicalBranchLabelMappings'];
|
|
8
7
|
repoName: string;
|
|
9
8
|
repoOwner: string;
|
|
10
9
|
sha: string;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.fetchCommitBySha = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
4
8
|
const HandledError_1 = require("../../../HandledError");
|
|
5
9
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
6
10
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
7
11
|
async function fetchCommitBySha(options) {
|
|
8
12
|
const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', repoName, repoOwner, sha, sourceBranch, } = options;
|
|
9
|
-
const query =
|
|
13
|
+
const query = (0, graphql_tag_1.default) `
|
|
10
14
|
query CommitsBySha($repoOwner: String!, $repoName: String!, $sha: String!) {
|
|
11
15
|
repository(owner: $repoOwner, name: $repoName) {
|
|
12
16
|
object(expression: $sha) {
|
|
@@ -15,7 +19,7 @@ async function fetchCommitBySha(options) {
|
|
|
15
19
|
}
|
|
16
20
|
}
|
|
17
21
|
|
|
18
|
-
${parseSourceCommit_1.sourceCommitWithTargetPullRequestFragment
|
|
22
|
+
${parseSourceCommit_1.sourceCommitWithTargetPullRequestFragment}
|
|
19
23
|
`;
|
|
20
24
|
const res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
21
25
|
githubApiBaseUrlV4,
|
|
@@ -18,11 +18,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const
|
|
22
|
+
const graphql_1 = require("graphql");
|
|
26
23
|
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
27
24
|
const apiRequestV4Module = __importStar(require("../apiRequestV4"));
|
|
28
25
|
const fetchCommitBySha_1 = require("./fetchCommitBySha");
|
|
@@ -42,16 +39,14 @@ describe('fetchCommitBySha', () => {
|
|
|
42
39
|
accessToken: devAccessToken,
|
|
43
40
|
sha: 'd421ddcf6157150596581c7885afa3690cec6339',
|
|
44
41
|
sourceBranch: 'main',
|
|
45
|
-
historicalBranchLabelMappings: [],
|
|
46
42
|
});
|
|
47
43
|
});
|
|
48
44
|
it('makes the right queries', () => {
|
|
49
45
|
const queries = spy.mock.calls.reduce((acc, call) => {
|
|
50
46
|
const query = call[0].query;
|
|
51
|
-
const ast = (0, graphql_tag_1.default)(query);
|
|
52
47
|
//@ts-expect-error
|
|
53
|
-
const name =
|
|
54
|
-
return { ...acc, [name]: query };
|
|
48
|
+
const name = query.definitions[0].name.value;
|
|
49
|
+
return { ...acc, [name]: (0, graphql_1.print)(query) };
|
|
55
50
|
}, {});
|
|
56
51
|
const queryNames = Object.keys(queries);
|
|
57
52
|
expect(queryNames).toEqual(['CommitsBySha']);
|
|
@@ -98,7 +93,6 @@ describe('fetchCommitBySha', () => {
|
|
|
98
93
|
accessToken: devAccessToken,
|
|
99
94
|
sha: 'cb6fbc0',
|
|
100
95
|
sourceBranch: 'master',
|
|
101
|
-
historicalBranchLabelMappings: [],
|
|
102
96
|
})).toEqual(expectedCommit);
|
|
103
97
|
});
|
|
104
98
|
it('throws if sha does not exist', async () => {
|
|
@@ -108,7 +102,6 @@ describe('fetchCommitBySha', () => {
|
|
|
108
102
|
accessToken: devAccessToken,
|
|
109
103
|
sha: 'fc22f59',
|
|
110
104
|
sourceBranch: 'main',
|
|
111
|
-
historicalBranchLabelMappings: [],
|
|
112
105
|
})).rejects.toThrowError('No commit found on branch "main" with sha "fc22f59"');
|
|
113
106
|
});
|
|
114
107
|
it('throws if sha is invalid', async () => {
|
|
@@ -118,7 +111,6 @@ describe('fetchCommitBySha', () => {
|
|
|
118
111
|
accessToken: devAccessToken,
|
|
119
112
|
sha: 'myCommitSha',
|
|
120
113
|
sourceBranch: 'main',
|
|
121
|
-
historicalBranchLabelMappings: [],
|
|
122
114
|
})).rejects.toThrowError('No commit found on branch "main" with sha "myCommitSha"');
|
|
123
115
|
});
|
|
124
116
|
});
|
|
@@ -6,7 +6,6 @@ export declare function fetchCommitsByAuthor(options: {
|
|
|
6
6
|
branchLabelMapping?: ValidConfigOptions['branchLabelMapping'];
|
|
7
7
|
commitPaths?: string[];
|
|
8
8
|
githubApiBaseUrlV4?: string;
|
|
9
|
-
historicalBranchLabelMappings: ValidConfigOptions['historicalBranchLabelMappings'];
|
|
10
9
|
maxNumber?: number;
|
|
11
10
|
repoName: string;
|
|
12
11
|
repoOwner: string;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.fetchCommitsByAuthor = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
4
8
|
const lodash_1 = require("lodash");
|
|
5
9
|
const filterEmpty_1 = require("../../../../utils/filterEmpty");
|
|
6
10
|
const HandledError_1 = require("../../../HandledError");
|
|
@@ -9,7 +13,7 @@ const apiRequestV4_1 = require("../apiRequestV4");
|
|
|
9
13
|
const fetchAuthorId_1 = require("../fetchAuthorId");
|
|
10
14
|
function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
11
15
|
const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', maxNumber = 10, repoName, repoOwner, sourceBranch, dateSince, dateUntil, } = options;
|
|
12
|
-
const query =
|
|
16
|
+
const query = (0, graphql_tag_1.default) `
|
|
13
17
|
query CommitsByAuthor(
|
|
14
18
|
$repoOwner: String!
|
|
15
19
|
$repoName: String!
|
|
@@ -43,7 +47,7 @@ function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
${parseSourceCommit_1.sourceCommitWithTargetPullRequestFragment
|
|
50
|
+
${parseSourceCommit_1.sourceCommitWithTargetPullRequestFragment}
|
|
47
51
|
`;
|
|
48
52
|
const variables = {
|
|
49
53
|
repoOwner,
|
|
@@ -18,11 +18,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const
|
|
22
|
+
const graphql_1 = require("graphql");
|
|
26
23
|
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
27
24
|
const apiRequestV4Module = __importStar(require("../apiRequestV4"));
|
|
28
25
|
const fetchCommitsByAuthor_1 = require("./fetchCommitsByAuthor");
|
|
@@ -39,7 +36,6 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
39
36
|
commits = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
40
37
|
accessToken: devAccessToken,
|
|
41
38
|
author: 'sqren',
|
|
42
|
-
historicalBranchLabelMappings: [],
|
|
43
39
|
maxNumber: 10,
|
|
44
40
|
repoName: 'kibana',
|
|
45
41
|
repoOwner: 'elastic',
|
|
@@ -52,10 +48,9 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
52
48
|
it('makes the right queries', () => {
|
|
53
49
|
const queries = spy.mock.calls.reduce((acc, call) => {
|
|
54
50
|
const query = call[0].query;
|
|
55
|
-
const ast = (0, graphql_tag_1.default)(query);
|
|
56
51
|
//@ts-expect-error
|
|
57
|
-
const name =
|
|
58
|
-
return { ...acc, [name]: query };
|
|
52
|
+
const name = query.definitions[0].name.value;
|
|
53
|
+
return { ...acc, [name]: (0, graphql_1.print)(query) };
|
|
59
54
|
}, {});
|
|
60
55
|
const queryNames = Object.keys(queries);
|
|
61
56
|
expect(queryNames).toEqual(['AuthorId', 'CommitsByAuthor']);
|
|
@@ -71,7 +66,6 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
71
66
|
const getOptions = () => ({
|
|
72
67
|
accessToken: devAccessToken,
|
|
73
68
|
author: 'sqren',
|
|
74
|
-
historicalBranchLabelMappings: [],
|
|
75
69
|
maxNumber: 10,
|
|
76
70
|
repoName: 'repo-with-different-commit-paths',
|
|
77
71
|
repoOwner: 'backport-org',
|
|
@@ -146,7 +140,6 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
146
140
|
res = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
147
141
|
accessToken: devAccessToken,
|
|
148
142
|
commitPaths: [],
|
|
149
|
-
historicalBranchLabelMappings: [],
|
|
150
143
|
maxNumber: 10,
|
|
151
144
|
repoName: 'backport-e2e',
|
|
152
145
|
repoOwner: 'backport-org',
|
|
@@ -192,9 +185,11 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
192
185
|
},
|
|
193
186
|
]);
|
|
194
187
|
});
|
|
195
|
-
it('returns
|
|
188
|
+
it('returns missing pull requests', async () => {
|
|
196
189
|
const commitWithoutPRs = res.find((commit) => commit.sourcePullRequest?.number === 8);
|
|
197
|
-
expect(commitWithoutPRs?.expectedTargetPullRequests).toEqual([
|
|
190
|
+
expect(commitWithoutPRs?.expectedTargetPullRequests).toEqual([
|
|
191
|
+
{ branch: '7.x', state: 'MISSING' },
|
|
192
|
+
]);
|
|
198
193
|
});
|
|
199
194
|
});
|
|
200
195
|
});
|