backport 7.1.0 → 7.2.0-beta.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/dist/entrypoint.cli.js +0 -0
- 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 +1 -0
- package/dist/options/cliArgs.js +4 -0
- package/dist/options/config/config.d.ts +1 -1
- package/dist/options/config/readConfigFile.d.ts +1 -1
- package/dist/options/options.d.ts +2 -1
- package/dist/runSequentially.js +1 -0
- package/dist/runSequentially.test.js +55 -29
- package/dist/services/git.d.ts +3 -3
- package/dist/services/git.integration.test.js +66 -13
- package/dist/services/git.js +47 -5
- package/dist/services/git.test.js +15 -1
- package/dist/services/github/v3/createStatusComment.js +1 -1
- package/dist/services/github/v4/apiRequestV4.d.ts +4 -3
- package/dist/services/github/v4/apiRequestV4.js +15 -14
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +19 -12
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +19 -12
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +15 -9
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +15 -8
- package/dist/services/github/v4/fetchRemoteProjectConfig.js +1 -1
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -1
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +2 -15
- package/dist/services/github/v4/getOptionsFromGithub/query.js +1 -1
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +2 -5
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +6 -6
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +5 -5
- package/dist/services/remoteConfig.d.ts +2 -0
- package/dist/services/remoteConfig.js +15 -2
- 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.js +19 -18
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +2 -2
- package/dist/services/sourceCommit/parseSourceCommit.js +9 -15
- 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/ui/cherrypickAndCreateTargetPullRequest.js +12 -18
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +6 -2
- package/dist/ui/getCommits.js +6 -4
- package/dist/ui/maybeSetupRepo.js +13 -16
- package/dist/ui/maybeSetupRepo.test.js +50 -16
- package/dist/ui/ora.d.ts +1 -1
- package/dist/ui/ora.js +2 -2
- 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
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.fetchCommitBySha = void 0;
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
8
|
const HandledError_1 = require("../../../HandledError");
|
|
9
|
+
const remoteConfig_1 = require("../../../remoteConfig");
|
|
9
10
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
10
11
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
11
12
|
async function fetchCommitBySha(options) {
|
|
@@ -14,23 +15,29 @@ async function fetchCommitBySha(options) {
|
|
|
14
15
|
query CommitsBySha($repoOwner: String!, $repoName: String!, $sha: String!) {
|
|
15
16
|
repository(owner: $repoOwner, name: $repoName) {
|
|
16
17
|
object(expression: $sha) {
|
|
17
|
-
...
|
|
18
|
+
...SourceCommitWithTargetPullRequestFragment
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
${parseSourceCommit_1.
|
|
23
|
+
${parseSourceCommit_1.SourceCommitWithTargetPullRequestFragment}
|
|
23
24
|
`;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
}
|
|
34
41
|
const sourceCommit = res.repository.object;
|
|
35
42
|
if (!sourceCommit) {
|
|
36
43
|
throw new HandledError_1.HandledError(`No commit found on branch "${sourceBranch}" with sha "${sha}"`);
|
|
@@ -8,10 +8,11 @@ const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
9
|
const filterEmpty_1 = require("../../../../utils/filterEmpty");
|
|
10
10
|
const HandledError_1 = require("../../../HandledError");
|
|
11
|
+
const remoteConfig_1 = require("../../../remoteConfig");
|
|
11
12
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
12
13
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
13
14
|
const fetchAuthorId_1 = require("../fetchAuthorId");
|
|
14
|
-
function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
15
|
+
async function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
15
16
|
const { accessToken, githubApiBaseUrlV4 = 'https://api.github.com/graphql', maxNumber = 10, repoName, repoOwner, sourceBranch, dateSince, dateUntil, } = options;
|
|
16
17
|
const query = (0, graphql_tag_1.default) `
|
|
17
18
|
query CommitsByAuthor(
|
|
@@ -37,7 +38,7 @@ function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
|
37
38
|
) {
|
|
38
39
|
edges {
|
|
39
40
|
node {
|
|
40
|
-
...
|
|
41
|
+
...SourceCommitWithTargetPullRequestFragment
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
}
|
|
@@ -47,7 +48,7 @@ function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
${parseSourceCommit_1.
|
|
51
|
+
${parseSourceCommit_1.SourceCommitWithTargetPullRequestFragment}
|
|
51
52
|
`;
|
|
52
53
|
const variables = {
|
|
53
54
|
repoOwner,
|
|
@@ -59,12 +60,17 @@ function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
|
59
60
|
dateSince,
|
|
60
61
|
dateUntil,
|
|
61
62
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
+
}
|
|
68
74
|
}
|
|
69
75
|
async function fetchCommitsByAuthor(options) {
|
|
70
76
|
const { sourceBranch, commitPaths = [] } = options;
|
|
@@ -7,6 +7,7 @@ exports.fetchPullRequestBySearchQuery = void 0;
|
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
9
|
const HandledError_1 = require("../../../HandledError");
|
|
10
|
+
const remoteConfig_1 = require("../../../remoteConfig");
|
|
10
11
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
11
12
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
12
13
|
async function fetchPullRequestBySearchQuery(options) {
|
|
@@ -17,14 +18,14 @@ async function fetchPullRequestBySearchQuery(options) {
|
|
|
17
18
|
nodes {
|
|
18
19
|
... on PullRequest {
|
|
19
20
|
mergeCommit {
|
|
20
|
-
...
|
|
21
|
+
...SourceCommitWithTargetPullRequestFragment
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
${parseSourceCommit_1.
|
|
28
|
+
${parseSourceCommit_1.SourceCommitWithTargetPullRequestFragment}
|
|
28
29
|
`;
|
|
29
30
|
const authorFilter = author ? ` author:${author}` : '';
|
|
30
31
|
const searchQuery = `type:pr is:merged sort:updated-desc repo:${repoOwner}/${repoName}${authorFilter} ${prFilter} base:${sourceBranch}`;
|
|
@@ -32,12 +33,18 @@ async function fetchPullRequestBySearchQuery(options) {
|
|
|
32
33
|
query: searchQuery,
|
|
33
34
|
maxNumber: maxNumber,
|
|
34
35
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
+
}
|
|
41
48
|
const commits = res.search.nodes.map((pullRequestNode) => {
|
|
42
49
|
const sourceCommit = pullRequestNode.mergeCommit;
|
|
43
50
|
return (0, parseSourceCommit_1.parseSourceCommit)({ options, sourceCommit });
|
|
@@ -47,7 +47,7 @@ export declare function getOptionsFromGithub(options: {
|
|
|
47
47
|
repoOwner?: string | undefined;
|
|
48
48
|
resetAuthor?: boolean | undefined;
|
|
49
49
|
reviewers?: string[] | undefined;
|
|
50
|
-
sha?: string | undefined;
|
|
50
|
+
sha?: string | string[] | undefined;
|
|
51
51
|
skipRemoteConfig?: boolean | undefined;
|
|
52
52
|
sourceBranch: string;
|
|
53
53
|
sourcePRLabels?: string[] | undefined;
|
|
@@ -23,9 +23,8 @@ async function getOptionsFromGithub(options) {
|
|
|
23
23
|
if (!(e instanceof apiRequestV4_1.GithubV4Exception)) {
|
|
24
24
|
throw e;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
(0,
|
|
28
|
-
res = swallowErrorIfConfigFileIsMissing(error);
|
|
26
|
+
(0, throwOnInvalidAccessToken_1.throwOnInvalidAccessToken)({ error: e, repoName, repoOwner });
|
|
27
|
+
res = (0, remoteConfig_1.swallowMissingConfigFileException)(e);
|
|
29
28
|
}
|
|
30
29
|
// it is not possible to have a branch named "backport"
|
|
31
30
|
if (res.repository.illegalBackportBranch) {
|
|
@@ -72,15 +71,3 @@ async function getRemoteConfigFileOptions(res, cwd, skipRemoteConfig) {
|
|
|
72
71
|
}
|
|
73
72
|
return (0, remoteConfig_1.parseRemoteConfig)(remoteConfig);
|
|
74
73
|
}
|
|
75
|
-
function swallowErrorIfConfigFileIsMissing(error) {
|
|
76
|
-
const { data, errors } = error.axiosResponse.data;
|
|
77
|
-
const missingConfigError = errors?.some((error) => {
|
|
78
|
-
return error.path.includes('remoteConfig') && error.type === 'NOT_FOUND';
|
|
79
|
-
});
|
|
80
|
-
// swallow error if it's just the config file that's missing
|
|
81
|
-
if (missingConfigError && data != null) {
|
|
82
|
-
return data;
|
|
83
|
-
}
|
|
84
|
-
// Throw unexpected error
|
|
85
|
-
throw error;
|
|
86
|
-
}
|
|
@@ -9,7 +9,6 @@ exports.commitsByAuthorMock = {
|
|
|
9
9
|
edges: [
|
|
10
10
|
{
|
|
11
11
|
node: {
|
|
12
|
-
remoteConfigHistory: { edges: [] },
|
|
13
12
|
repository: {
|
|
14
13
|
name: 'kibana',
|
|
15
14
|
owner: { login: 'elastic' },
|
|
@@ -24,7 +23,6 @@ exports.commitsByAuthorMock = {
|
|
|
24
23
|
},
|
|
25
24
|
{
|
|
26
25
|
node: {
|
|
27
|
-
remoteConfigHistory: { edges: [] },
|
|
28
26
|
repository: {
|
|
29
27
|
name: 'kibana',
|
|
30
28
|
owner: { login: 'elastic' },
|
|
@@ -43,6 +41,7 @@ exports.commitsByAuthorMock = {
|
|
|
43
41
|
},
|
|
44
42
|
number: 85,
|
|
45
43
|
mergeCommit: {
|
|
44
|
+
remoteConfigHistory: { edges: [] },
|
|
46
45
|
sha: 'f3b618b9421fdecdb36862f907afbdd6344b361d',
|
|
47
46
|
message: 'Add witch (#85)',
|
|
48
47
|
},
|
|
@@ -57,7 +56,6 @@ exports.commitsByAuthorMock = {
|
|
|
57
56
|
},
|
|
58
57
|
{
|
|
59
58
|
node: {
|
|
60
|
-
remoteConfigHistory: { edges: [] },
|
|
61
59
|
repository: {
|
|
62
60
|
name: 'kibana',
|
|
63
61
|
owner: { login: 'elastic' },
|
|
@@ -76,6 +74,7 @@ exports.commitsByAuthorMock = {
|
|
|
76
74
|
baseRefName: 'master',
|
|
77
75
|
number: 80,
|
|
78
76
|
mergeCommit: {
|
|
77
|
+
remoteConfigHistory: { edges: [] },
|
|
79
78
|
sha: '79cf18453ec32a4677009dcbab1c9c8c73fc14fe',
|
|
80
79
|
message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
|
|
81
80
|
},
|
|
@@ -123,7 +122,6 @@ exports.commitsByAuthorMock = {
|
|
|
123
122
|
},
|
|
124
123
|
{
|
|
125
124
|
node: {
|
|
126
|
-
remoteConfigHistory: { edges: [] },
|
|
127
125
|
repository: {
|
|
128
126
|
name: 'kibana',
|
|
129
127
|
owner: { login: 'elastic' },
|
|
@@ -138,7 +136,6 @@ exports.commitsByAuthorMock = {
|
|
|
138
136
|
},
|
|
139
137
|
{
|
|
140
138
|
node: {
|
|
141
|
-
remoteConfigHistory: { edges: [] },
|
|
142
139
|
repository: {
|
|
143
140
|
name: 'kibana',
|
|
144
141
|
owner: { login: 'elastic' },
|
|
@@ -12,13 +12,13 @@ function throwOnInvalidAccessToken({ error, repoOwner, repoName, }) {
|
|
|
12
12
|
return matches[1];
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
const statusCode = error.
|
|
15
|
+
const statusCode = error.githubResponse.status;
|
|
16
16
|
switch (statusCode) {
|
|
17
17
|
case 200: {
|
|
18
|
-
const repoNotFound = error.
|
|
19
|
-
const grantedScopes = error.
|
|
20
|
-
const requiredScopes = error.
|
|
21
|
-
const ssoHeader = (0, maybe_1.maybe)(error.
|
|
18
|
+
const repoNotFound = error.githubResponse.data.errors?.some((error) => error.type === 'NOT_FOUND' && error.path.join('.') === 'repository');
|
|
19
|
+
const grantedScopes = error.githubResponse.headers['x-oauth-scopes'] || '';
|
|
20
|
+
const requiredScopes = error.githubResponse.headers['x-accepted-oauth-scopes'] || '';
|
|
21
|
+
const ssoHeader = (0, maybe_1.maybe)(error.githubResponse.headers['x-github-sso']);
|
|
22
22
|
if (repoNotFound) {
|
|
23
23
|
const hasRequiredScopes = (0, lodash_1.isEmpty)((0, lodash_1.difference)(requiredScopes.split(','), grantedScopes.split(',')));
|
|
24
24
|
// user does not have permission to the repo
|
|
@@ -28,7 +28,7 @@ function throwOnInvalidAccessToken({ error, repoOwner, repoName, }) {
|
|
|
28
28
|
// repo does not exist
|
|
29
29
|
throw new HandledError_1.HandledError(`The repository "${repoOwner}/${repoName}" doesn't exist`);
|
|
30
30
|
}
|
|
31
|
-
const repoAccessForbidden = error.
|
|
31
|
+
const repoAccessForbidden = error.githubResponse.data.errors?.some((error) => error.type === 'FORBIDDEN');
|
|
32
32
|
const ssoAuthUrl = getSSOAuthUrl(ssoHeader);
|
|
33
33
|
// user does not have permissions
|
|
34
34
|
if (repoAccessForbidden && ssoAuthUrl) {
|
|
@@ -5,7 +5,7 @@ describe('throwOnInvalidAccessToken', () => {
|
|
|
5
5
|
describe('when status code is', () => {
|
|
6
6
|
it('should handle invalid access token', () => {
|
|
7
7
|
const error = {
|
|
8
|
-
|
|
8
|
+
githubResponse: {
|
|
9
9
|
status: 401,
|
|
10
10
|
headers: {},
|
|
11
11
|
},
|
|
@@ -18,7 +18,7 @@ describe('throwOnInvalidAccessToken', () => {
|
|
|
18
18
|
});
|
|
19
19
|
it('should handle SSO error', () => {
|
|
20
20
|
const error = {
|
|
21
|
-
|
|
21
|
+
githubResponse: {
|
|
22
22
|
status: 200,
|
|
23
23
|
headers: { 'x-github-sso': 'required; url=https://ssourl.com' },
|
|
24
24
|
data: {
|
|
@@ -34,7 +34,7 @@ describe('throwOnInvalidAccessToken', () => {
|
|
|
34
34
|
});
|
|
35
35
|
it('should handle non-existing repo', () => {
|
|
36
36
|
const error = {
|
|
37
|
-
|
|
37
|
+
githubResponse: {
|
|
38
38
|
status: 200,
|
|
39
39
|
headers: {
|
|
40
40
|
'x-oauth-scopes': 'a,b,c',
|
|
@@ -53,7 +53,7 @@ describe('throwOnInvalidAccessToken', () => {
|
|
|
53
53
|
});
|
|
54
54
|
it('should handle insufficient permissions (oauth scopes)', () => {
|
|
55
55
|
const error = {
|
|
56
|
-
|
|
56
|
+
githubResponse: {
|
|
57
57
|
status: 200,
|
|
58
58
|
headers: {
|
|
59
59
|
'x-oauth-scopes': 'a,b',
|
|
@@ -72,7 +72,7 @@ describe('throwOnInvalidAccessToken', () => {
|
|
|
72
72
|
});
|
|
73
73
|
it('should not handle unknown cases', () => {
|
|
74
74
|
const error = {
|
|
75
|
-
|
|
75
|
+
githubResponse: {
|
|
76
76
|
status: 500,
|
|
77
77
|
headers: {},
|
|
78
78
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConfigFileOptions } from '../entrypoint.module';
|
|
2
|
+
import { GithubV4Exception } from './github/v4/apiRequestV4';
|
|
2
3
|
export declare const RemoteConfigHistoryFragment: import("graphql").DocumentNode;
|
|
3
4
|
export interface RemoteConfig {
|
|
4
5
|
committedDate: string;
|
|
@@ -16,3 +17,4 @@ export interface RemoteConfigHistory {
|
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
export declare function parseRemoteConfig(remoteConfig: RemoteConfig): ConfigFileOptions | undefined;
|
|
20
|
+
export declare function swallowMissingConfigFileException<T>(error: GithubV4Exception<T>): T;
|
|
@@ -3,12 +3,12 @@ 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.parseRemoteConfig = exports.RemoteConfigHistoryFragment = void 0;
|
|
6
|
+
exports.swallowMissingConfigFileException = exports.parseRemoteConfig = exports.RemoteConfigHistoryFragment = void 0;
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
8
|
const readConfigFile_1 = require("../options/config/readConfigFile");
|
|
9
9
|
const logger_1 = require("./logger");
|
|
10
10
|
exports.RemoteConfigHistoryFragment = (0, graphql_tag_1.default) `
|
|
11
|
-
fragment
|
|
11
|
+
fragment RemoteConfigHistoryFragment on Commit {
|
|
12
12
|
remoteConfigHistory: history(first: 1, path: ".backportrc.json") {
|
|
13
13
|
edges {
|
|
14
14
|
remoteConfig: node {
|
|
@@ -37,3 +37,16 @@ function parseRemoteConfig(remoteConfig) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
exports.parseRemoteConfig = parseRemoteConfig;
|
|
40
|
+
function swallowMissingConfigFileException(error) {
|
|
41
|
+
const { data, errors } = error.githubResponse.data;
|
|
42
|
+
const missingConfigError = errors?.some((error) => {
|
|
43
|
+
return error.path.includes('remoteConfig') && error.type === 'NOT_FOUND';
|
|
44
|
+
});
|
|
45
|
+
// swallow error if it's just the config file that's missing
|
|
46
|
+
if (missingConfigError && data != null) {
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
// Throw unexpected error
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
exports.swallowMissingConfigFileException = swallowMissingConfigFileException;
|
|
@@ -10,4 +10,7 @@ export declare type ExpectedTargetPullRequest = {
|
|
|
10
10
|
message: string;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export declare function getExpectedTargetPullRequests(sourceCommit
|
|
13
|
+
export declare function getExpectedTargetPullRequests({ sourceCommit, latestBranchLabelMapping, }: {
|
|
14
|
+
sourceCommit: SourceCommitWithTargetPullRequest;
|
|
15
|
+
latestBranchLabelMapping: ValidConfigOptions['branchLabelMapping'];
|
|
16
|
+
}): ExpectedTargetPullRequest[];
|
|
@@ -4,8 +4,12 @@ exports.getExpectedTargetPullRequests = void 0;
|
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const filterEmpty_1 = require("../../utils/filterEmpty");
|
|
6
6
|
const commitFormatters_1 = require("../github/commitFormatters");
|
|
7
|
-
|
|
7
|
+
const remoteConfig_1 = require("../remoteConfig");
|
|
8
|
+
function getExpectedTargetPullRequests({ sourceCommit, latestBranchLabelMapping, }) {
|
|
8
9
|
const sourcePullRequest = sourceCommit.associatedPullRequests.edges?.[0]?.node;
|
|
10
|
+
const remoteConfig = sourcePullRequest?.mergeCommit.remoteConfigHistory.edges?.[0]?.remoteConfig;
|
|
11
|
+
const branchLabelMapping = (remoteConfig && (0, remoteConfig_1.parseRemoteConfig)(remoteConfig)?.branchLabelMapping) ??
|
|
12
|
+
latestBranchLabelMapping;
|
|
9
13
|
// if there is no source pull request the commit was pushed directly to the source branch
|
|
10
14
|
// in that case there will be no labels, and thus not possible to deduce the expected target branches
|
|
11
15
|
if (!sourcePullRequest) {
|