backport 7.0.1 → 7.2.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backportRun.d.ts +1 -0
- package/dist/backportRun.js +3 -2
- package/dist/entrypoint.cli.js +12 -1
- package/dist/entrypoint.module.d.ts +4 -3
- package/dist/entrypoint.module.js +2 -7
- package/dist/options/ConfigOptions.d.ts +1 -1
- package/dist/options/cliArgs.d.ts +2 -1
- package/dist/options/cliArgs.js +4 -0
- package/dist/options/config/config.d.ts +1 -1
- package/dist/options/config/readConfigFile.d.ts +2 -2
- package/dist/options/options.d.ts +3 -6
- package/dist/options/options.test.js +26 -28
- package/dist/runSequentially.js +1 -0
- package/dist/runSequentially.test.js +55 -30
- package/dist/services/HandledError.js +3 -1
- package/dist/services/git.d.ts +3 -3
- package/dist/services/git.integration.test.js +66 -13
- package/dist/services/git.js +52 -13
- package/dist/services/git.test.js +15 -1
- 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/createStatusComment.js +1 -1
- package/dist/services/github/v4/FetchPullRequestId.js +5 -1
- package/dist/services/github/v4/apiRequestV4.d.ts +7 -4
- package/dist/services/github/v4/apiRequestV4.js +22 -21
- 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 +24 -13
- 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 +24 -13
- 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 +20 -10
- 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 +20 -9
- 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 -5
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +12 -66
- 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 +2 -0
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +6 -6
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +5 -5
- package/dist/services/logger.d.ts +5 -5
- package/dist/services/logger.js +24 -23
- package/dist/services/remoteConfig.d.ts +20 -0
- package/dist/services/remoteConfig.js +52 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +4 -1
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +5 -1
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +73 -39
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +4 -0
- package/dist/services/sourceCommit/getMockSourceCommit.js +21 -6
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +3 -4
- package/dist/services/sourceCommit/parseSourceCommit.js +73 -77
- package/dist/services/sourceCommit/parseSourceCommit.test.js +7 -17
- package/dist/{entrypoint.cli.e2e.private.test.d.ts → test/e2e/cli.e2e.private.test.d.ts} +0 -0
- package/dist/{entrypoint.cli.e2e.private.test.js → test/e2e/cli.e2e.private.test.js} +153 -39
- package/dist/{services/github/v3/index.d.ts → test/e2e/module.e2e.private.test.d.ts} +0 -0
- package/dist/test/e2e/module.e2e.private.test.js +363 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.js +0 -2
- package/dist/test/nockHelpers.js +6 -2
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +16 -22
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +6 -2
- package/dist/ui/getCommits.js +8 -6
- package/dist/ui/maybeSetupRepo.js +13 -16
- package/dist/ui/maybeSetupRepo.test.js +50 -16
- 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 +10 -10
- package/yarn.lock +121 -114
- package/dist/services/github/v3/index.js +0 -61
- package/dist/test/backport-e2e.mutation.test.d.ts +0 -1
- package/dist/test/backport-e2e.mutation.test.js +0 -347
|
@@ -1,12 +1,17 @@
|
|
|
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");
|
|
9
|
+
const remoteConfig_1 = require("../../../remoteConfig");
|
|
5
10
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
6
11
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
7
12
|
async function fetchCommitByPullNumber(options) {
|
|
8
13
|
const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', pullNumber, repoName, repoOwner, } = options;
|
|
9
|
-
const query =
|
|
14
|
+
const query = (0, graphql_tag_1.default) `
|
|
10
15
|
query CommitByPullNumber(
|
|
11
16
|
$repoOwner: String!
|
|
12
17
|
$repoName: String!
|
|
@@ -15,24 +20,30 @@ async function fetchCommitByPullNumber(options) {
|
|
|
15
20
|
repository(owner: $repoOwner, name: $repoName) {
|
|
16
21
|
pullRequest(number: $pullNumber) {
|
|
17
22
|
mergeCommit {
|
|
18
|
-
...
|
|
23
|
+
...SourceCommitWithTargetPullRequestFragment
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
27
|
}
|
|
23
28
|
|
|
24
|
-
${parseSourceCommit_1.
|
|
29
|
+
${parseSourceCommit_1.SourceCommitWithTargetPullRequestFragment}
|
|
25
30
|
`;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
let res;
|
|
32
|
+
try {
|
|
33
|
+
res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
34
|
+
githubApiBaseUrlV4,
|
|
35
|
+
accessToken,
|
|
36
|
+
query,
|
|
37
|
+
variables: {
|
|
38
|
+
repoOwner,
|
|
39
|
+
repoName,
|
|
40
|
+
pullNumber,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
res = (0, remoteConfig_1.swallowMissingConfigFileException)(e);
|
|
46
|
+
}
|
|
36
47
|
const pullRequestNode = res.repository.pullRequest;
|
|
37
48
|
if (!pullRequestNode) {
|
|
38
49
|
throw new HandledError_1.HandledError(`The PR #${pullNumber} does not exist`);
|
|
@@ -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,32 +1,43 @@
|
|
|
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");
|
|
9
|
+
const remoteConfig_1 = require("../../../remoteConfig");
|
|
5
10
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
6
11
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
7
12
|
async function fetchCommitBySha(options) {
|
|
8
13
|
const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', repoName, repoOwner, sha, sourceBranch, } = options;
|
|
9
|
-
const query =
|
|
14
|
+
const query = (0, graphql_tag_1.default) `
|
|
10
15
|
query CommitsBySha($repoOwner: String!, $repoName: String!, $sha: String!) {
|
|
11
16
|
repository(owner: $repoOwner, name: $repoName) {
|
|
12
17
|
object(expression: $sha) {
|
|
13
|
-
...
|
|
18
|
+
...SourceCommitWithTargetPullRequestFragment
|
|
14
19
|
}
|
|
15
20
|
}
|
|
16
21
|
}
|
|
17
22
|
|
|
18
|
-
${parseSourceCommit_1.
|
|
23
|
+
${parseSourceCommit_1.SourceCommitWithTargetPullRequestFragment}
|
|
19
24
|
`;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
let res;
|
|
26
|
+
try {
|
|
27
|
+
res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
28
|
+
githubApiBaseUrlV4,
|
|
29
|
+
accessToken,
|
|
30
|
+
query,
|
|
31
|
+
variables: {
|
|
32
|
+
repoOwner,
|
|
33
|
+
repoName,
|
|
34
|
+
sha,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
res = (0, remoteConfig_1.swallowMissingConfigFileException)(e);
|
|
40
|
+
}
|
|
30
41
|
const sourceCommit = res.repository.object;
|
|
31
42
|
if (!sourceCommit) {
|
|
32
43
|
throw new HandledError_1.HandledError(`No commit found on branch "${sourceBranch}" with sha "${sha}"`);
|
|
@@ -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,15 +1,20 @@
|
|
|
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");
|
|
11
|
+
const remoteConfig_1 = require("../../../remoteConfig");
|
|
7
12
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
8
13
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
9
14
|
const fetchAuthorId_1 = require("../fetchAuthorId");
|
|
10
|
-
function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
15
|
+
async function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
11
16
|
const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', maxNumber = 10, repoName, repoOwner, sourceBranch, dateSince, dateUntil, } = options;
|
|
12
|
-
const query =
|
|
17
|
+
const query = (0, graphql_tag_1.default) `
|
|
13
18
|
query CommitsByAuthor(
|
|
14
19
|
$repoOwner: String!
|
|
15
20
|
$repoName: String!
|
|
@@ -33,7 +38,7 @@ function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
|
33
38
|
) {
|
|
34
39
|
edges {
|
|
35
40
|
node {
|
|
36
|
-
...
|
|
41
|
+
...SourceCommitWithTargetPullRequestFragment
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
44
|
}
|
|
@@ -43,7 +48,7 @@ function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
${parseSourceCommit_1.
|
|
51
|
+
${parseSourceCommit_1.SourceCommitWithTargetPullRequestFragment}
|
|
47
52
|
`;
|
|
48
53
|
const variables = {
|
|
49
54
|
repoOwner,
|
|
@@ -55,12 +60,17 @@ function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
|
55
60
|
dateSince,
|
|
56
61
|
dateUntil,
|
|
57
62
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
try {
|
|
64
|
+
return await (0, apiRequestV4_1.apiRequestV4)({
|
|
65
|
+
githubApiBaseUrlV4,
|
|
66
|
+
accessToken,
|
|
67
|
+
query,
|
|
68
|
+
variables,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
catch (e) {
|
|
72
|
+
return (0, remoteConfig_1.swallowMissingConfigFileException)(e);
|
|
73
|
+
}
|
|
64
74
|
}
|
|
65
75
|
async function fetchCommitsByAuthor(options) {
|
|
66
76
|
const { sourceBranch, commitPaths = [] } = options;
|
|
@@ -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
|
});
|
|
@@ -1,26 +1,31 @@
|
|
|
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.fetchPullRequestBySearchQuery = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
4
8
|
const lodash_1 = require("lodash");
|
|
5
9
|
const HandledError_1 = require("../../../HandledError");
|
|
10
|
+
const remoteConfig_1 = require("../../../remoteConfig");
|
|
6
11
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
7
12
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
8
13
|
async function fetchPullRequestBySearchQuery(options) {
|
|
9
14
|
const { accessToken, githubApiBaseUrlV4, maxNumber = 10, prFilter, repoName, repoOwner, sourceBranch, author, } = options;
|
|
10
|
-
const query =
|
|
15
|
+
const query = (0, graphql_tag_1.default) `
|
|
11
16
|
query PullRequestBySearchQuery($query: String!, $maxNumber: Int!) {
|
|
12
17
|
search(query: $query, type: ISSUE, first: $maxNumber) {
|
|
13
18
|
nodes {
|
|
14
19
|
... on PullRequest {
|
|
15
20
|
mergeCommit {
|
|
16
|
-
...
|
|
21
|
+
...SourceCommitWithTargetPullRequestFragment
|
|
17
22
|
}
|
|
18
23
|
}
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
${parseSourceCommit_1.
|
|
28
|
+
${parseSourceCommit_1.SourceCommitWithTargetPullRequestFragment}
|
|
24
29
|
`;
|
|
25
30
|
const authorFilter = author ? ` author:${author}` : '';
|
|
26
31
|
const searchQuery = `type:pr is:merged sort:updated-desc repo:${repoOwner}/${repoName}${authorFilter} ${prFilter} base:${sourceBranch}`;
|
|
@@ -28,12 +33,18 @@ async function fetchPullRequestBySearchQuery(options) {
|
|
|
28
33
|
query: searchQuery,
|
|
29
34
|
maxNumber: maxNumber,
|
|
30
35
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
let res;
|
|
37
|
+
try {
|
|
38
|
+
res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
39
|
+
githubApiBaseUrlV4,
|
|
40
|
+
accessToken,
|
|
41
|
+
query,
|
|
42
|
+
variables,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
res = (0, remoteConfig_1.swallowMissingConfigFileException)(e);
|
|
47
|
+
}
|
|
37
48
|
const commits = res.search.nodes.map((pullRequestNode) => {
|
|
38
49
|
const sourceCommit = pullRequestNode.mergeCommit;
|
|
39
50
|
return (0, parseSourceCommit_1.parseSourceCommit)({ options, sourceCommit });
|
|
@@ -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.fetchExistingPullRequest = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
4
8
|
const apiRequestV4_1 = require("./apiRequestV4");
|
|
5
9
|
async function fetchExistingPullRequest({ options, prPayload, }) {
|
|
6
10
|
const { githubApiBaseUrlV4, accessToken } = options;
|
|
7
|
-
const query =
|
|
11
|
+
const query = (0, graphql_tag_1.default) `
|
|
8
12
|
query ExistingPullRequest(
|
|
9
13
|
$repoOwner: String!
|
|
10
14
|
$repoName: String!
|
|
@@ -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.fetchPullRequestAutoMergeMethod = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
4
8
|
const apiRequestV4_1 = require("./apiRequestV4");
|
|
5
9
|
async function fetchPullRequestAutoMergeMethod(options, pullNumber) {
|
|
6
10
|
const { accessToken, githubApiBaseUrlV4, repoName, repoOwner } = options;
|
|
7
|
-
const query =
|
|
11
|
+
const query = (0, graphql_tag_1.default) `
|
|
8
12
|
query PullRequestAutoMergeMethod(
|
|
9
13
|
$repoOwner: String!
|
|
10
14
|
$repoName: String!
|
|
@@ -1,11 +1,15 @@
|
|
|
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.fetchRemoteProjectConfig = void 0;
|
|
4
|
-
const
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
+
const remoteConfig_1 = require("../../remoteConfig");
|
|
5
9
|
const apiRequestV4_1 = require("./apiRequestV4");
|
|
6
10
|
async function fetchRemoteProjectConfig(options) {
|
|
7
11
|
const { accessToken, githubApiBaseUrlV4, repoName, repoOwner, sourceBranch } = options;
|
|
8
|
-
const query =
|
|
12
|
+
const query = (0, graphql_tag_1.default) `
|
|
9
13
|
query ProjectConfig(
|
|
10
14
|
$repoOwner: String!
|
|
11
15
|
$repoName: String!
|
|
@@ -14,27 +18,13 @@ async function fetchRemoteProjectConfig(options) {
|
|
|
14
18
|
repository(owner: $repoOwner, name: $repoName) {
|
|
15
19
|
ref(qualifiedName: $sourceBranch) {
|
|
16
20
|
target {
|
|
17
|
-
...
|
|
18
|
-
history(first: 1, path: ".backportrc.json") {
|
|
19
|
-
edges {
|
|
20
|
-
remoteConfig: node {
|
|
21
|
-
file(path: ".backportrc.json") {
|
|
22
|
-
... on TreeEntry {
|
|
23
|
-
object {
|
|
24
|
-
... on Blob {
|
|
25
|
-
text
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
21
|
+
...RemoteConfigHistoryFragment
|
|
34
22
|
}
|
|
35
23
|
}
|
|
36
24
|
}
|
|
37
25
|
}
|
|
26
|
+
|
|
27
|
+
${remoteConfig_1.RemoteConfigHistoryFragment}
|
|
38
28
|
`;
|
|
39
29
|
try {
|
|
40
30
|
const res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
@@ -47,7 +37,10 @@ async function fetchRemoteProjectConfig(options) {
|
|
|
47
37
|
sourceBranch,
|
|
48
38
|
},
|
|
49
39
|
});
|
|
50
|
-
|
|
40
|
+
const remoteConfig = res.repository.ref.target.remoteConfigHistory.edges?.[0].remoteConfig;
|
|
41
|
+
if (remoteConfig) {
|
|
42
|
+
return (0, remoteConfig_1.parseRemoteConfig)(remoteConfig);
|
|
43
|
+
}
|
|
51
44
|
}
|
|
52
45
|
catch (e) {
|
|
53
46
|
throw new Error('Project config does not exist');
|
|
@@ -8,10 +8,6 @@ export declare function getOptionsFromGithub(options: {
|
|
|
8
8
|
skipRemoteConfig?: boolean;
|
|
9
9
|
cwd?: string;
|
|
10
10
|
}): Promise<{
|
|
11
|
-
historicalBranchLabelMappings: {
|
|
12
|
-
branchLabelMapping: Record<string, string>;
|
|
13
|
-
committedDate: string;
|
|
14
|
-
}[];
|
|
15
11
|
accessToken?: string | undefined;
|
|
16
12
|
assignees?: string[] | undefined;
|
|
17
13
|
author?: string | null | undefined;
|
|
@@ -51,7 +47,7 @@ export declare function getOptionsFromGithub(options: {
|
|
|
51
47
|
repoOwner?: string | undefined;
|
|
52
48
|
resetAuthor?: boolean | undefined;
|
|
53
49
|
reviewers?: string[] | undefined;
|
|
54
|
-
sha?: string | undefined;
|
|
50
|
+
sha?: string | string[] | undefined;
|
|
55
51
|
skipRemoteConfig?: boolean | undefined;
|
|
56
52
|
sourceBranch: string;
|
|
57
53
|
sourcePRLabels?: string[] | undefined;
|