backport 7.0.1 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backportRun.d.ts +1 -0
- package/dist/backportRun.js +3 -2
- package/dist/entrypoint.cli.js +12 -1
- package/dist/options/cliArgs.d.ts +1 -1
- package/dist/options/config/readConfigFile.d.ts +1 -1
- package/dist/options/options.d.ts +1 -5
- package/dist/options/options.test.js +26 -28
- package/dist/runSequentially.test.js +0 -1
- package/dist/services/HandledError.js +3 -1
- package/dist/services/git.js +5 -8
- package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.js +3 -6
- package/dist/services/github/v3/addLabelsToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addLabelsToPullRequest.js +3 -6
- package/dist/services/github/v3/addReviewersToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addReviewersToPullRequest.js +3 -6
- package/dist/services/github/v3/createPullRequest.js +2 -5
- package/dist/services/github/v4/FetchPullRequestId.js +5 -1
- package/dist/services/github/v4/apiRequestV4.d.ts +3 -1
- package/dist/services/github/v4/apiRequestV4.js +7 -7
- package/dist/services/github/v4/apiRequestV4.test.js +38 -11
- package/dist/services/github/v4/disablePullRequestAutoMerge.js +5 -1
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +4 -3
- package/dist/services/github/v4/fetchAuthorId.js +5 -1
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +6 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +3 -12
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +6 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +3 -11
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +6 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +7 -12
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +6 -2
- package/dist/services/github/v4/fetchExistingPullRequest.js +5 -1
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +5 -1
- package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +1 -1
- package/dist/services/github/v4/fetchRemoteProjectConfig.js +13 -20
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +0 -4
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +14 -55
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -19
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +3 -16
- package/dist/services/github/v4/getOptionsFromGithub/query.js +9 -19
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +5 -1
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +5 -0
- package/dist/services/logger.d.ts +5 -5
- package/dist/services/logger.js +24 -23
- package/dist/services/remoteConfig.d.ts +18 -0
- package/dist/services/remoteConfig.js +39 -0
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +4 -0
- package/dist/services/sourceCommit/getMockSourceCommit.js +20 -6
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +3 -4
- package/dist/services/sourceCommit/parseSourceCommit.js +73 -71
- package/dist/services/sourceCommit/parseSourceCommit.test.js +7 -17
- package/dist/test/nockHelpers.js +6 -2
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +4 -4
- package/dist/ui/getCommits.js +2 -2
- package/dist/ui/ora.d.ts +9 -0
- package/dist/ui/ora.js +21 -0
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
+
...RemoteConfigHistory
|
|
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
|
|
@@ -9,6 +9,7 @@ exports.commitsByAuthorMock = {
|
|
|
9
9
|
edges: [
|
|
10
10
|
{
|
|
11
11
|
node: {
|
|
12
|
+
remoteConfigHistory: { edges: [] },
|
|
12
13
|
repository: {
|
|
13
14
|
name: 'kibana',
|
|
14
15
|
owner: { login: 'elastic' },
|
|
@@ -23,6 +24,7 @@ exports.commitsByAuthorMock = {
|
|
|
23
24
|
},
|
|
24
25
|
{
|
|
25
26
|
node: {
|
|
27
|
+
remoteConfigHistory: { edges: [] },
|
|
26
28
|
repository: {
|
|
27
29
|
name: 'kibana',
|
|
28
30
|
owner: { login: 'elastic' },
|
|
@@ -55,6 +57,7 @@ exports.commitsByAuthorMock = {
|
|
|
55
57
|
},
|
|
56
58
|
{
|
|
57
59
|
node: {
|
|
60
|
+
remoteConfigHistory: { edges: [] },
|
|
58
61
|
repository: {
|
|
59
62
|
name: 'kibana',
|
|
60
63
|
owner: { login: 'elastic' },
|
|
@@ -120,6 +123,7 @@ exports.commitsByAuthorMock = {
|
|
|
120
123
|
},
|
|
121
124
|
{
|
|
122
125
|
node: {
|
|
126
|
+
remoteConfigHistory: { edges: [] },
|
|
123
127
|
repository: {
|
|
124
128
|
name: 'kibana',
|
|
125
129
|
owner: { login: 'elastic' },
|
|
@@ -134,6 +138,7 @@ exports.commitsByAuthorMock = {
|
|
|
134
138
|
},
|
|
135
139
|
{
|
|
136
140
|
node: {
|
|
141
|
+
remoteConfigHistory: { edges: [] },
|
|
137
142
|
repository: {
|
|
138
143
|
name: 'kibana',
|
|
139
144
|
owner: { login: 'elastic' },
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import winston from 'winston';
|
|
2
2
|
export declare let logger: winston.Logger;
|
|
3
|
+
export declare function initLogger({ ci, accessToken, logFilePath, }: {
|
|
4
|
+
ci: boolean | undefined;
|
|
5
|
+
accessToken?: string;
|
|
6
|
+
logFilePath?: string;
|
|
7
|
+
}): winston.Logger;
|
|
3
8
|
export declare function consoleLog(message: string): void;
|
|
4
9
|
export declare function updateLogger({ accessToken, verbose, }: {
|
|
5
10
|
accessToken: string;
|
|
6
11
|
verbose?: boolean;
|
|
7
12
|
}): void;
|
|
8
|
-
export declare function initLogger({ ci, accessToken, logFilePath, }: {
|
|
9
|
-
ci?: boolean;
|
|
10
|
-
accessToken?: string;
|
|
11
|
-
logFilePath?: string;
|
|
12
|
-
}): winston.Logger;
|
package/dist/services/logger.js
CHANGED
|
@@ -19,18 +19,37 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.
|
|
22
|
+
exports.updateLogger = exports.consoleLog = exports.initLogger = exports.logger = void 0;
|
|
23
23
|
const winston_1 = __importStar(require("winston"));
|
|
24
24
|
const redact_1 = require("../utils/redact");
|
|
25
25
|
const env_1 = require("./env");
|
|
26
|
+
let _accessToken;
|
|
27
|
+
let _ci;
|
|
28
|
+
function initLogger({ ci, accessToken, logFilePath, }) {
|
|
29
|
+
const fileTransport = getFileTransport({ logFilePath });
|
|
30
|
+
if (accessToken) {
|
|
31
|
+
_accessToken = accessToken;
|
|
32
|
+
}
|
|
33
|
+
_ci = ci;
|
|
34
|
+
exports.logger = winston_1.default.createLogger({
|
|
35
|
+
format: winston_1.format.combine(winston_1.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
|
|
36
|
+
// Format the metadata object
|
|
37
|
+
winston_1.format.metadata({
|
|
38
|
+
fillExcept: ['message', 'level', 'timestamp', 'label'],
|
|
39
|
+
})),
|
|
40
|
+
transports: fileTransport,
|
|
41
|
+
});
|
|
42
|
+
return exports.logger;
|
|
43
|
+
}
|
|
44
|
+
exports.initLogger = initLogger;
|
|
26
45
|
// wrapper around console.log
|
|
27
46
|
function consoleLog(message) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
47
|
+
if (!_ci) {
|
|
48
|
+
// eslint-disable-next-line no-console
|
|
49
|
+
console.log(redactAccessToken(message));
|
|
50
|
+
}
|
|
31
51
|
}
|
|
32
52
|
exports.consoleLog = consoleLog;
|
|
33
|
-
let _accessToken;
|
|
34
53
|
function updateLogger({ accessToken, verbose, }) {
|
|
35
54
|
// set access token
|
|
36
55
|
_accessToken = accessToken;
|
|
@@ -45,24 +64,6 @@ function redactAccessToken(str) {
|
|
|
45
64
|
}
|
|
46
65
|
return str;
|
|
47
66
|
}
|
|
48
|
-
function initLogger({ ci, accessToken, logFilePath, }) {
|
|
49
|
-
const fileTransport = getFileTransport({ logFilePath });
|
|
50
|
-
if (accessToken) {
|
|
51
|
-
_accessToken = accessToken;
|
|
52
|
-
}
|
|
53
|
-
exports.logger = winston_1.default.createLogger({
|
|
54
|
-
format: winston_1.format.combine(winston_1.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
|
|
55
|
-
// Format the metadata object
|
|
56
|
-
winston_1.format.metadata({
|
|
57
|
-
fillExcept: ['message', 'level', 'timestamp', 'label'],
|
|
58
|
-
})),
|
|
59
|
-
transports: ci
|
|
60
|
-
? [fileTransport, new winston_1.default.transports.Console()]
|
|
61
|
-
: [fileTransport],
|
|
62
|
-
});
|
|
63
|
-
return exports.logger;
|
|
64
|
-
}
|
|
65
|
-
exports.initLogger = initLogger;
|
|
66
67
|
function getFileTransport({ logFilePath }) {
|
|
67
68
|
return new winston_1.default.transports.File({
|
|
68
69
|
filename: (0, env_1.getLogfilePath)({ logFilePath }),
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ConfigFileOptions } from '../entrypoint.module';
|
|
2
|
+
export declare const RemoteConfigHistoryFragment: import("graphql").DocumentNode;
|
|
3
|
+
export interface RemoteConfig {
|
|
4
|
+
committedDate: string;
|
|
5
|
+
file: {
|
|
6
|
+
object: {
|
|
7
|
+
text: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export interface RemoteConfigHistory {
|
|
12
|
+
remoteConfigHistory: {
|
|
13
|
+
edges: Array<{
|
|
14
|
+
remoteConfig: RemoteConfig;
|
|
15
|
+
}> | null;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare function parseRemoteConfig(remoteConfig: RemoteConfig): ConfigFileOptions | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
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.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 RemoteConfigHistory 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;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { SourceCommitWithTargetPullRequest } from './parseSourceCommit';
|
|
2
2
|
export declare function getMockSourceCommit({ sourceCommit, sourcePullRequest, timelineItems, }: {
|
|
3
3
|
sourceCommit: {
|
|
4
|
+
remoteConfig?: {
|
|
5
|
+
branchLabelMapping: Record<string, string>;
|
|
6
|
+
committedDate: string;
|
|
7
|
+
};
|
|
4
8
|
sha?: string;
|
|
5
9
|
message: string;
|
|
6
10
|
commitedDate?: string;
|
|
@@ -5,6 +5,24 @@ function getMockSourceCommit({ sourceCommit, sourcePullRequest, timelineItems =
|
|
|
5
5
|
const defaultTargetPullRequestTitle = 'DO NOT USE: Default Pull Request Title';
|
|
6
6
|
const defaultSourceCommitSha = 'DO NOT USE: default-source-commit-sha';
|
|
7
7
|
const baseMockCommit = {
|
|
8
|
+
remoteConfigHistory: sourceCommit.remoteConfig
|
|
9
|
+
? {
|
|
10
|
+
edges: [
|
|
11
|
+
{
|
|
12
|
+
remoteConfig: {
|
|
13
|
+
committedDate: sourceCommit.remoteConfig.committedDate,
|
|
14
|
+
file: {
|
|
15
|
+
object: {
|
|
16
|
+
text: JSON.stringify({
|
|
17
|
+
branchLabelMapping: sourceCommit.remoteConfig.branchLabelMapping,
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
}
|
|
25
|
+
: { edges: [] },
|
|
8
26
|
repository: {
|
|
9
27
|
name: 'kibana',
|
|
10
28
|
owner: { login: 'elastic' },
|
|
@@ -12,14 +30,10 @@ function getMockSourceCommit({ sourceCommit, sourcePullRequest, timelineItems =
|
|
|
12
30
|
committedDate: sourceCommit.commitedDate ?? '2021-12-22T00:00:00Z',
|
|
13
31
|
sha: sourceCommit.sha ?? defaultSourceCommitSha,
|
|
14
32
|
message: sourceCommit.message,
|
|
33
|
+
associatedPullRequests: { edges: null },
|
|
15
34
|
};
|
|
16
35
|
if (!sourcePullRequest) {
|
|
17
|
-
return
|
|
18
|
-
...baseMockCommit,
|
|
19
|
-
associatedPullRequests: {
|
|
20
|
-
edges: null,
|
|
21
|
-
},
|
|
22
|
-
};
|
|
36
|
+
return baseMockCommit;
|
|
23
37
|
}
|
|
24
38
|
return {
|
|
25
39
|
...baseMockCommit,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ValidConfigOptions } from '../../options/options';
|
|
2
|
+
import { RemoteConfigHistory } from '../remoteConfig';
|
|
2
3
|
import { ExpectedTargetPullRequest } from './getExpectedTargetPullRequests';
|
|
3
4
|
export interface Commit {
|
|
4
5
|
sourceCommit: {
|
|
@@ -75,6 +76,7 @@ interface TimelineIssueEdge {
|
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
78
|
export declare type SourceCommitWithTargetPullRequest = {
|
|
79
|
+
remoteConfigHistory: RemoteConfigHistory['remoteConfigHistory'];
|
|
78
80
|
repository: {
|
|
79
81
|
name: string;
|
|
80
82
|
owner: {
|
|
@@ -94,11 +96,8 @@ export declare function parseSourceCommit({ sourceCommit, options, }: {
|
|
|
94
96
|
sourceCommit: SourceCommitWithTargetPullRequest;
|
|
95
97
|
options: {
|
|
96
98
|
branchLabelMapping?: ValidConfigOptions['branchLabelMapping'];
|
|
97
|
-
historicalBranchLabelMappings: ValidConfigOptions['historicalBranchLabelMappings'];
|
|
98
99
|
sourceBranch: string;
|
|
99
100
|
};
|
|
100
101
|
}): Commit;
|
|
101
|
-
export declare const sourceCommitWithTargetPullRequestFragment:
|
|
102
|
-
source: string;
|
|
103
|
-
};
|
|
102
|
+
export declare const sourceCommitWithTargetPullRequestFragment: import("graphql").DocumentNode;
|
|
104
103
|
export {};
|
|
@@ -1,13 +1,21 @@
|
|
|
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.sourceCommitWithTargetPullRequestFragment = exports.parseSourceCommit = void 0;
|
|
4
|
-
const
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
+
const remoteConfig_1 = require("../remoteConfig");
|
|
5
9
|
const getExpectedTargetPullRequests_1 = require("./getExpectedTargetPullRequests");
|
|
6
10
|
function parseSourceCommit({ sourceCommit, options, }) {
|
|
7
11
|
const sourcePullRequest = sourceCommit.associatedPullRequests.edges?.[0]?.node;
|
|
8
12
|
// use info from associated pull request if available. Fall back to commit info
|
|
9
13
|
const sourceBranch = sourcePullRequest?.baseRefName ?? options.sourceBranch;
|
|
10
|
-
const
|
|
14
|
+
const remoteConfig = sourceCommit.remoteConfigHistory.edges?.[0]?.remoteConfig;
|
|
15
|
+
const branchLabelMapping = remoteConfig
|
|
16
|
+
? (0, remoteConfig_1.parseRemoteConfig)(remoteConfig)?.branchLabelMapping ??
|
|
17
|
+
options.branchLabelMapping
|
|
18
|
+
: options.branchLabelMapping;
|
|
11
19
|
const expectedTargetPullRequests = (0, getExpectedTargetPullRequests_1.getExpectedTargetPullRequests)(sourceCommit, branchLabelMapping);
|
|
12
20
|
return {
|
|
13
21
|
sourceCommit: {
|
|
@@ -30,72 +38,72 @@ function parseSourceCommit({ sourceCommit, options, }) {
|
|
|
30
38
|
};
|
|
31
39
|
}
|
|
32
40
|
exports.parseSourceCommit = parseSourceCommit;
|
|
33
|
-
exports.sourceCommitWithTargetPullRequestFragment =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
exports.sourceCommitWithTargetPullRequestFragment = (0, graphql_tag_1.default) `
|
|
42
|
+
fragment SourceCommitWithTargetPullRequest on Commit {
|
|
43
|
+
...RemoteConfigHistory
|
|
44
|
+
|
|
45
|
+
# Source Commit
|
|
46
|
+
repository {
|
|
47
|
+
name
|
|
48
|
+
owner {
|
|
49
|
+
login
|
|
42
50
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
}
|
|
52
|
+
sha: oid
|
|
53
|
+
message
|
|
54
|
+
committedDate
|
|
46
55
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
56
|
+
# Source pull request: PR where source commit was merged in
|
|
57
|
+
associatedPullRequests(first: 1) {
|
|
58
|
+
edges {
|
|
59
|
+
node {
|
|
60
|
+
url
|
|
61
|
+
number
|
|
62
|
+
labels(first: 50) {
|
|
63
|
+
nodes {
|
|
64
|
+
name
|
|
57
65
|
}
|
|
58
|
-
|
|
66
|
+
}
|
|
67
|
+
baseRefName
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
# source merge commit (the commit that actually went into the source branch)
|
|
70
|
+
mergeCommit {
|
|
71
|
+
sha: oid
|
|
72
|
+
message
|
|
73
|
+
}
|
|
65
74
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
# (possible) backport pull requests referenced in the source pull request
|
|
76
|
+
timelineItems(last: 20, itemTypes: CROSS_REFERENCED_EVENT) {
|
|
77
|
+
edges {
|
|
78
|
+
node {
|
|
79
|
+
... on CrossReferencedEvent {
|
|
80
|
+
targetPullRequest: source {
|
|
81
|
+
__typename
|
|
73
82
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
83
|
+
# Target PRs (backport PRs)
|
|
84
|
+
... on PullRequest {
|
|
85
|
+
# target merge commit: the backport commit that was merged into the target branch
|
|
86
|
+
targetMergeCommit: mergeCommit {
|
|
87
|
+
sha: oid
|
|
88
|
+
message
|
|
89
|
+
}
|
|
90
|
+
repository {
|
|
91
|
+
name
|
|
92
|
+
owner {
|
|
93
|
+
login
|
|
86
94
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
}
|
|
96
|
+
url
|
|
97
|
+
title
|
|
98
|
+
state
|
|
99
|
+
baseRefName
|
|
100
|
+
number
|
|
101
|
+
commits(first: 20) {
|
|
102
|
+
edges {
|
|
103
|
+
node {
|
|
104
|
+
targetCommit: commit {
|
|
105
|
+
message
|
|
106
|
+
sha: oid
|
|
99
107
|
}
|
|
100
108
|
}
|
|
101
109
|
}
|
|
@@ -109,13 +117,7 @@ exports.sourceCommitWithTargetPullRequestFragment = {
|
|
|
109
117
|
}
|
|
110
118
|
}
|
|
111
119
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return branchLabelMapping;
|
|
117
|
-
}
|
|
118
|
-
const match = historicalBranchLabelMappings.find((branchLabelMapping) => sourceCommit.committedDate > branchLabelMapping.committedDate);
|
|
119
|
-
return (match?.branchLabelMapping ??
|
|
120
|
-
historicalBranchLabelMappings[0].branchLabelMapping);
|
|
121
|
-
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
${remoteConfig_1.RemoteConfigHistoryFragment}
|
|
123
|
+
`;
|
|
@@ -76,7 +76,6 @@ describe('parseSourceCommit', () => {
|
|
|
76
76
|
'^v6.4.0$': 'main',
|
|
77
77
|
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
78
78
|
},
|
|
79
|
-
historicalBranchLabelMappings: [],
|
|
80
79
|
},
|
|
81
80
|
});
|
|
82
81
|
expect(commit.expectedTargetPullRequests).toEqual([
|
|
@@ -105,6 +104,13 @@ describe('parseSourceCommit', () => {
|
|
|
105
104
|
it('uses the historical branchLabelMapping from 2021-02-02', () => {
|
|
106
105
|
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
107
106
|
sourceCommit: {
|
|
107
|
+
remoteConfig: {
|
|
108
|
+
branchLabelMapping: {
|
|
109
|
+
'^v6.3.0$': 'main',
|
|
110
|
+
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
111
|
+
},
|
|
112
|
+
committedDate: '2021-02-02T00:00:00Z',
|
|
113
|
+
},
|
|
108
114
|
message: 'My commit message (#66)',
|
|
109
115
|
commitedDate: '2021-03-03T00:00:00Z',
|
|
110
116
|
},
|
|
@@ -129,22 +135,6 @@ describe('parseSourceCommit', () => {
|
|
|
129
135
|
'^v6.4.0$': 'main',
|
|
130
136
|
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
131
137
|
},
|
|
132
|
-
historicalBranchLabelMappings: [
|
|
133
|
-
{
|
|
134
|
-
branchLabelMapping: {
|
|
135
|
-
'^v6.4.0$': 'main',
|
|
136
|
-
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
137
|
-
},
|
|
138
|
-
committedDate: '2021-04-04T00:00:00Z',
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
branchLabelMapping: {
|
|
142
|
-
'^v6.3.0$': 'main',
|
|
143
|
-
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
144
|
-
},
|
|
145
|
-
committedDate: '2021-02-02T00:00:00Z',
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
138
|
},
|
|
149
139
|
});
|
|
150
140
|
expect(commit.expectedTargetPullRequests).toEqual([
|
package/dist/test/nockHelpers.js
CHANGED
|
@@ -6,18 +6,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.listenForCallsToNockScope = exports.mockGqlRequest = void 0;
|
|
7
7
|
const url_1 = require("url");
|
|
8
8
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
9
|
+
const graphql_tag_2 = require("graphql-tag");
|
|
9
10
|
const nock_1 = __importDefault(require("nock"));
|
|
11
|
+
(0, graphql_tag_2.disableFragmentWarnings)();
|
|
10
12
|
function mockGqlRequest({ name, statusCode, body, headers, apiBaseUrl, }) {
|
|
11
13
|
const { origin, pathname } = new url_1.URL(
|
|
12
14
|
// default to localhost as host to avoid CORS issues
|
|
13
15
|
apiBaseUrl ?? 'http://localhost/graphql');
|
|
14
16
|
const scope = (0, nock_1.default)(origin)
|
|
15
|
-
.post(pathname, (body) =>
|
|
17
|
+
.post(pathname, (body) => {
|
|
18
|
+
return getQueryNameFromString(body.query) === name;
|
|
19
|
+
})
|
|
16
20
|
.reply(statusCode, body, headers);
|
|
17
21
|
return listenForCallsToNockScope(scope);
|
|
18
22
|
}
|
|
19
23
|
exports.mockGqlRequest = mockGqlRequest;
|
|
20
|
-
function
|
|
24
|
+
function getQueryNameFromString(query) {
|
|
21
25
|
const obj = (0, graphql_tag_1.default)(query);
|
|
22
26
|
// @ts-expect-error
|
|
23
27
|
return obj.definitions[0].name.value;
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.cherrypickAndCreateTargetPullRequest = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
|
-
const ora = require("ora");
|
|
10
9
|
const HandledError_1 = require("../services/HandledError");
|
|
11
10
|
const child_process_promisified_1 = require("../services/child-process-promisified");
|
|
12
11
|
const env_1 = require("../services/env");
|
|
@@ -21,6 +20,7 @@ const logger_1 = require("../services/logger");
|
|
|
21
20
|
const prompts_1 = require("../services/prompts");
|
|
22
21
|
const sequentially_1 = require("../services/sequentially");
|
|
23
22
|
const getCommitsWithoutBackports_1 = require("./getCommitsWithoutBackports");
|
|
23
|
+
const ora_1 = require("./ora");
|
|
24
24
|
async function cherrypickAndCreateTargetPullRequest({ options, commits, targetBranch, }) {
|
|
25
25
|
const backportBranch = getBackportBranchName(targetBranch, commits);
|
|
26
26
|
const repoForkOwner = (0, git_1.getRepoForkOwner)(options);
|
|
@@ -103,7 +103,7 @@ function getBackportBranchName(targetBranch, commits) {
|
|
|
103
103
|
async function waitForCherrypick(options, commit, targetBranch) {
|
|
104
104
|
const spinnerText = `Cherry-picking: ${chalk_1.default.greenBright((0, commitFormatters_1.getFirstLine)(commit.sourceCommit.message))}`;
|
|
105
105
|
const mergedTargetPullRequest = commit.expectedTargetPullRequests.find((pr) => pr.state === 'MERGED' && pr.branch === targetBranch);
|
|
106
|
-
const cherrypickSpinner = ora(spinnerText).start();
|
|
106
|
+
const cherrypickSpinner = (0, ora_1.ora)(options.ci, spinnerText).start();
|
|
107
107
|
let conflictingFiles;
|
|
108
108
|
let unstagedFiles;
|
|
109
109
|
let needsResolving;
|
|
@@ -124,7 +124,7 @@ async function waitForCherrypick(options, commit, targetBranch) {
|
|
|
124
124
|
}
|
|
125
125
|
// resolve conflicts automatically
|
|
126
126
|
if (options.autoFixConflicts) {
|
|
127
|
-
const autoResolveSpinner = ora('Attempting to resolve conflicts automatically').start();
|
|
127
|
+
const autoResolveSpinner = (0, ora_1.ora)(options.ci, 'Attempting to resolve conflicts automatically').start();
|
|
128
128
|
const repoPath = (0, env_1.getRepoPath)(options);
|
|
129
129
|
const didAutoFix = await options.autoFixConflicts({
|
|
130
130
|
files: conflictingFiles.map((f) => f.absolute),
|
|
@@ -171,7 +171,7 @@ async function waitForCherrypick(options, commit, targetBranch) {
|
|
|
171
171
|
unstagedFiles,
|
|
172
172
|
});
|
|
173
173
|
// Conflicts should be resolved and files staged at this point
|
|
174
|
-
const stagingSpinner = ora(`Finalizing cherrypick`).start();
|
|
174
|
+
const stagingSpinner = (0, ora_1.ora)(options.ci, `Finalizing cherrypick`).start();
|
|
175
175
|
try {
|
|
176
176
|
// Run `git commit`
|
|
177
177
|
await (0, git_1.commitChanges)(commit, options);
|
package/dist/ui/getCommits.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getCommits = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const ora_1 = __importDefault(require("ora"));
|
|
9
8
|
const HandledError_1 = require("../services/HandledError");
|
|
10
9
|
const commitFormatters_1 = require("../services/github/commitFormatters");
|
|
11
10
|
const fetchCommitByPullNumber_1 = require("../services/github/v4/fetchCommits/fetchCommitByPullNumber");
|
|
@@ -13,6 +12,7 @@ const fetchCommitBySha_1 = require("../services/github/v4/fetchCommits/fetchComm
|
|
|
13
12
|
const fetchCommitsByAuthor_1 = require("../services/github/v4/fetchCommits/fetchCommitsByAuthor");
|
|
14
13
|
const fetchPullRequestBySearchQuery_1 = require("../services/github/v4/fetchCommits/fetchPullRequestBySearchQuery");
|
|
15
14
|
const prompts_1 = require("../services/prompts");
|
|
15
|
+
const ora_1 = require("./ora");
|
|
16
16
|
function getOraPersistsOption(question, answer) {
|
|
17
17
|
return {
|
|
18
18
|
symbol: chalk_1.default.green('?'),
|
|
@@ -20,7 +20,7 @@ function getOraPersistsOption(question, answer) {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
async function getCommits(options) {
|
|
23
|
-
const spinner = (0, ora_1.
|
|
23
|
+
const spinner = (0, ora_1.ora)(options.ci).start();
|
|
24
24
|
try {
|
|
25
25
|
if (options.sha) {
|
|
26
26
|
spinner.text = `Loading commit "${(0, commitFormatters_1.getShortSha)(options.sha)}"`;
|
package/dist/ui/ora.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import oraOriginal from 'ora';
|
|
2
|
+
export declare function ora(ci: boolean | undefined, options?: string | oraOriginal.Options | undefined): oraOriginal.Ora | {
|
|
3
|
+
start: (text?: string | undefined) => any;
|
|
4
|
+
succeed: () => void;
|
|
5
|
+
stop: () => void;
|
|
6
|
+
fail: () => void;
|
|
7
|
+
stopAndPersist: () => void;
|
|
8
|
+
text: string;
|
|
9
|
+
};
|