backport 8.3.1 → 8.4.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/dist/lib/child-process-promisified.js +2 -2
- package/dist/lib/git.js +1 -0
- package/dist/lib/git.test.js +26 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -0
- package/dist/options/ConfigOptions.d.ts +1 -0
- package/dist/options/cliArgs.d.ts +1 -0
- package/dist/options/cliArgs.js +5 -0
- package/dist/options/config/config.d.ts +1 -0
- package/dist/options/config/readConfigFile.d.ts +1 -0
- package/dist/options/options.d.ts +2 -0
- package/dist/options/options.js +1 -0
- package/dist/options/options.test.js +1 -0
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +2 -0
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +3 -4
- package/dist/entrypoint.cli.private.test.d.ts +0 -1
- package/dist/entrypoint.cli.private.test.js +0 -47
- package/dist/errors/BackportError.d.ts +0 -19
- package/dist/errors/BackportError.js +0 -29
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts +0 -1
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
- package/dist/runSequentially.test.d.ts +0 -1
- package/dist/runSequentially.test.js +0 -243
- package/dist/services/BackportError.d.ts +0 -19
- package/dist/services/BackportError.js +0 -29
- package/dist/services/HandledBackportError.d.ts +0 -19
- package/dist/services/HandledBackportError.js +0 -29
- package/dist/services/HandledError.d.ts +0 -19
- package/dist/services/HandledError.js +0 -29
- package/dist/services/child-process-promisified.d.ts +0 -25
- package/dist/services/child-process-promisified.js +0 -58
- package/dist/services/env.d.ts +0 -7
- package/dist/services/env.js +0 -30
- package/dist/services/env.test.d.ts +0 -1
- package/dist/services/env.test.js +0 -21
- package/dist/services/git.d.ts +0 -77
- package/dist/services/git.integration.test.d.ts +0 -1
- package/dist/services/git.integration.test.js +0 -616
- package/dist/services/git.js +0 -439
- package/dist/services/git.private.test.d.ts +0 -1
- package/dist/services/git.private.test.js +0 -618
- package/dist/services/git.test.d.ts +0 -1
- package/dist/services/git.test.js +0 -580
- package/dist/services/github/commitFormatters.d.ts +0 -3
- package/dist/services/github/commitFormatters.js +0 -17
- 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.d.ts +0 -2
- package/dist/services/github/v3/addAssigneesToPullRequest.js +0 -32
- 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/addLabelsToPullRequest.d.ts +0 -2
- package/dist/services/github/v3/addLabelsToPullRequest.js +0 -30
- package/dist/services/github/v3/addReviewersToPullRequest.d.ts +0 -2
- package/dist/services/github/v3/addReviewersToPullRequest.js +0 -32
- package/dist/services/github/v3/createPullRequest.d.ts +0 -29
- package/dist/services/github/v3/createPullRequest.js +0 -91
- package/dist/services/github/v3/createPullRequest.test.d.ts +0 -1
- package/dist/services/github/v3/createPullRequest.test.js +0 -377
- package/dist/services/github/v3/createStatusComment.d.ts +0 -11
- package/dist/services/github/v3/createStatusComment.js +0 -131
- package/dist/services/github/v3/createStatusComment.test.d.ts +0 -1
- package/dist/services/github/v3/createStatusComment.test.js +0 -409
- package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +0 -14
- package/dist/services/github/v3/getGithubV3ErrorMessage.js +0 -16
- package/dist/services/github/v4/FetchPullRequestId.d.ts +0 -2
- package/dist/services/github/v4/FetchPullRequestId.js +0 -36
- package/dist/services/github/v4/apiRequestV4.d.ts +0 -31
- package/dist/services/github/v4/apiRequestV4.js +0 -71
- package/dist/services/github/v4/apiRequestV4.test.d.ts +0 -1
- package/dist/services/github/v4/apiRequestV4.test.js +0 -109
- package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -2
- package/dist/services/github/v4/disablePullRequestAutoMerge.js +0 -32
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -2
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +0 -50
- 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.d.ts +0 -10
- package/dist/services/github/v4/fetchAuthorId.js +0 -28
- package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchAuthorId.private.test.js +0 -25
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -93
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +0 -11
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +0 -58
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +0 -136
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +0 -11
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +0 -48
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +0 -118
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +0 -29
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +0 -110
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +0 -196
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -157
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +0 -3
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +0 -61
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +0 -107
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +0 -12
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +0 -69
- package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -9
- package/dist/services/github/v4/fetchExistingPullRequest.js +0 -64
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -44
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -2
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +0 -39
- package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +0 -8
- package/dist/services/github/v4/fetchRemoteProjectConfig.js +0 -49
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +0 -49
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +0 -69
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +0 -73
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +0 -1
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -116
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +0 -16
- package/dist/services/github/v4/getOptionsFromGithub/query.js +0 -29
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +0 -29
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +0 -61
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +0 -1
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +0 -72
- package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +0 -176
- package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +0 -6
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +0 -45
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +0 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +0 -87
- package/dist/services/logger.d.ts +0 -9
- package/dist/services/logger.js +0 -74
- package/dist/services/prompt.test.d.ts +0 -1
- package/dist/services/prompt.test.js +0 -139
- package/dist/services/prompts.d.ts +0 -17
- package/dist/services/prompts.js +0 -132
- package/dist/services/remoteConfig.d.ts +0 -20
- package/dist/services/remoteConfig.js +0 -52
- package/dist/services/sequentially.d.ts +0 -1
- package/dist/services/sequentially.js +0 -10
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +0 -16
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +0 -102
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +0 -1
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +0 -467
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +0 -26
- package/dist/services/sourceCommit/getMockSourceCommit.js +0 -103
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +0 -108
- package/dist/services/sourceCommit/parseSourceCommit.js +0 -123
- package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit/parseSourceCommit.test.js +0 -226
- package/dist/services/test.d.ts +0 -1
- package/dist/services/test.js +0 -23
- package/dist/state.d.ts +0 -0
- package/dist/state.js +0 -1
- package/dist/test/ExecError.d.ts +0 -16
- package/dist/test/ExecError.js +0 -15
- package/dist/test/e2e/cli/cli.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/cli.private.test.js +0 -222
- package/dist/test/e2e/cli/date-filters.d.ts +0 -1
- package/dist/test/e2e/cli/date-filters.js +0 -43
- package/dist/test/e2e/cli/interactive-error-handling.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/interactive-error-handling.private.test.js +0 -80
- package/dist/test/e2e/cli/non-interactive-error-handling.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/non-interactive-error-handling.private.test.js +0 -198
- package/dist/test/e2e/cli.e2e.private.test.d.ts +0 -1
- package/dist/test/e2e/cli.e2e.private.test.js +0 -433
- package/dist/test/e2e/module/module.mutation.test.d.ts +0 -1
- package/dist/test/e2e/module/module.mutation.test.js +0 -369
- package/dist/test/e2e/module.e2e.mutation.test.d.ts +0 -1
- package/dist/test/e2e/module.e2e.mutation.test.js +0 -369
- package/dist/test/e2e/module.e2e.private.test.d.ts +0 -1
- package/dist/test/e2e/module.e2e.private.test.js +0 -369
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -13
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +0 -243
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +0 -320
- package/dist/ui/getCommits.d.ts +0 -2
- package/dist/ui/getCommits.js +0 -75
- package/dist/ui/getCommitsWithoutBackports.d.ts +0 -11
- package/dist/ui/getCommitsWithoutBackports.js +0 -68
- package/dist/ui/getCommitsWithoutBackports.test.d.ts +0 -1
- package/dist/ui/getCommitsWithoutBackports.test.js +0 -335
- package/dist/ui/getGitConfigAuthor.d.ts +0 -6
- package/dist/ui/getGitConfigAuthor.js +0 -15
- package/dist/ui/getTargetBranches.d.ts +0 -5
- package/dist/ui/getTargetBranches.js +0 -67
- package/dist/ui/getTargetBranches.test.d.ts +0 -1
- package/dist/ui/getTargetBranches.test.js +0 -204
- package/dist/ui/maybeSetupRepo.d.ts +0 -2
- package/dist/ui/maybeSetupRepo.js +0 -53
- package/dist/ui/maybeSetupRepo.test.d.ts +0 -1
- package/dist/ui/maybeSetupRepo.test.js +0 -238
- package/dist/ui/ora.d.ts +0 -2
- package/dist/ui/ora.js +0 -21
- package/dist/ui/setupRepo.d.ts +0 -2
- package/dist/ui/setupRepo.js +0 -56
- package/dist/ui/setupRepo.test.d.ts +0 -1
- package/dist/ui/setupRepo.test.js +0 -273
- package/dist/utils/filterMissingCommits.d.ts +0 -2
- package/dist/utils/filterMissingCommits.js +0 -7
- package/dist/utils/redact.d.ts +0 -1
- package/dist/utils/redact.js +0 -7
package/dist/services/prompts.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.confirmPrompt = exports.promptForTargetBranches = exports.promptForCommits = exports.getChoicesForCommitPrompt = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
9
|
-
const lodash_1 = require("lodash");
|
|
10
|
-
const terminal_link_1 = __importDefault(require("terminal-link"));
|
|
11
|
-
const commitFormatters_1 = require("./github/commitFormatters");
|
|
12
|
-
async function prompt(options) {
|
|
13
|
-
const { promptResult } = (await inquirer_1.default.prompt([
|
|
14
|
-
{ ...options, name: 'promptResult' },
|
|
15
|
-
]));
|
|
16
|
-
return promptResult;
|
|
17
|
-
}
|
|
18
|
-
function getPrStateIcon(state) {
|
|
19
|
-
if (state === 'MERGED') {
|
|
20
|
-
return '🟢';
|
|
21
|
-
}
|
|
22
|
-
if (state === 'NOT_CREATED') {
|
|
23
|
-
return '🔴';
|
|
24
|
-
}
|
|
25
|
-
if (state === 'OPEN') {
|
|
26
|
-
return '🔵';
|
|
27
|
-
}
|
|
28
|
-
// unknown state
|
|
29
|
-
return '🔴';
|
|
30
|
-
}
|
|
31
|
-
function getPrStateText(state) {
|
|
32
|
-
if (state === 'MERGED') {
|
|
33
|
-
return chalk_1.default.gray('Merged');
|
|
34
|
-
}
|
|
35
|
-
if (state === 'NOT_CREATED') {
|
|
36
|
-
return chalk_1.default.gray('Backport not created');
|
|
37
|
-
}
|
|
38
|
-
if (state === 'OPEN') {
|
|
39
|
-
return chalk_1.default.gray('Open, not merged');
|
|
40
|
-
}
|
|
41
|
-
return chalk_1.default.gray('Unknown state');
|
|
42
|
-
}
|
|
43
|
-
function getPrLink(number, url) {
|
|
44
|
-
return url ? `(${(0, terminal_link_1.default)(`#${number}`, url)})` : '';
|
|
45
|
-
}
|
|
46
|
-
function getDetailedPullStatus(c) {
|
|
47
|
-
const items = c.expectedTargetPullRequests.map((pr) => {
|
|
48
|
-
const prLink = getPrLink(pr.number, pr.url);
|
|
49
|
-
return ` └ ${getPrStateIcon(pr.state)} ${pr.branch} ${prLink} ${getPrStateText(pr.state)}`;
|
|
50
|
-
});
|
|
51
|
-
const list = items.length > 0
|
|
52
|
-
? `\n${chalk_1.default.reset(items.join('\n'))}`
|
|
53
|
-
: `\n └ ${chalk_1.default.gray('No backports expected')}`;
|
|
54
|
-
return `${list}\n`;
|
|
55
|
-
}
|
|
56
|
-
function getSimplePullStatus(c) {
|
|
57
|
-
return c.expectedTargetPullRequests
|
|
58
|
-
.map(({ state, branch }) => {
|
|
59
|
-
if (state === 'MERGED') {
|
|
60
|
-
return chalk_1.default.green(branch);
|
|
61
|
-
}
|
|
62
|
-
if (state === 'NOT_CREATED') {
|
|
63
|
-
return chalk_1.default.red(branch);
|
|
64
|
-
}
|
|
65
|
-
if (state === 'OPEN') {
|
|
66
|
-
return chalk_1.default.gray(branch);
|
|
67
|
-
}
|
|
68
|
-
return chalk_1.default.gray('Unknown state');
|
|
69
|
-
})
|
|
70
|
-
.join(', ');
|
|
71
|
-
}
|
|
72
|
-
function getChoicesForCommitPrompt(commits, showDetails) {
|
|
73
|
-
return commits.map((c, i) => {
|
|
74
|
-
const leadingWhitespace = (0, lodash_1.repeat)(' ', 2 - (i + 1).toString().length);
|
|
75
|
-
const position = chalk_1.default.gray(`${i + 1}.${leadingWhitespace}`);
|
|
76
|
-
let name;
|
|
77
|
-
if (showDetails) {
|
|
78
|
-
const message = (0, commitFormatters_1.stripPullNumber)(c.sourceCommit.message);
|
|
79
|
-
const prLink = c.sourcePullRequest
|
|
80
|
-
? ` ` + getPrLink(c.sourcePullRequest.number, c.sourcePullRequest.url)
|
|
81
|
-
: '';
|
|
82
|
-
const pullStatus = getDetailedPullStatus(c);
|
|
83
|
-
name = `${position}${message}${prLink}${pullStatus}`;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
const message = (0, commitFormatters_1.getFirstLine)(c.sourceCommit.message);
|
|
87
|
-
const pullStatus = getSimplePullStatus(c);
|
|
88
|
-
name = `${position}${message} ${pullStatus}`;
|
|
89
|
-
}
|
|
90
|
-
const short = c.sourcePullRequest
|
|
91
|
-
? `#${c.sourcePullRequest.number} (${(0, commitFormatters_1.getShortSha)(c.sourcePullRequest.mergeCommit.sha)})`
|
|
92
|
-
: (0, commitFormatters_1.getShortSha)(c.sourceCommit.sha);
|
|
93
|
-
return { name, short, value: c };
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
exports.getChoicesForCommitPrompt = getChoicesForCommitPrompt;
|
|
97
|
-
async function promptForCommits({ commitChoices, isMultipleChoice, showDetails, }) {
|
|
98
|
-
const choices = getChoicesForCommitPrompt(commitChoices, showDetails);
|
|
99
|
-
const res = await prompt({
|
|
100
|
-
loop: false,
|
|
101
|
-
pageSize: 30,
|
|
102
|
-
choices: choices,
|
|
103
|
-
message: 'Select commit',
|
|
104
|
-
type: isMultipleChoice ? 'checkbox' : 'list',
|
|
105
|
-
});
|
|
106
|
-
const selectedCommits = Array.isArray(res) ? res.reverse() : [res];
|
|
107
|
-
return (0, lodash_1.isEmpty)(selectedCommits)
|
|
108
|
-
? promptForCommits({ commitChoices, isMultipleChoice, showDetails })
|
|
109
|
-
: selectedCommits;
|
|
110
|
-
}
|
|
111
|
-
exports.promptForCommits = promptForCommits;
|
|
112
|
-
async function promptForTargetBranches({ targetBranchChoices, isMultipleChoice, }) {
|
|
113
|
-
const res = await prompt({
|
|
114
|
-
loop: false,
|
|
115
|
-
pageSize: 15,
|
|
116
|
-
choices: targetBranchChoices,
|
|
117
|
-
message: 'Select branch',
|
|
118
|
-
type: isMultipleChoice ? 'checkbox' : 'list',
|
|
119
|
-
});
|
|
120
|
-
const selectedBranches = Array.isArray(res) ? res : [res];
|
|
121
|
-
return (0, lodash_1.isEmpty)(selectedBranches)
|
|
122
|
-
? promptForTargetBranches({
|
|
123
|
-
targetBranchChoices,
|
|
124
|
-
isMultipleChoice,
|
|
125
|
-
})
|
|
126
|
-
: selectedBranches;
|
|
127
|
-
}
|
|
128
|
-
exports.promptForTargetBranches = promptForTargetBranches;
|
|
129
|
-
function confirmPrompt(message) {
|
|
130
|
-
return prompt({ message, type: 'confirm' });
|
|
131
|
-
}
|
|
132
|
-
exports.confirmPrompt = confirmPrompt;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ConfigFileOptions } from '../entrypoint.module';
|
|
2
|
-
import { GithubV4Exception } from './github/v4/apiRequestV4';
|
|
3
|
-
export declare const RemoteConfigHistoryFragment: import("graphql").DocumentNode;
|
|
4
|
-
export interface RemoteConfig {
|
|
5
|
-
committedDate: string;
|
|
6
|
-
file: {
|
|
7
|
-
object: {
|
|
8
|
-
text: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export interface RemoteConfigHistory {
|
|
13
|
-
remoteConfigHistory: {
|
|
14
|
-
edges: Array<{
|
|
15
|
-
remoteConfig: RemoteConfig;
|
|
16
|
-
}> | null;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
export declare function parseRemoteConfig(remoteConfig: RemoteConfig): ConfigFileOptions | undefined;
|
|
20
|
-
export declare function swallowMissingConfigFileException<T>(error: GithubV4Exception<T>): T;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.swallowMissingConfigFileException = exports.parseRemoteConfig = exports.RemoteConfigHistoryFragment = void 0;
|
|
7
|
-
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
-
const readConfigFile_1 = require("../options/config/readConfigFile");
|
|
9
|
-
const logger_1 = require("./logger");
|
|
10
|
-
exports.RemoteConfigHistoryFragment = (0, graphql_tag_1.default) `
|
|
11
|
-
fragment RemoteConfigHistoryFragment on Commit {
|
|
12
|
-
remoteConfigHistory: history(first: 1, path: ".backportrc.json") {
|
|
13
|
-
edges {
|
|
14
|
-
remoteConfig: node {
|
|
15
|
-
committedDate
|
|
16
|
-
file(path: ".backportrc.json") {
|
|
17
|
-
... on TreeEntry {
|
|
18
|
-
object {
|
|
19
|
-
... on Blob {
|
|
20
|
-
text
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
`;
|
|
30
|
-
function parseRemoteConfig(remoteConfig) {
|
|
31
|
-
try {
|
|
32
|
-
return (0, readConfigFile_1.withConfigMigrations)(JSON.parse(remoteConfig.file.object.text));
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
logger_1.logger.info('Parsing remote config failed', e);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function sequentially<T>(items: T[], handler: (item: T) => Promise<void>): Promise<void>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sequentially = void 0;
|
|
4
|
-
function sequentially(items, handler) {
|
|
5
|
-
return items.reduce(async (p, item) => {
|
|
6
|
-
await p;
|
|
7
|
-
return handler(item);
|
|
8
|
-
}, Promise.resolve());
|
|
9
|
-
}
|
|
10
|
-
exports.sequentially = sequentially;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ValidConfigOptions } from '../../options/options';
|
|
2
|
-
import { SourceCommitWithTargetPullRequest } from './parseSourceCommit';
|
|
3
|
-
export declare type ExpectedTargetPullRequest = {
|
|
4
|
-
url?: string;
|
|
5
|
-
number?: number;
|
|
6
|
-
branch: string;
|
|
7
|
-
state: 'OPEN' | 'CLOSED' | 'MERGED' | 'NOT_CREATED';
|
|
8
|
-
mergeCommit?: {
|
|
9
|
-
sha: string;
|
|
10
|
-
message: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export declare function getExpectedTargetPullRequests({ sourceCommit, latestBranchLabelMapping, }: {
|
|
14
|
-
sourceCommit: SourceCommitWithTargetPullRequest;
|
|
15
|
-
latestBranchLabelMapping: ValidConfigOptions['branchLabelMapping'];
|
|
16
|
-
}): ExpectedTargetPullRequest[];
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getExpectedTargetPullRequests = void 0;
|
|
4
|
-
const lodash_1 = require("lodash");
|
|
5
|
-
const filterEmpty_1 = require("../../utils/filterEmpty");
|
|
6
|
-
const commitFormatters_1 = require("../github/commitFormatters");
|
|
7
|
-
const remoteConfig_1 = require("../remoteConfig");
|
|
8
|
-
function getExpectedTargetPullRequests({ sourceCommit, latestBranchLabelMapping, }) {
|
|
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;
|
|
13
|
-
// if there is no source pull request the commit was pushed directly to the source branch
|
|
14
|
-
// in that case there will be no labels, and thus not possible to deduce the expected target branches
|
|
15
|
-
if (!sourcePullRequest) {
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
const existingTargetPullRequests = getExistingTargetPullRequests(sourceCommit, sourcePullRequest);
|
|
19
|
-
// if there's no `branchLabelMapping`, it's not possible to deduce the missing target branches
|
|
20
|
-
if (!branchLabelMapping) {
|
|
21
|
-
return existingTargetPullRequests;
|
|
22
|
-
}
|
|
23
|
-
const missingTargetPullRequests = getMissingTargetPullRequests(sourcePullRequest, existingTargetPullRequests, branchLabelMapping);
|
|
24
|
-
return [...existingTargetPullRequests, ...missingTargetPullRequests];
|
|
25
|
-
}
|
|
26
|
-
exports.getExpectedTargetPullRequests = getExpectedTargetPullRequests;
|
|
27
|
-
function getExistingTargetPullRequests(sourceCommit, sourcePullRequest) {
|
|
28
|
-
const sourceCommitMessage = (0, commitFormatters_1.getFirstLine)(sourceCommit.message);
|
|
29
|
-
return sourcePullRequest.timelineItems.edges
|
|
30
|
-
.filter(filterEmpty_1.filterNil)
|
|
31
|
-
.filter(filterPullRequests)
|
|
32
|
-
.filter((item) => {
|
|
33
|
-
const { targetPullRequest } = item.node;
|
|
34
|
-
// ignore closed PRs
|
|
35
|
-
if (targetPullRequest.state === 'CLOSED') {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
// at least one of the commits in `targetPullRequest` should match the merge commit from the source pull request
|
|
39
|
-
const didCommitMatch = targetPullRequest.commits.edges.some((commitEdge) => {
|
|
40
|
-
const { targetCommit } = commitEdge.node;
|
|
41
|
-
const matchingRepoName = sourceCommit.repository.name === targetPullRequest.repository.name;
|
|
42
|
-
const matchingRepoOwner = sourceCommit.repository.owner.login ===
|
|
43
|
-
targetPullRequest.repository.owner.login;
|
|
44
|
-
const targetCommitMessage = (0, commitFormatters_1.getFirstLine)(targetCommit.message);
|
|
45
|
-
const matchingMessage = targetCommitMessage === sourceCommitMessage;
|
|
46
|
-
return matchingRepoName && matchingRepoOwner && matchingMessage;
|
|
47
|
-
});
|
|
48
|
-
const titleIncludesMessage = targetPullRequest.title.includes(sourceCommitMessage);
|
|
49
|
-
const titleIncludesNumber = targetPullRequest.title.includes(sourcePullRequest.number.toString());
|
|
50
|
-
return didCommitMatch || (titleIncludesMessage && titleIncludesNumber);
|
|
51
|
-
})
|
|
52
|
-
.map((item) => {
|
|
53
|
-
const { targetPullRequest } = item.node;
|
|
54
|
-
return {
|
|
55
|
-
url: targetPullRequest.url,
|
|
56
|
-
number: targetPullRequest.number,
|
|
57
|
-
branch: targetPullRequest.baseRefName,
|
|
58
|
-
state: targetPullRequest.state,
|
|
59
|
-
mergeCommit: targetPullRequest.targetMergeCommit
|
|
60
|
-
? {
|
|
61
|
-
sha: targetPullRequest.targetMergeCommit.sha,
|
|
62
|
-
message: targetPullRequest.targetMergeCommit.message,
|
|
63
|
-
}
|
|
64
|
-
: undefined,
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
function getMissingTargetPullRequests(sourcePullRequest, existingTargetPullRequests, branchLabelMapping) {
|
|
69
|
-
const labels = sourcePullRequest.labels.nodes.map((label) => label.name);
|
|
70
|
-
const targetBranchesFromLabels = labels
|
|
71
|
-
.map((label) => getTargetBranchForLabel({ branchLabelMapping, label }))
|
|
72
|
-
.filter(filterEmpty_1.filterNil)
|
|
73
|
-
.filter((targetBranch) => targetBranch !== sourcePullRequest.baseRefName);
|
|
74
|
-
const expectedTargetBranches = existingTargetPullRequests.map((pr) => pr.branch);
|
|
75
|
-
const expected = (0, lodash_1.uniq)(targetBranchesFromLabels);
|
|
76
|
-
return expected
|
|
77
|
-
.filter((targetBranch) => !expectedTargetBranches.includes(targetBranch))
|
|
78
|
-
.map((branch) => {
|
|
79
|
-
return { branch, state: 'NOT_CREATED' };
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
// narrow TimelineEdge to TimelinePullRequestEdge
|
|
83
|
-
function filterPullRequests(item) {
|
|
84
|
-
const { targetPullRequest } = item.node;
|
|
85
|
-
return targetPullRequest.__typename === 'PullRequest';
|
|
86
|
-
}
|
|
87
|
-
function getTargetBranchForLabel({ branchLabelMapping, label, }) {
|
|
88
|
-
// only get first match
|
|
89
|
-
const result = Object.entries(branchLabelMapping).find(([labelPattern]) => {
|
|
90
|
-
const regex = new RegExp(labelPattern);
|
|
91
|
-
const isMatch = label.match(regex) !== null;
|
|
92
|
-
return isMatch;
|
|
93
|
-
});
|
|
94
|
-
if (result) {
|
|
95
|
-
const [labelPattern, targetBranchPattern] = result;
|
|
96
|
-
const regex = new RegExp(labelPattern);
|
|
97
|
-
const targetBranch = label.replace(regex, targetBranchPattern);
|
|
98
|
-
if (targetBranch) {
|
|
99
|
-
return targetBranch;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|