backport 7.4.0 → 8.0.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/README.md +12 -13
- package/dist/backportRun.d.ts +8 -3
- package/dist/backportRun.js +54 -42
- package/dist/entrypoint.cli.js +1 -1
- package/dist/entrypoint.module.d.ts +8 -3
- package/dist/entrypoint.module.js +3 -11
- package/dist/entrypoint.module.private.test.js +47 -346
- package/dist/options/cliArgs.d.ts +9 -4
- package/dist/options/cliArgs.js +28 -15
- package/dist/options/cliArgs.test.js +3 -3
- package/dist/options/config/globalConfig.d.ts +2 -2
- package/dist/options/config/globalConfig.js +13 -10
- package/dist/options/config/readConfigFile.d.ts +2 -2
- package/dist/options/options.d.ts +3 -3
- package/dist/options/options.test.js +5 -1
- package/dist/runSequentially.d.ts +6 -2
- package/dist/runSequentially.js +23 -7
- package/dist/scripts/postinstall.js +1 -0
- package/dist/scripts/postinstall.test.js +5 -1
- package/dist/services/HandledError.d.ts +1 -1
- package/dist/services/HandledError.js +2 -2
- package/dist/services/child-process-promisified.d.ts +19 -3
- package/dist/services/child-process-promisified.js +46 -17
- package/dist/services/git.d.ts +6 -7
- package/dist/services/git.integration.test.js +381 -65
- package/dist/services/git.js +188 -122
- package/dist/services/git.private.test.d.ts +1 -0
- package/dist/services/git.private.test.js +618 -0
- package/dist/services/git.test.js +167 -124
- package/dist/services/github/v3/addAssigneesToPullRequest.js +1 -1
- package/dist/services/github/v3/addLabelsToPullRequest.js +1 -1
- package/dist/services/github/v3/addReviewersToPullRequest.js +2 -1
- package/dist/services/github/v3/createPullRequest.js +3 -1
- package/dist/services/github/v3/createStatusComment.js +14 -15
- package/dist/services/github/v3/createStatusComment.test.js +15 -5
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +2 -4
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +5 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +5 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +5 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +1 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +5 -1
- package/dist/services/logger.js +5 -1
- package/dist/services/test.d.ts +1 -0
- package/dist/services/test.js +23 -0
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +194 -12
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +17 -16
- package/dist/test/e2e/cli/runBackportViaCli.d.ts +2 -1
- package/dist/test/e2e/cli/runBackportViaCli.js +10 -2
- package/dist/test/e2e/module/entrypoint.module.mutation.test.js +26 -19
- package/dist/test/handleUnbackportedPullRequests.private.test.js +10 -8
- package/dist/test/sandbox.js +5 -1
- package/dist/test/setupFiles/automatic-mocks.js +5 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +1 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +7 -159
- package/dist/ui/getCommitsWithoutBackports.test.js +5 -1
- package/dist/ui/getGitConfigAuthor.js +1 -1
- package/dist/ui/getTargetBranches.test.js +5 -1
- package/dist/ui/ora.d.ts +1 -8
- package/dist/ui/setupRepo.js +1 -1
- package/dist/ui/setupRepo.test.js +98 -61
- package/dist/utils/isErrnoError.d.ts +2 -0
- package/dist/utils/isErrnoError.js +7 -0
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +13 -13
- package/yarn.lock +414 -695
|
@@ -4,9 +4,9 @@ export declare function getOptions(processArgs: string[], optionsFromModule: Con
|
|
|
4
4
|
accessToken: string;
|
|
5
5
|
repoName: string;
|
|
6
6
|
repoOwner: string;
|
|
7
|
+
cwd: string;
|
|
7
8
|
fork: boolean;
|
|
8
9
|
dir?: string | undefined;
|
|
9
|
-
logFilePath?: string | undefined;
|
|
10
10
|
author: string | null;
|
|
11
11
|
autoAssign: boolean;
|
|
12
12
|
assignees: string[];
|
|
@@ -24,6 +24,7 @@ export declare function getOptions(processArgs: string[], optionsFromModule: Con
|
|
|
24
24
|
githubApiBaseUrlV4?: string | undefined;
|
|
25
25
|
gitAuthorName?: string | undefined;
|
|
26
26
|
gitAuthorEmail?: string | undefined;
|
|
27
|
+
logFilePath?: string | undefined;
|
|
27
28
|
ls?: boolean | undefined;
|
|
28
29
|
mainline?: number | undefined;
|
|
29
30
|
maxNumber: number;
|
|
@@ -44,7 +45,7 @@ export declare function getOptions(processArgs: string[], optionsFromModule: Con
|
|
|
44
45
|
commitPaths: string[];
|
|
45
46
|
reviewers: string[];
|
|
46
47
|
sourcePRLabels: string[];
|
|
47
|
-
targetBranchChoices:
|
|
48
|
+
targetBranchChoices: TargetBranchChoiceOrString[];
|
|
48
49
|
targetBranches: string[];
|
|
49
50
|
targetPRLabels: string[];
|
|
50
51
|
publishStatusComment: boolean;
|
|
@@ -64,5 +65,4 @@ export declare function getOptions(processArgs: string[], optionsFromModule: Con
|
|
|
64
65
|
branches?: TargetBranchChoiceOrString[] | undefined;
|
|
65
66
|
labels?: string[] | undefined;
|
|
66
67
|
authenticatedUsername: string;
|
|
67
|
-
cwd: string;
|
|
68
68
|
}>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -9,9 +9,13 @@ export declare type Result = {
|
|
|
9
9
|
pullRequestUrl: string;
|
|
10
10
|
pullRequestNumber: number;
|
|
11
11
|
} | {
|
|
12
|
-
status: '
|
|
12
|
+
status: 'handled-error';
|
|
13
13
|
targetBranch: string;
|
|
14
|
-
error: HandledError
|
|
14
|
+
error: HandledError;
|
|
15
|
+
} | {
|
|
16
|
+
status: 'unhandled-error';
|
|
17
|
+
targetBranch: string;
|
|
18
|
+
error: Error;
|
|
15
19
|
};
|
|
16
20
|
export declare function runSequentially({ options, commits, targetBranches, gitConfigAuthor, }: {
|
|
17
21
|
options: ValidConfigOptions;
|
package/dist/runSequentially.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runSequentially = void 0;
|
|
4
|
+
const HandledError_1 = require("./services/HandledError");
|
|
4
5
|
const logger_1 = require("./services/logger");
|
|
5
6
|
const sequentially_1 = require("./services/sequentially");
|
|
6
7
|
const cherrypickAndCreateTargetPullRequest_1 = require("./ui/cherrypickAndCreateTargetPullRequest");
|
|
@@ -25,13 +26,28 @@ async function runSequentially({ options, commits, targetBranches, gitConfigAuth
|
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
catch (e) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
const isHandledError = e instanceof HandledError_1.HandledError;
|
|
30
|
+
if (isHandledError) {
|
|
31
|
+
results.push({
|
|
32
|
+
targetBranch,
|
|
33
|
+
status: 'handled-error',
|
|
34
|
+
error: e,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
else if (e instanceof Error) {
|
|
38
|
+
results.push({
|
|
39
|
+
targetBranch,
|
|
40
|
+
status: 'unhandled-error',
|
|
41
|
+
error: e,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
(0, logger_1.consoleLog)(isHandledError
|
|
48
|
+
? e.message
|
|
49
|
+
: 'An error occurred while backporting commit. Please see the logs for details');
|
|
50
|
+
logger_1.logger.error('runSequentially failed', e);
|
|
35
51
|
}
|
|
36
52
|
});
|
|
37
53
|
// return the results for consumers to programatically read
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -9,14 +9,14 @@ function getMessage(errorContext) {
|
|
|
9
9
|
return 'There are no branches to backport to. Aborting.';
|
|
10
10
|
case 'abort-exception':
|
|
11
11
|
return 'Aborted';
|
|
12
|
-
case '
|
|
12
|
+
case 'message-only-exception':
|
|
13
13
|
return errorContext.message;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
class HandledError extends Error {
|
|
17
17
|
constructor(errorContextOrString) {
|
|
18
18
|
const errorContext = typeof errorContextOrString === 'string'
|
|
19
|
-
? { code: '
|
|
19
|
+
? { code: 'message-only-exception', message: errorContextOrString }
|
|
20
20
|
: errorContextOrString;
|
|
21
21
|
const message = getMessage(errorContext);
|
|
22
22
|
super(message);
|
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
3
|
-
export declare function exec(cmd: string, options:
|
|
2
|
+
import childProcess from 'child_process';
|
|
3
|
+
export declare function exec(cmd: string, options: childProcess.ExecOptions & {
|
|
4
4
|
cwd: string;
|
|
5
5
|
}): Promise<{
|
|
6
6
|
stdout: string;
|
|
7
7
|
stderr: string;
|
|
8
8
|
}>;
|
|
9
|
-
export declare
|
|
9
|
+
export declare function spawnPromise(cmd: string, cmdArgs: string[], cwd: string): Promise<{
|
|
10
|
+
cmdArgs: string[];
|
|
11
|
+
code: number | null;
|
|
12
|
+
stderr: string;
|
|
13
|
+
stdout: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const spawnOriginal: typeof childProcess.spawn;
|
|
16
|
+
export declare type SpawnErrorContext = {
|
|
17
|
+
cmdArgs: string[];
|
|
18
|
+
code: number;
|
|
19
|
+
stderr: string;
|
|
20
|
+
stdout: string;
|
|
21
|
+
};
|
|
22
|
+
export declare class SpawnError extends Error {
|
|
23
|
+
context: SpawnErrorContext;
|
|
24
|
+
constructor(context: SpawnErrorContext);
|
|
25
|
+
}
|
|
@@ -3,27 +3,56 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.SpawnError = exports.spawnOriginal = exports.spawnPromise = exports.exec = void 0;
|
|
7
7
|
const child_process_1 = __importDefault(require("child_process"));
|
|
8
8
|
const util_1 = require("util");
|
|
9
9
|
const logger_1 = require("./logger");
|
|
10
|
+
const execPromisified = (0, util_1.promisify)(child_process_1.default.exec);
|
|
10
11
|
async function exec(cmd, options) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const res = await execPromisified(cmd, {
|
|
13
|
+
maxBuffer: 100 * 1024 * 1024,
|
|
14
|
+
...options,
|
|
15
|
+
});
|
|
16
|
+
return res;
|
|
17
|
+
}
|
|
18
|
+
exports.exec = exec;
|
|
19
|
+
async function spawnPromise(cmd, cmdArgs, cwd) {
|
|
20
|
+
return new Promise(function (resolve, reject) {
|
|
21
|
+
const subprocess = child_process_1.default.spawn(cmd, cmdArgs, { cwd });
|
|
22
|
+
let stderr = '';
|
|
23
|
+
let stdout = '';
|
|
24
|
+
subprocess.stdout.on('data', (data) => {
|
|
25
|
+
stdout += data;
|
|
16
26
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
subprocess.stderr.on('data', (data) => {
|
|
28
|
+
stderr += data;
|
|
29
|
+
});
|
|
30
|
+
subprocess.on('close', (code) => {
|
|
31
|
+
if (code === 0 || code === null) {
|
|
32
|
+
logger_1.logger.verbose(`spawn success "${cmdArgs}"`);
|
|
33
|
+
resolve({ cmdArgs, code, stderr, stdout });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const err = new SpawnError({ cmdArgs, code, stderr, stdout });
|
|
37
|
+
logger_1.logger.info('spawn error', err);
|
|
38
|
+
reject(err);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
subprocess.on('error', (err) => {
|
|
42
|
+
reject(err);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
exports.spawnPromise = spawnPromise;
|
|
47
|
+
exports.spawnOriginal = child_process_1.default.spawn;
|
|
48
|
+
class SpawnError extends Error {
|
|
49
|
+
constructor(context) {
|
|
50
|
+
const message = `Code: ${context.code}; Args: ${JSON.stringify(context.cmdArgs)}; ${context.stderr.trim()}`;
|
|
51
|
+
super(message);
|
|
52
|
+
Error.captureStackTrace(this, SpawnError);
|
|
53
|
+
this.name = 'SpawnError';
|
|
54
|
+
this.message = message;
|
|
55
|
+
this.context = context;
|
|
23
56
|
}
|
|
24
57
|
}
|
|
25
|
-
exports.
|
|
26
|
-
const execAsCallback = (...args) => {
|
|
27
|
-
return child_process_1.default.exec(...args);
|
|
28
|
-
};
|
|
29
|
-
exports.execAsCallback = execAsCallback;
|
|
58
|
+
exports.SpawnError = SpawnError;
|
package/dist/services/git.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare function isLocalConfigFileUntracked({ cwd }: {
|
|
|
14
14
|
}): Promise<boolean | undefined>;
|
|
15
15
|
export declare function isLocalConfigFileModified({ cwd }: {
|
|
16
16
|
cwd: string;
|
|
17
|
-
}): Promise<boolean
|
|
17
|
+
}): Promise<boolean>;
|
|
18
18
|
export declare function getRepoInfoFromGitRemotes({ cwd }: {
|
|
19
19
|
cwd: string;
|
|
20
20
|
}): Promise<{
|
|
@@ -59,10 +59,7 @@ export declare function createBackportBranch({ options, targetBranch, backportBr
|
|
|
59
59
|
options: ValidConfigOptions;
|
|
60
60
|
targetBranch: string;
|
|
61
61
|
backportBranch: string;
|
|
62
|
-
}): Promise<
|
|
63
|
-
stdout: string;
|
|
64
|
-
stderr: string;
|
|
65
|
-
}>;
|
|
62
|
+
}): Promise<void>;
|
|
66
63
|
export declare function deleteBackportBranch({ options, backportBranch, }: {
|
|
67
64
|
options: ValidConfigOptions;
|
|
68
65
|
backportBranch: string;
|
|
@@ -72,7 +69,9 @@ export declare function pushBackportBranch({ options, backportBranch, }: {
|
|
|
72
69
|
options: ValidConfigOptions;
|
|
73
70
|
backportBranch: string;
|
|
74
71
|
}): Promise<{
|
|
75
|
-
|
|
72
|
+
cmdArgs: string[];
|
|
73
|
+
code: number | null;
|
|
76
74
|
stderr: string;
|
|
75
|
+
stdout: string;
|
|
77
76
|
}>;
|
|
78
|
-
export declare function
|
|
77
|
+
export declare function getLocalSourceRepoPath(options: ValidConfigOptions): Promise<string | undefined>;
|