backport 7.0.1-beta.2 → 7.2.0-beta.2
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/runSequentially.js +1 -0
- package/dist/services/HandledError.js +3 -1
- package/dist/services/git.d.ts +2 -0
- package/dist/services/git.js +47 -10
- 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/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/fetchCommitByPullNumber.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +24 -13
- 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/fetchCommitsByAuthor.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +20 -10
- 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/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/throwOnInvalidAccessToken.js +6 -6
- 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/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/ui/cherrypickAndCreateTargetPullRequest.js +16 -22
- package/dist/ui/getCommits.js +8 -6
- package/dist/ui/maybeSetupRepo.js +7 -14
- 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/entrypoint.cli.e2e.private.test.d.ts +0 -1
- package/dist/entrypoint.cli.e2e.private.test.js +0 -319
- package/dist/entrypoint.cli.private.test.d.ts +0 -1
- package/dist/entrypoint.cli.private.test.js +0 -46
- package/dist/options/cliArgs.test.d.ts +0 -1
- package/dist/options/cliArgs.test.js +0 -182
- package/dist/options/config/config.test.d.ts +0 -1
- package/dist/options/config/config.test.js +0 -32
- package/dist/options/config/globalConfig.test.d.ts +0 -1
- package/dist/options/config/globalConfig.test.js +0 -61
- package/dist/options/config/projectConfig.test.d.ts +0 -1
- package/dist/options/config/projectConfig.test.js +0 -109
- package/dist/options/options.test.d.ts +0 -1
- package/dist/options/options.test.js +0 -386
- package/dist/runSequentially.test.d.ts +0 -1
- package/dist/runSequentially.test.js +0 -218
- package/dist/scripts/postinstall.test.d.ts +0 -1
- package/dist/scripts/postinstall.test.js +0 -53
- package/dist/services/env.test.d.ts +0 -1
- package/dist/services/env.test.js +0 -21
- package/dist/services/git.integration.test.d.ts +0 -1
- package/dist/services/git.integration.test.js +0 -267
- package/dist/services/git.test.d.ts +0 -1
- package/dist/services/git.test.js +0 -518
- package/dist/services/github/commitFormatters.test.d.ts +0 -1
- package/dist/services/github/commitFormatters.test.js +0 -11
- package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +0 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.test.js +0 -27
- package/dist/services/github/v3/createPullRequest.test.d.ts +0 -1
- package/dist/services/github/v3/createPullRequest.test.js +0 -325
- package/dist/services/github/v3/createStatusComment.test.d.ts +0 -1
- package/dist/services/github/v3/createStatusComment.test.js +0 -386
- package/dist/services/github/v3/index.d.ts +0 -1
- package/dist/services/github/v3/index.js +0 -61
- package/dist/services/github/v4/apiRequestV4.test.d.ts +0 -1
- package/dist/services/github/v4/apiRequestV4.test.js +0 -82
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +0 -1
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
- package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchAuthorId.private.test.js +0 -28
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -96
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +0 -143
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +0 -124
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +0 -200
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -153
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +0 -102
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -47
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +0 -52
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +0 -1
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -136
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +0 -1
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +0 -71
- package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +0 -154
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +0 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +0 -87
- package/dist/services/prompt.test.d.ts +0 -1
- package/dist/services/prompt.test.js +0 -134
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +0 -1
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +0 -433
- package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit/parseSourceCommit.test.js +0 -235
- package/dist/test/ExecError.d.ts +0 -16
- package/dist/test/ExecError.js +0 -15
- package/dist/test/backport-e2e.mutation.test.d.ts +0 -1
- package/dist/test/backport-e2e.mutation.test.js +0 -347
- package/dist/test/handleUnbackportedPullRequests.private.test.d.ts +0 -1
- package/dist/test/handleUnbackportedPullRequests.private.test.js +0 -57
- package/dist/test/mockConfigFiles.d.ts +0 -5
- package/dist/test/mockConfigFiles.js +0 -21
- package/dist/test/mocks.d.ts +0 -10
- package/dist/test/mocks.js +0 -23
- package/dist/test/nockHelpers.d.ts +0 -16
- package/dist/test/nockHelpers.js +0 -32
- package/dist/test/private/getDevAccessToken.d.ts +0 -2
- package/dist/test/private/getDevAccessToken.js +0 -12
- package/dist/test/sandbox.d.ts +0 -5
- package/dist/test/sandbox.js +0 -43
- package/dist/test/setupFiles/automatic-mocks.d.ts +0 -1
- package/dist/test/setupFiles/automatic-mocks.js +0 -63
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +0 -455
- package/dist/ui/getCommitsWithoutBackports.test.d.ts +0 -1
- package/dist/ui/getCommitsWithoutBackports.test.js +0 -311
- package/dist/ui/getTargetBranches.test.d.ts +0 -1
- package/dist/ui/getTargetBranches.test.js +0 -198
- package/dist/ui/maybeSetupRepo.test.d.ts +0 -1
- package/dist/ui/maybeSetupRepo.test.js +0 -204
- package/dist/utils/excludeUndefined.test.d.ts +0 -1
- package/dist/utils/excludeUndefined.test.js +0 -24
|
@@ -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
|
|
@@ -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,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`);
|
|
@@ -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}"`);
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOptionsFromGithub = void 0;
|
|
4
|
-
const readConfigFile_1 = require("../../../../options/config/readConfigFile");
|
|
5
|
-
const filterEmpty_1 = require("../../../../utils/filterEmpty");
|
|
6
4
|
const HandledError_1 = require("../../../HandledError");
|
|
7
5
|
const git_1 = require("../../../git");
|
|
8
6
|
const logger_1 = require("../../../logger");
|
|
7
|
+
const remoteConfig_1 = require("../../../remoteConfig");
|
|
9
8
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
10
9
|
const throwOnInvalidAccessToken_1 = require("../throwOnInvalidAccessToken");
|
|
11
10
|
const query_1 = require("./query");
|
|
@@ -24,38 +23,31 @@ async function getOptionsFromGithub(options) {
|
|
|
24
23
|
if (!(e instanceof apiRequestV4_1.GithubV4Exception)) {
|
|
25
24
|
throw e;
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
(0,
|
|
29
|
-
res = swallowErrorIfConfigFileIsMissing(error);
|
|
26
|
+
(0, throwOnInvalidAccessToken_1.throwOnInvalidAccessToken)({ error: e, repoName, repoOwner });
|
|
27
|
+
res = (0, remoteConfig_1.swallowMissingConfigFileException)(e);
|
|
30
28
|
}
|
|
31
29
|
// it is not possible to have a branch named "backport"
|
|
32
30
|
if (res.repository.illegalBackportBranch) {
|
|
33
31
|
throw new HandledError_1.HandledError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
34
32
|
}
|
|
35
|
-
const
|
|
36
|
-
const latestRemoteConfig = historicalRemoteConfigs[0]?.remoteConfig;
|
|
37
|
-
const skipRemoteConfig = await getSkipRemoteConfigFile(options.cwd, options.skipRemoteConfig, latestRemoteConfig);
|
|
38
|
-
const remoteConfig = skipRemoteConfig
|
|
39
|
-
? {}
|
|
40
|
-
: parseRemoteConfig(latestRemoteConfig);
|
|
33
|
+
const remoteConfig = await getRemoteConfigFileOptions(res, options.cwd, options.skipRemoteConfig);
|
|
41
34
|
return {
|
|
42
35
|
authenticatedUsername: options.username ?? res.viewer.login,
|
|
43
36
|
sourceBranch: res.repository.defaultBranchRef.name,
|
|
44
37
|
...remoteConfig,
|
|
45
|
-
historicalBranchLabelMappings: skipRemoteConfig
|
|
46
|
-
? []
|
|
47
|
-
: getHistoricalBranchLabelMappings(historicalRemoteConfigs),
|
|
48
38
|
};
|
|
49
39
|
}
|
|
50
40
|
exports.getOptionsFromGithub = getOptionsFromGithub;
|
|
51
|
-
async function
|
|
41
|
+
async function getRemoteConfigFileOptions(res, cwd, skipRemoteConfig) {
|
|
52
42
|
if (skipRemoteConfig) {
|
|
53
43
|
logger_1.logger.info('Skipping remote config: `--skip-remote-config` specified via config file or cli');
|
|
54
|
-
return
|
|
44
|
+
return;
|
|
55
45
|
}
|
|
46
|
+
const remoteConfig = res.repository.defaultBranchRef.target.remoteConfigHistory.edges?.[0]
|
|
47
|
+
?.remoteConfig;
|
|
56
48
|
if (!remoteConfig) {
|
|
57
49
|
logger_1.logger.info("Skipping remote config: remote config doesn't exist");
|
|
58
|
-
return
|
|
50
|
+
return;
|
|
59
51
|
}
|
|
60
52
|
if (cwd) {
|
|
61
53
|
const [isLocalConfigModified, isLocalConfigUntracked, localCommitDate] = await Promise.all([
|
|
@@ -65,63 +57,17 @@ async function getSkipRemoteConfigFile(cwd, skipRemoteConfig, remoteConfig) {
|
|
|
65
57
|
]);
|
|
66
58
|
if (isLocalConfigUntracked) {
|
|
67
59
|
logger_1.logger.info('Skipping remote config: local config is new');
|
|
68
|
-
return
|
|
60
|
+
return;
|
|
69
61
|
}
|
|
70
62
|
if (isLocalConfigModified) {
|
|
71
63
|
logger_1.logger.info('Skipping remote config: local config is modified');
|
|
72
|
-
return
|
|
64
|
+
return;
|
|
73
65
|
}
|
|
74
66
|
if (localCommitDate &&
|
|
75
67
|
localCommitDate > Date.parse(remoteConfig.committedDate)) {
|
|
76
68
|
logger_1.logger.info(`Skipping remote config: local config is newer: ${new Date(localCommitDate).toISOString()} > ${remoteConfig.committedDate}`);
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
function parseRemoteConfig(remoteConfig) {
|
|
83
|
-
if (!remoteConfig) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
logger_1.logger.info('Using remote config');
|
|
88
|
-
return (0, readConfigFile_1.withConfigMigrations)(JSON.parse(remoteConfig.file.object.text));
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
logger_1.logger.info('Parsing remote config failed', e);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function getHistoricalBranchLabelMappings(historicalRemoteConfigs) {
|
|
96
|
-
return historicalRemoteConfigs
|
|
97
|
-
.map((edge) => {
|
|
98
|
-
try {
|
|
99
|
-
const remoteConfig = JSON.parse(edge.remoteConfig.file.object.text);
|
|
100
|
-
if (!remoteConfig.branchLabelMapping) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
return {
|
|
104
|
-
branchLabelMapping: remoteConfig.branchLabelMapping,
|
|
105
|
-
committedDate: edge.remoteConfig.committedDate,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
catch (e) {
|
|
109
|
-
logger_1.logger.info('Could not get historical remote config', e);
|
|
110
69
|
return;
|
|
111
70
|
}
|
|
112
|
-
})
|
|
113
|
-
.filter(filterEmpty_1.filterNil);
|
|
114
|
-
}
|
|
115
|
-
function swallowErrorIfConfigFileIsMissing(error) {
|
|
116
|
-
const { data, errors } = error.axiosResponse.data;
|
|
117
|
-
const wasMissingConfigError = errors?.some((error) => {
|
|
118
|
-
const isMatch = /^repository.defaultBranchRef.target.history.edges.\d+.remoteConfig.file$/.test(error.path.join('.'));
|
|
119
|
-
return isMatch && error.type === 'NOT_FOUND';
|
|
120
|
-
});
|
|
121
|
-
// swallow error if it's just the config file that's missing
|
|
122
|
-
if (wasMissingConfigError && data != null) {
|
|
123
|
-
return data;
|
|
124
71
|
}
|
|
125
|
-
|
|
126
|
-
throw error;
|
|
72
|
+
return (0, remoteConfig_1.parseRemoteConfig)(remoteConfig);
|
|
127
73
|
}
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
committedDate: string;
|
|
3
|
-
file: {
|
|
4
|
-
object: {
|
|
5
|
-
text: string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
};
|
|
1
|
+
import { RemoteConfigHistory } from '../../../remoteConfig';
|
|
9
2
|
export interface GithubConfigOptionsResponse {
|
|
10
3
|
viewer: {
|
|
11
4
|
login: string;
|
|
@@ -16,14 +9,8 @@ export interface GithubConfigOptionsResponse {
|
|
|
16
9
|
} | null;
|
|
17
10
|
defaultBranchRef: {
|
|
18
11
|
name: string;
|
|
19
|
-
target:
|
|
20
|
-
history: {
|
|
21
|
-
edges: Array<{
|
|
22
|
-
remoteConfig: RemoteConfig;
|
|
23
|
-
}>;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
12
|
+
target: RemoteConfigHistory;
|
|
26
13
|
};
|
|
27
14
|
};
|
|
28
15
|
}
|
|
29
|
-
export declare const query
|
|
16
|
+
export declare const query: import("graphql").DocumentNode;
|
|
@@ -1,7 +1,12 @@
|
|
|
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.query = void 0;
|
|
4
|
-
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
+
const remoteConfig_1 = require("../../../remoteConfig");
|
|
9
|
+
exports.query = (0, graphql_tag_1.default) `
|
|
5
10
|
query GithubConfigOptions($repoOwner: String!, $repoName: String!) {
|
|
6
11
|
viewer {
|
|
7
12
|
login
|
|
@@ -14,26 +19,11 @@ exports.query = `
|
|
|
14
19
|
defaultBranchRef {
|
|
15
20
|
name
|
|
16
21
|
target {
|
|
17
|
-
...
|
|
18
|
-
history(first: 20, path: ".backportrc.json") {
|
|
19
|
-
edges {
|
|
20
|
-
remoteConfig: node {
|
|
21
|
-
committedDate
|
|
22
|
-
file(path: ".backportrc.json") {
|
|
23
|
-
... on TreeEntry {
|
|
24
|
-
object {
|
|
25
|
-
... on Blob {
|
|
26
|
-
text
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
22
|
+
...RemoteConfigHistoryFragment
|
|
35
23
|
}
|
|
36
24
|
}
|
|
37
25
|
}
|
|
38
26
|
}
|
|
27
|
+
|
|
28
|
+
${remoteConfig_1.RemoteConfigHistoryFragment}
|
|
39
29
|
`;
|
|
@@ -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.getRepoOwnerAndNameFromGitRemotes = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
4
8
|
const maybe_1 = require("../../../utils/maybe");
|
|
5
9
|
const git_1 = require("../../git");
|
|
6
10
|
const logger_1 = require("../../logger");
|
|
@@ -38,7 +42,7 @@ async function getRepoOwnerAndNameFromGitRemotes({ accessToken, githubApiBaseUrl
|
|
|
38
42
|
}
|
|
39
43
|
}
|
|
40
44
|
exports.getRepoOwnerAndNameFromGitRemotes = getRepoOwnerAndNameFromGitRemotes;
|
|
41
|
-
const query =
|
|
45
|
+
const query = (0, graphql_tag_1.default) `
|
|
42
46
|
query RepoOwnerAndName($repoOwner: String!, $repoName: String!) {
|
|
43
47
|
repository(owner: $repoOwner, name: $repoName) {
|
|
44
48
|
isFork
|