backport 6.1.4 → 6.1.5
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 +39 -37
- package/dist/entrypoint.module.d.ts +2 -1
- package/dist/entrypoint.module.js +5 -3
- package/dist/main.js +4 -0
- package/dist/options/ConfigOptions.d.ts +2 -0
- package/dist/options/cliArgs.d.ts +3 -1
- package/dist/options/cliArgs.js +10 -1
- package/dist/options/config/config.d.ts +6 -1
- package/dist/options/config/config.js +2 -2
- package/dist/options/config/config.test.js +1 -1
- package/dist/options/config/globalConfig.d.ts +1 -1
- package/dist/options/config/globalConfig.js +3 -7
- package/dist/options/config/readConfigFile.d.ts +3 -1
- package/dist/options/options.d.ts +4 -1
- package/dist/options/options.js +6 -1
- package/dist/services/env.d.ts +2 -3
- package/dist/services/env.js +9 -10
- package/dist/services/env.test.js +0 -6
- package/dist/services/git.js +1 -1
- package/dist/services/github/v3/createStatusComment.js +9 -4
- package/dist/services/github/v4/fetchProjectConfig.d.ts +1 -1
- package/dist/services/github/v4/fetchProjectConfig.js +3 -3
- package/dist/services/github/v4/fetchProjectConfig.private.test.js +5 -5
- package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +8 -0
- package/dist/services/github/v4/fetchRemoteProjectConfig.js +56 -0
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +52 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +2 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +0 -7
- package/dist/services/logger.d.ts +0 -1
- package/dist/services/logger.js +3 -3
- package/dist/todo-delete.d.ts +1 -0
- package/dist/todo-delete.js +17 -0
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +1 -1
- package/dist/ui/maybeSetupRepo.js +0 -6
- package/dist/utils/redact.d.ts +1 -0
- package/dist/utils/redact.js +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,42 +67,44 @@ See [configuration.md](https://github.com/sqren/backport/blob/master/docs/config
|
|
|
67
67
|
|
|
68
68
|
### CLI options
|
|
69
69
|
|
|
70
|
-
| Option | Shorthand notation | Description
|
|
71
|
-
| ------------------- | ------------------ |
|
|
72
|
-
| --access-token | | Github access token
|
|
73
|
-
| --all | -a | Show commits from any author
|
|
74
|
-
| --assignee | --assign | Assign users to the target PR
|
|
75
|
-
| --author | | Filter commits by Github username. Opposite of `--all`
|
|
76
|
-
| --auto-assign | | Assign current user to the target PR
|
|
77
|
-
| --branch | -b | Target branch to backport to
|
|
78
|
-
| --ci | | Disable interactive prompts
|
|
79
|
-
| --
|
|
80
|
-
| --
|
|
81
|
-
| --
|
|
82
|
-
| --
|
|
83
|
-
| --
|
|
84
|
-
| --
|
|
85
|
-
| --
|
|
86
|
-
| --multiple
|
|
87
|
-
| --multiple-
|
|
88
|
-
| --
|
|
89
|
-
| --no-
|
|
90
|
-
| --
|
|
91
|
-
| --
|
|
92
|
-
| --
|
|
93
|
-
| --pr-
|
|
94
|
-
| --
|
|
95
|
-
| --
|
|
96
|
-
| --
|
|
97
|
-
| --
|
|
98
|
-
| --
|
|
99
|
-
| --
|
|
100
|
-
| --
|
|
101
|
-
| --
|
|
102
|
-
| --
|
|
103
|
-
| --
|
|
104
|
-
| --
|
|
105
|
-
| -
|
|
70
|
+
| Option | Shorthand notation | Description | Default |
|
|
71
|
+
| ------------------- | ------------------ | -------------------------------------------------------------------------- | ------------------------- |
|
|
72
|
+
| --access-token | | Github access token | |
|
|
73
|
+
| --all | -a | Show commits from any author | false |
|
|
74
|
+
| --assignee | --assign | Assign users to the target PR | |
|
|
75
|
+
| --author | | Filter commits by Github username. Opposite of `--all` | _Current user_ |
|
|
76
|
+
| --auto-assign | | Assign current user to the target PR | false |
|
|
77
|
+
| --branch | -b | Target branch to backport to | |
|
|
78
|
+
| --ci | | Disable interactive prompts | false |
|
|
79
|
+
| --dir | | Clone repository into custom directory | ~/.backport/repositories/ |
|
|
80
|
+
| --dry-run | | Perform backport without pushing to Github | false |
|
|
81
|
+
| --editor | | Editor (eg. `code`) to open and resolve conflicts | nano |
|
|
82
|
+
| --fork | | Create backports in fork repo | true |
|
|
83
|
+
| --git-hostname | | Hostname for Git | github.com |
|
|
84
|
+
| --mainline | | Parent id of merge commit | 1 |
|
|
85
|
+
| --max-number | --number, -n | Number of commits to choose from | 10 |
|
|
86
|
+
| --multiple | | Multi-select for commits and branches | false |
|
|
87
|
+
| --multiple-branches | | Multi-select for branches | true |
|
|
88
|
+
| --multiple-commits | | Multi-select for commits | false |
|
|
89
|
+
| --no-cherrypick-ref | | Do not append "(cherry picked from commit...)". [Git Docs][1] | false |
|
|
90
|
+
| --no-status-comment | | Do not publish a status comment to Github with the results of the backport | false |
|
|
91
|
+
| --no-verify | | Bypass the pre-commit and commit-msg hooks | false |
|
|
92
|
+
| --path | -p | Filter commits by path | |
|
|
93
|
+
| --pr-description | --description | Pull request description suffix | |
|
|
94
|
+
| --pr-filter | | Find PRs using [Github's search syntax][2] | |
|
|
95
|
+
| --pr-title | --title | Title of pull request | |
|
|
96
|
+
| --pull-number | --pr | Backport pull request by number | |
|
|
97
|
+
| --repo-name | | Name of repository | |
|
|
98
|
+
| --repo-owner | | Owner of repository | |
|
|
99
|
+
| --reset-author | | Set yourself as commit author | |
|
|
100
|
+
| --reviewer | | Add reviewer to the target PR | |
|
|
101
|
+
| --sha | | Sha of commit to backport | |
|
|
102
|
+
| --source-branch | | Specify a non-default branch to backport from | |
|
|
103
|
+
| --source-pr-label | | Labels added to the source PR | |
|
|
104
|
+
| --target-branch | -b | Target branch(es) to backport to | |
|
|
105
|
+
| --target-pr-label | --label, -l | Labels added to the target PR | |
|
|
106
|
+
| --help | | Show help | |
|
|
107
|
+
| -v, --version | | Show version number | |
|
|
106
108
|
|
|
107
109
|
The CLI options will override the [configuration options](https://github.com/sqren/backport/blob/master/docs/configuration.md).
|
|
108
110
|
|
|
@@ -238,7 +240,7 @@ This tools is for anybody who is working on a codebase where they have to mainta
|
|
|
238
240
|
- ability to see which commits have been backported and to which branches
|
|
239
241
|
- ability to customize the title, description and labels of the created backport PRs
|
|
240
242
|
- all git operations are handled in a separate directory to not interfere with unstaged files
|
|
241
|
-
- Conflicts are handled gracefully, and hints are provided to help the user understand the source of the conflict
|
|
243
|
+
- Conflicts are handled gracefully, and hints are provided to help the user understand the source of the conflict
|
|
242
244
|
- backport a commit by specifying a PR: `backport --pr 1337`
|
|
243
245
|
- list and backport commits by a particular user: `backport --author john`
|
|
244
246
|
- list and backport commits by a particular path: `backport --path src/plugins/chatbot`
|
|
@@ -3,7 +3,8 @@ import { ValidConfigOptions } from './options/options';
|
|
|
3
3
|
export { BackportResponse } from './main';
|
|
4
4
|
export { ConfigFileOptions } from './options/ConfigOptions';
|
|
5
5
|
export { Commit } from './services/sourceCommit/parseSourceCommit';
|
|
6
|
-
export {
|
|
6
|
+
export { fetchRemoteProjectConfig as getRemoteProjectConfig } from './services/github/v4/fetchRemoteProjectConfig';
|
|
7
|
+
export { getGlobalConfig as getLocalGlobalConfig } from './options/config/globalConfig';
|
|
7
8
|
export declare function backportRun(options: ConfigFileOptions, args?: string[]): Promise<import("./main").BackportResponse>;
|
|
8
9
|
export declare function getCommits(options: {
|
|
9
10
|
accessToken: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCommits = exports.backportRun = exports.
|
|
3
|
+
exports.getCommits = exports.backportRun = exports.getLocalGlobalConfig = exports.getRemoteProjectConfig = void 0;
|
|
4
4
|
const main_1 = require("./main");
|
|
5
5
|
const fetchCommitByPullNumber_1 = require("./services/github/v4/fetchCommits/fetchCommitByPullNumber");
|
|
6
6
|
const fetchCommitBySha_1 = require("./services/github/v4/fetchCommits/fetchCommitBySha");
|
|
@@ -9,8 +9,10 @@ const getOptionsFromGithub_1 = require("./services/github/v4/getOptionsFromGithu
|
|
|
9
9
|
const logger_1 = require("./services/logger");
|
|
10
10
|
const excludeUndefined_1 = require("./utils/excludeUndefined");
|
|
11
11
|
(0, logger_1.initLogger)();
|
|
12
|
-
var
|
|
13
|
-
Object.defineProperty(exports, "
|
|
12
|
+
var fetchRemoteProjectConfig_1 = require("./services/github/v4/fetchRemoteProjectConfig");
|
|
13
|
+
Object.defineProperty(exports, "getRemoteProjectConfig", { enumerable: true, get: function () { return fetchRemoteProjectConfig_1.fetchRemoteProjectConfig; } });
|
|
14
|
+
var globalConfig_1 = require("./options/config/globalConfig");
|
|
15
|
+
Object.defineProperty(exports, "getLocalGlobalConfig", { enumerable: true, get: function () { return globalConfig_1.getGlobalConfig; } });
|
|
14
16
|
function backportRun(options,
|
|
15
17
|
// cli args will not automatically be forwarded when it is consumed as a module
|
|
16
18
|
// It is simple to forward args manually via `process.argv`:
|
package/dist/main.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.main = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const ora_1 = __importDefault(require("ora"));
|
|
8
9
|
const options_1 = require("./options/options");
|
|
9
10
|
const runSequentially_1 = require("./runSequentially");
|
|
10
11
|
const HandledError_1 = require("./services/HandledError");
|
|
@@ -14,10 +15,12 @@ const logger_1 = require("./services/logger");
|
|
|
14
15
|
const getCommits_1 = require("./ui/getCommits");
|
|
15
16
|
const getTargetBranches_1 = require("./ui/getTargetBranches");
|
|
16
17
|
async function main(argv, optionsFromModule) {
|
|
18
|
+
const spinner = (0, ora_1.default)().start('Initializing...');
|
|
17
19
|
let options = null;
|
|
18
20
|
let commits = [];
|
|
19
21
|
try {
|
|
20
22
|
options = await (0, options_1.getOptions)(argv, optionsFromModule);
|
|
23
|
+
spinner.stop();
|
|
21
24
|
commits = await (0, getCommits_1.getCommits)(options);
|
|
22
25
|
const targetBranches = await (0, getTargetBranches_1.getTargetBranches)(options, commits);
|
|
23
26
|
const results = await (0, runSequentially_1.runSequentially)({ options, commits, targetBranches });
|
|
@@ -33,6 +36,7 @@ async function main(argv, optionsFromModule) {
|
|
|
33
36
|
return backportResponse;
|
|
34
37
|
}
|
|
35
38
|
catch (e) {
|
|
39
|
+
spinner.stop();
|
|
36
40
|
const backportResponse = {
|
|
37
41
|
status: 'failure',
|
|
38
42
|
commits,
|
|
@@ -22,6 +22,7 @@ declare type Options = Partial<{
|
|
|
22
22
|
cherrypickRef: boolean;
|
|
23
23
|
ci: boolean;
|
|
24
24
|
commitPaths: string[];
|
|
25
|
+
dir: string;
|
|
25
26
|
details: boolean;
|
|
26
27
|
editor: string;
|
|
27
28
|
fork: boolean;
|
|
@@ -36,6 +37,7 @@ declare type Options = Partial<{
|
|
|
36
37
|
prDescription: string;
|
|
37
38
|
prFilter: string;
|
|
38
39
|
prTitle: string;
|
|
40
|
+
publishStatusComment: boolean;
|
|
39
41
|
pullNumber: number;
|
|
40
42
|
repoName: string;
|
|
41
43
|
repoOwner: string;
|
|
@@ -3,7 +3,9 @@ export declare function getOptionsFromCliArgs(argv: readonly string[], { exitOnE
|
|
|
3
3
|
exitOnError?: boolean;
|
|
4
4
|
}): {
|
|
5
5
|
fork?: boolean | undefined;
|
|
6
|
+
dir?: string | undefined;
|
|
6
7
|
verbose?: boolean | undefined;
|
|
8
|
+
ci?: boolean | undefined;
|
|
7
9
|
accessToken?: string | undefined;
|
|
8
10
|
assignees?: string[] | undefined;
|
|
9
11
|
author?: string | null | undefined;
|
|
@@ -11,7 +13,6 @@ export declare function getOptionsFromCliArgs(argv: readonly string[], { exitOnE
|
|
|
11
13
|
autoMerge?: boolean | undefined;
|
|
12
14
|
autoMergeMethod?: string | undefined;
|
|
13
15
|
cherrypickRef?: boolean | undefined;
|
|
14
|
-
ci?: boolean | undefined;
|
|
15
16
|
commitPaths?: string[] | undefined;
|
|
16
17
|
details?: boolean | undefined;
|
|
17
18
|
editor?: string | undefined;
|
|
@@ -25,6 +26,7 @@ export declare function getOptionsFromCliArgs(argv: readonly string[], { exitOnE
|
|
|
25
26
|
prDescription?: string | undefined;
|
|
26
27
|
prFilter?: string | undefined;
|
|
27
28
|
prTitle?: string | undefined;
|
|
29
|
+
publishStatusComment?: boolean | undefined;
|
|
28
30
|
pullNumber?: number | undefined;
|
|
29
31
|
repoName?: string | undefined;
|
|
30
32
|
repoOwner?: string | undefined;
|
package/dist/options/cliArgs.js
CHANGED
|
@@ -64,6 +64,10 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
64
64
|
.option('until', {
|
|
65
65
|
description: 'ISO-8601 date for filtering commits',
|
|
66
66
|
type: 'string',
|
|
67
|
+
})
|
|
68
|
+
.option('dir', {
|
|
69
|
+
description: 'Location where the temporary repository will be stored',
|
|
70
|
+
type: 'string',
|
|
67
71
|
})
|
|
68
72
|
.option('details', {
|
|
69
73
|
description: 'Show details about each commit',
|
|
@@ -143,6 +147,10 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
143
147
|
description: 'Do not append commit message with "(cherry picked from commit...)"',
|
|
144
148
|
type: 'boolean',
|
|
145
149
|
conflicts: ['cherrypickRef'],
|
|
150
|
+
})
|
|
151
|
+
.option('noStatusComment', {
|
|
152
|
+
description: "Don't publish status comment to Github",
|
|
153
|
+
type: 'boolean',
|
|
146
154
|
})
|
|
147
155
|
.option('noVerify', {
|
|
148
156
|
description: 'Bypass the pre-commit and commit-msg hooks',
|
|
@@ -268,7 +276,7 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
268
276
|
// filters
|
|
269
277
|
author, since, until,
|
|
270
278
|
// negations
|
|
271
|
-
|
|
279
|
+
noCherrypickRef, noFork, noStatusComment, noVerify, verify,
|
|
272
280
|
// array types (should be renamed to plural form)
|
|
273
281
|
assignee, path, reviewer, sourcePRLabel, targetBranch, targetBranchChoice, targetPRLabel, ...restOptions } = yargsInstance.parseSync();
|
|
274
282
|
return (0, excludeUndefined_1.excludeUndefined)({
|
|
@@ -292,6 +300,7 @@ function getOptionsFromCliArgs(argv, { exitOnError = true } = {}) {
|
|
|
292
300
|
cherrypickRef: noCherrypickRef === true ? false : restOptions.cherrypickRef,
|
|
293
301
|
fork: noFork === true ? false : restOptions.fork,
|
|
294
302
|
noVerify: verify ?? noVerify,
|
|
303
|
+
publishStatusComment: noStatusComment === true ? false : undefined,
|
|
295
304
|
});
|
|
296
305
|
}
|
|
297
306
|
exports.getOptionsFromCliArgs = getOptionsFromCliArgs;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { ConfigFileOptions } from '../ConfigOptions';
|
|
2
2
|
export declare type OptionsFromConfigFiles = Awaited<ReturnType<typeof getOptionsFromConfigFiles>>;
|
|
3
|
-
export declare function getOptionsFromConfigFiles(optionsFromModule
|
|
3
|
+
export declare function getOptionsFromConfigFiles({ optionsFromModule, ci, }: {
|
|
4
|
+
optionsFromModule?: ConfigFileOptions;
|
|
5
|
+
ci: boolean;
|
|
6
|
+
}): Promise<{
|
|
4
7
|
accessToken?: string | undefined;
|
|
5
8
|
assignees?: string[] | undefined;
|
|
6
9
|
author?: string | null | undefined;
|
|
@@ -23,6 +26,7 @@ export declare function getOptionsFromConfigFiles(optionsFromModule?: ConfigFile
|
|
|
23
26
|
cherrypickRef?: boolean | undefined;
|
|
24
27
|
ci?: boolean | undefined;
|
|
25
28
|
commitPaths?: string[] | undefined;
|
|
29
|
+
dir?: string | undefined;
|
|
26
30
|
details?: boolean | undefined;
|
|
27
31
|
editor?: string | undefined;
|
|
28
32
|
fork?: boolean | undefined;
|
|
@@ -37,6 +41,7 @@ export declare function getOptionsFromConfigFiles(optionsFromModule?: ConfigFile
|
|
|
37
41
|
prDescription?: string | undefined;
|
|
38
42
|
prFilter?: string | undefined;
|
|
39
43
|
prTitle?: string | undefined;
|
|
44
|
+
publishStatusComment?: boolean | undefined;
|
|
40
45
|
pullNumber?: number | undefined;
|
|
41
46
|
repoName?: string | undefined;
|
|
42
47
|
repoOwner?: string | undefined;
|
|
@@ -4,11 +4,11 @@ exports.getOptionsFromConfigFiles = void 0;
|
|
|
4
4
|
const getOptionsFromGit_1 = require("./getOptionsFromGit");
|
|
5
5
|
const globalConfig_1 = require("./globalConfig");
|
|
6
6
|
const projectConfig_1 = require("./projectConfig");
|
|
7
|
-
async function getOptionsFromConfigFiles(optionsFromModule) {
|
|
7
|
+
async function getOptionsFromConfigFiles({ optionsFromModule, ci, }) {
|
|
8
8
|
const [gitConfig, projectConfig, globalConfig] = await Promise.all([
|
|
9
9
|
(0, getOptionsFromGit_1.getOptionsFromGit)(),
|
|
10
10
|
(0, projectConfig_1.getProjectConfig)(),
|
|
11
|
-
(0, globalConfig_1.getGlobalConfig)(
|
|
11
|
+
ci ? undefined : (0, globalConfig_1.getGlobalConfig)(),
|
|
12
12
|
]);
|
|
13
13
|
return {
|
|
14
14
|
...gitConfig,
|
|
@@ -9,7 +9,7 @@ describe('getOptionsFromConfigFiles', () => {
|
|
|
9
9
|
globalConfig: { accessToken: 'abc', editor: 'vim' },
|
|
10
10
|
projectConfig: { repoName: 'kibana', repoOwner: 'elastic' },
|
|
11
11
|
});
|
|
12
|
-
res = await (0, config_1.getOptionsFromConfigFiles)();
|
|
12
|
+
res = await (0, config_1.getOptionsFromConfigFiles)({ ci: false });
|
|
13
13
|
});
|
|
14
14
|
it('should return values from config files', () => {
|
|
15
15
|
expect(res).toEqual({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ConfigFileOptions } from '../ConfigOptions';
|
|
2
|
-
export declare function getGlobalConfig(
|
|
2
|
+
export declare function getGlobalConfig(): Promise<ConfigFileOptions>;
|
|
3
3
|
export declare function createGlobalConfigAndFolderIfNotExist(): Promise<boolean>;
|
|
4
4
|
export declare function createGlobalConfigIfNotExist(globalConfigPath: string, configTemplate: string): Promise<boolean>;
|
|
@@ -8,21 +8,17 @@ const make_dir_1 = __importDefault(require("make-dir"));
|
|
|
8
8
|
const env_1 = require("../../services/env");
|
|
9
9
|
const fs_promisified_1 = require("../../services/fs-promisified");
|
|
10
10
|
const readConfigFile_1 = require("./readConfigFile");
|
|
11
|
-
async function getGlobalConfig(
|
|
12
|
-
// don't attempt to fetch global config in ci environment
|
|
13
|
-
if (ci) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
11
|
+
async function getGlobalConfig() {
|
|
16
12
|
await createGlobalConfigAndFolderIfNotExist();
|
|
17
13
|
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
18
14
|
return (0, readConfigFile_1.readConfigFile)(globalConfigPath);
|
|
19
15
|
}
|
|
20
16
|
exports.getGlobalConfig = getGlobalConfig;
|
|
21
17
|
async function createGlobalConfigAndFolderIfNotExist() {
|
|
22
|
-
|
|
18
|
+
// create .backport folder
|
|
19
|
+
await (0, make_dir_1.default)((0, env_1.getBackportDirPath)());
|
|
23
20
|
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
24
21
|
const configTemplate = getConfigTemplate();
|
|
25
|
-
await (0, make_dir_1.default)(reposPath);
|
|
26
22
|
const didCreate = await createGlobalConfigIfNotExist(globalConfigPath, configTemplate);
|
|
27
23
|
await ensureCorrectPermissions(globalConfigPath);
|
|
28
24
|
return didCreate;
|
|
@@ -2,7 +2,9 @@ import { ConfigFileOptions } from '../ConfigOptions';
|
|
|
2
2
|
export declare function readConfigFile(filepath: string): Promise<ConfigFileOptions>;
|
|
3
3
|
export declare function withConfigMigrations({ upstream, labels, branches, ...config }: ConfigFileOptions): {
|
|
4
4
|
fork?: boolean | undefined;
|
|
5
|
+
dir?: string | undefined;
|
|
5
6
|
verbose?: boolean | undefined;
|
|
7
|
+
ci?: boolean | undefined;
|
|
6
8
|
accessToken?: string | undefined;
|
|
7
9
|
assignees?: string[] | undefined;
|
|
8
10
|
author?: string | null | undefined;
|
|
@@ -23,7 +25,6 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
|
|
|
23
25
|
autoMergeMethod?: string | undefined;
|
|
24
26
|
backportBinary?: string | undefined;
|
|
25
27
|
cherrypickRef?: boolean | undefined;
|
|
26
|
-
ci?: boolean | undefined;
|
|
27
28
|
commitPaths?: string[] | undefined;
|
|
28
29
|
details?: boolean | undefined;
|
|
29
30
|
editor?: string | undefined;
|
|
@@ -38,6 +39,7 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
|
|
|
38
39
|
prDescription?: string | undefined;
|
|
39
40
|
prFilter?: string | undefined;
|
|
40
41
|
prTitle?: string | undefined;
|
|
42
|
+
publishStatusComment?: boolean | undefined;
|
|
41
43
|
pullNumber?: number | undefined;
|
|
42
44
|
repoName?: string | undefined;
|
|
43
45
|
repoOwner?: string | undefined;
|
|
@@ -17,6 +17,7 @@ export declare const defaultConfigOptions: {
|
|
|
17
17
|
multipleBranches: boolean;
|
|
18
18
|
multipleCommits: boolean;
|
|
19
19
|
noVerify: boolean;
|
|
20
|
+
publishStatusComment: boolean;
|
|
20
21
|
resetAuthor: boolean;
|
|
21
22
|
reviewers: string[];
|
|
22
23
|
sourcePRLabels: string[];
|
|
@@ -30,14 +31,15 @@ export declare function getOptions(argv: string[], optionsFromModule?: ConfigFil
|
|
|
30
31
|
repoName: string;
|
|
31
32
|
repoOwner: string;
|
|
32
33
|
fork: boolean;
|
|
34
|
+
dir?: string | undefined;
|
|
33
35
|
verbose: boolean;
|
|
36
|
+
ci: boolean;
|
|
34
37
|
assignees: string[];
|
|
35
38
|
author: string | null;
|
|
36
39
|
autoAssign: boolean;
|
|
37
40
|
autoMerge: boolean;
|
|
38
41
|
autoMergeMethod: string;
|
|
39
42
|
cherrypickRef: boolean;
|
|
40
|
-
ci: boolean;
|
|
41
43
|
commitPaths: string[];
|
|
42
44
|
details: boolean;
|
|
43
45
|
editor?: string | undefined;
|
|
@@ -51,6 +53,7 @@ export declare function getOptions(argv: string[], optionsFromModule?: ConfigFil
|
|
|
51
53
|
prDescription?: string | undefined;
|
|
52
54
|
prFilter?: string | undefined;
|
|
53
55
|
prTitle?: string | undefined;
|
|
56
|
+
publishStatusComment: boolean;
|
|
54
57
|
pullNumber?: number | undefined;
|
|
55
58
|
resetAuthor: boolean;
|
|
56
59
|
reviewers: string[];
|
package/dist/options/options.js
CHANGED
|
@@ -27,6 +27,7 @@ exports.defaultConfigOptions = {
|
|
|
27
27
|
multipleBranches: true,
|
|
28
28
|
multipleCommits: false,
|
|
29
29
|
noVerify: true,
|
|
30
|
+
publishStatusComment: true,
|
|
30
31
|
resetAuthor: false,
|
|
31
32
|
reviewers: [],
|
|
32
33
|
sourcePRLabels: [],
|
|
@@ -36,8 +37,12 @@ exports.defaultConfigOptions = {
|
|
|
36
37
|
verbose: false,
|
|
37
38
|
};
|
|
38
39
|
async function getOptions(argv, optionsFromModule) {
|
|
39
|
-
const optionsFromConfigFiles = await (0, config_1.getOptionsFromConfigFiles)(optionsFromModule);
|
|
40
40
|
const optionsFromCliArgs = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
41
|
+
const ci = optionsFromCliArgs.ci ?? optionsFromModule?.ci ?? exports.defaultConfigOptions.ci;
|
|
42
|
+
const optionsFromConfigFiles = await (0, config_1.getOptionsFromConfigFiles)({
|
|
43
|
+
optionsFromModule,
|
|
44
|
+
ci,
|
|
45
|
+
});
|
|
41
46
|
// combined options from cli and config files
|
|
42
47
|
const combined = getCombinedOptions({
|
|
43
48
|
optionsFromConfigFiles,
|
package/dist/services/env.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ValidConfigOptions } from '../options/options';
|
|
2
|
+
export declare function getBackportDirPath(): string;
|
|
2
3
|
export declare function getLogfilePath(): string;
|
|
3
4
|
export declare function getGlobalConfigPath(): string;
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function getRepoOwnerPath({ repoOwner }: ValidConfigOptions): string;
|
|
6
|
-
export declare function getRepoPath({ repoOwner, repoName }: ValidConfigOptions): string;
|
|
5
|
+
export declare function getRepoPath({ repoOwner, repoName, dir }: ValidConfigOptions): string;
|
package/dist/services/env.js
CHANGED
|
@@ -3,9 +3,13 @@ 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.getRepoPath = exports.
|
|
6
|
+
exports.getRepoPath = exports.getGlobalConfigPath = exports.getLogfilePath = exports.getBackportDirPath = void 0;
|
|
7
7
|
const os_1 = require("os");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
+
function getBackportDirPath() {
|
|
10
|
+
return path_1.default.join((0, os_1.homedir)(), '.backport');
|
|
11
|
+
}
|
|
12
|
+
exports.getBackportDirPath = getBackportDirPath;
|
|
9
13
|
function getLogfilePath() {
|
|
10
14
|
return path_1.default.join((0, os_1.homedir)(), '.backport', 'backport.log');
|
|
11
15
|
}
|
|
@@ -14,15 +18,10 @@ function getGlobalConfigPath() {
|
|
|
14
18
|
return path_1.default.join((0, os_1.homedir)(), '.backport', 'config.json');
|
|
15
19
|
}
|
|
16
20
|
exports.getGlobalConfigPath = getGlobalConfigPath;
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function getRepoOwnerPath({ repoOwner }) {
|
|
22
|
-
return path_1.default.join((0, os_1.homedir)(), '.backport', 'repositories', repoOwner);
|
|
23
|
-
}
|
|
24
|
-
exports.getRepoOwnerPath = getRepoOwnerPath;
|
|
25
|
-
function getRepoPath({ repoOwner, repoName }) {
|
|
21
|
+
function getRepoPath({ repoOwner, repoName, dir }) {
|
|
22
|
+
if (dir) {
|
|
23
|
+
return dir;
|
|
24
|
+
}
|
|
26
25
|
return path_1.default.join((0, os_1.homedir)(), '.backport', 'repositories', repoOwner, repoName);
|
|
27
26
|
}
|
|
28
27
|
exports.getRepoPath = getRepoPath;
|
|
@@ -12,12 +12,6 @@ describe('env', () => {
|
|
|
12
12
|
test('getGlobalConfigPath', () => {
|
|
13
13
|
expect((0, env_1.getGlobalConfigPath)()).toBe('/myHomeDir/.backport/config.json');
|
|
14
14
|
});
|
|
15
|
-
test('getReposPath', () => {
|
|
16
|
-
expect((0, env_1.getReposPath)()).toBe('/myHomeDir/.backport/repositories');
|
|
17
|
-
});
|
|
18
|
-
test('getRepoOwnerPath', () => {
|
|
19
|
-
expect((0, env_1.getRepoOwnerPath)({ repoOwner: 'elastic' })).toBe('/myHomeDir/.backport/repositories/elastic');
|
|
20
|
-
});
|
|
21
15
|
test('getRepoPath', () => {
|
|
22
16
|
expect((0, env_1.getRepoPath)({
|
|
23
17
|
repoOwner: 'elastic',
|
package/dist/services/git.js
CHANGED
|
@@ -49,7 +49,7 @@ function cloneRepo(options, callback) {
|
|
|
49
49
|
resolve();
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
const execProcess = (0, child_process_promisified_1.execAsCallback)(`git clone ${getRemoteUrl(options, options.repoOwner)}
|
|
52
|
+
const execProcess = (0, child_process_promisified_1.execAsCallback)(`git clone ${getRemoteUrl(options, options.repoOwner)} ${(0, env_1.getRepoPath)(options)} --progress`, { maxBuffer: 100 * 1024 * 1024 }, cb);
|
|
53
53
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
54
54
|
if (execProcess.stderr) {
|
|
55
55
|
execProcess.stderr.on('data', (data) => {
|
|
@@ -2,10 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCommentBody = exports.createStatusComment = void 0;
|
|
4
4
|
const rest_1 = require("@octokit/rest");
|
|
5
|
+
const redact_1 = require("../../../utils/redact");
|
|
5
6
|
const logger_1 = require("../../logger");
|
|
6
7
|
const commitFormatters_1 = require("../commitFormatters");
|
|
7
8
|
async function createStatusComment({ options, backportResponse, }) {
|
|
8
|
-
const { githubApiBaseUrlV3, repoName, repoOwner, accessToken } = options;
|
|
9
|
+
const { githubApiBaseUrlV3, repoName, repoOwner, accessToken, publishStatusComment, } = options;
|
|
10
|
+
if (!publishStatusComment) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
9
13
|
try {
|
|
10
14
|
const octokit = new rest_1.Octokit({
|
|
11
15
|
auth: accessToken,
|
|
@@ -26,10 +30,11 @@ async function createStatusComment({ options, backportResponse, }) {
|
|
|
26
30
|
return;
|
|
27
31
|
}
|
|
28
32
|
return octokit.issues.createComment({
|
|
33
|
+
baseUrl: options.githubApiBaseUrlV3,
|
|
29
34
|
owner: repoOwner,
|
|
30
35
|
repo: repoName,
|
|
31
36
|
issue_number: commit.pullNumber,
|
|
32
|
-
body,
|
|
37
|
+
body: (0, redact_1.redact)(options.accessToken, body),
|
|
33
38
|
});
|
|
34
39
|
}));
|
|
35
40
|
}
|
|
@@ -109,7 +114,7 @@ ${backportPRCommand}${supportSection}`;
|
|
|
109
114
|
const backportPRCommandMessage = !didAllBackportsSucceed
|
|
110
115
|
? `${backportPRCommand}`
|
|
111
116
|
: '';
|
|
112
|
-
return
|
|
113
|
-
${backportPRCommandMessage}${autoMergeMessage}${supportSection}
|
|
117
|
+
return `${header}\n\n${table}
|
|
118
|
+
${backportPRCommandMessage}${autoMergeMessage}${supportSection}`;
|
|
114
119
|
}
|
|
115
120
|
exports.getCommentBody = getCommentBody;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.fetchRemoteProjectConfig = void 0;
|
|
4
4
|
const readConfigFile_1 = require("../../../options/config/readConfigFile");
|
|
5
5
|
const apiRequestV4_1 = require("./apiRequestV4");
|
|
6
|
-
async function
|
|
6
|
+
async function fetchRemoteProjectConfig(options) {
|
|
7
7
|
const { accessToken, githubApiBaseUrlV4, repoName, repoOwner, sourceBranch } = options;
|
|
8
8
|
const query = /* GraphQL */ `
|
|
9
9
|
query ProjectConfig(
|
|
@@ -53,4 +53,4 @@ async function fetchProjectConfig(options) {
|
|
|
53
53
|
throw new Error('Project config does not exist');
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
exports.
|
|
56
|
+
exports.fetchRemoteProjectConfig = fetchRemoteProjectConfig;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
4
|
-
const
|
|
5
|
-
describe('
|
|
4
|
+
const fetchRemoteProjectConfig_1 = require("./fetchRemoteProjectConfig");
|
|
5
|
+
describe('fetchRemoteProjectConfig', () => {
|
|
6
6
|
let devAccessToken;
|
|
7
7
|
beforeEach(async () => {
|
|
8
8
|
devAccessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
9
|
});
|
|
10
10
|
it('returns the backport config from "main" branch', async () => {
|
|
11
|
-
const projectConfig = await (0,
|
|
11
|
+
const projectConfig = await (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
12
12
|
repoOwner: 'backport-org',
|
|
13
13
|
repoName: 'repo-with-project-config',
|
|
14
14
|
accessToken: devAccessToken,
|
|
@@ -28,7 +28,7 @@ describe('fetchProjectConfig', () => {
|
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
it('returns the backport config from "branch-with-legacy-config" branch', async () => {
|
|
31
|
-
const projectConfig = await (0,
|
|
31
|
+
const projectConfig = await (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
32
32
|
repoOwner: 'backport-org',
|
|
33
33
|
repoName: 'repo-with-project-config',
|
|
34
34
|
accessToken: devAccessToken,
|
|
@@ -41,7 +41,7 @@ describe('fetchProjectConfig', () => {
|
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
it('throws an error if config does not exist', async () => {
|
|
44
|
-
const promise = (0,
|
|
44
|
+
const promise = (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
45
45
|
repoOwner: 'backport-org',
|
|
46
46
|
repoName: 'repo-with-project-config',
|
|
47
47
|
accessToken: devAccessToken,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ConfigFileOptions } from '../../../entrypoint.module';
|
|
2
|
+
export declare function fetchRemoteProjectConfig(options: {
|
|
3
|
+
accessToken: string;
|
|
4
|
+
githubApiBaseUrlV4?: string;
|
|
5
|
+
repoName: string;
|
|
6
|
+
repoOwner: string;
|
|
7
|
+
sourceBranch: string;
|
|
8
|
+
}): Promise<ConfigFileOptions>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchRemoteProjectConfig = void 0;
|
|
4
|
+
const readConfigFile_1 = require("../../../options/config/readConfigFile");
|
|
5
|
+
const apiRequestV4_1 = require("./apiRequestV4");
|
|
6
|
+
async function fetchRemoteProjectConfig(options) {
|
|
7
|
+
const { accessToken, githubApiBaseUrlV4, repoName, repoOwner, sourceBranch } = options;
|
|
8
|
+
const query = /* GraphQL */ `
|
|
9
|
+
query ProjectConfig(
|
|
10
|
+
$repoOwner: String!
|
|
11
|
+
$repoName: String!
|
|
12
|
+
$sourceBranch: String!
|
|
13
|
+
) {
|
|
14
|
+
repository(owner: $repoOwner, name: $repoName) {
|
|
15
|
+
ref(qualifiedName: $sourceBranch) {
|
|
16
|
+
target {
|
|
17
|
+
... on Commit {
|
|
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
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
try {
|
|
40
|
+
const res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
41
|
+
githubApiBaseUrlV4,
|
|
42
|
+
accessToken,
|
|
43
|
+
query,
|
|
44
|
+
variables: {
|
|
45
|
+
repoOwner,
|
|
46
|
+
repoName,
|
|
47
|
+
sourceBranch,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
return (0, readConfigFile_1.withConfigMigrations)(JSON.parse(res.repository.ref.target.history.edges[0].remoteConfig.file.object.text));
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
throw new Error('Project config does not exist');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.fetchRemoteProjectConfig = fetchRemoteProjectConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
4
|
+
const fetchRemoteProjectConfig_1 = require("./fetchRemoteProjectConfig");
|
|
5
|
+
describe('fetchRemoteProjectConfig', () => {
|
|
6
|
+
let devAccessToken;
|
|
7
|
+
beforeEach(async () => {
|
|
8
|
+
devAccessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
|
+
});
|
|
10
|
+
it('returns the backport config from "main" branch', async () => {
|
|
11
|
+
const projectConfig = await (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
12
|
+
repoOwner: 'backport-org',
|
|
13
|
+
repoName: 'repo-with-project-config',
|
|
14
|
+
accessToken: devAccessToken,
|
|
15
|
+
sourceBranch: 'main',
|
|
16
|
+
});
|
|
17
|
+
expect(projectConfig).toEqual({
|
|
18
|
+
autoMerge: true,
|
|
19
|
+
autoMergeMethod: 'squash',
|
|
20
|
+
branchLabelMapping: {
|
|
21
|
+
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
22
|
+
'^v8.1.0$': 'main',
|
|
23
|
+
},
|
|
24
|
+
targetBranchChoices: ['main', '8.0', '7.17', '7.16'],
|
|
25
|
+
targetPRLabels: ['backport'],
|
|
26
|
+
repoOwner: 'backport-org',
|
|
27
|
+
repoName: 'repo-with-project-config',
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
it('returns the backport config from "branch-with-legacy-config" branch', async () => {
|
|
31
|
+
const projectConfig = await (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
32
|
+
repoOwner: 'backport-org',
|
|
33
|
+
repoName: 'repo-with-project-config',
|
|
34
|
+
accessToken: devAccessToken,
|
|
35
|
+
sourceBranch: 'branch-with-legacy-config',
|
|
36
|
+
});
|
|
37
|
+
expect(projectConfig).toEqual({
|
|
38
|
+
targetBranchChoices: ['main', '8.0', '7.17', '7.16'],
|
|
39
|
+
repoOwner: 'backport-org',
|
|
40
|
+
repoName: 'repo-with-project-config',
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
it('throws an error if config does not exist', async () => {
|
|
44
|
+
const promise = (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
45
|
+
repoOwner: 'backport-org',
|
|
46
|
+
repoName: 'repo-with-project-config',
|
|
47
|
+
accessToken: devAccessToken,
|
|
48
|
+
sourceBranch: 'branch-with-no-config',
|
|
49
|
+
});
|
|
50
|
+
await expect(promise).rejects.toThrowError('Project config does not exist');
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -32,6 +32,7 @@ export declare function getOptionsFromGithub(options: {
|
|
|
32
32
|
cherrypickRef?: boolean | undefined;
|
|
33
33
|
ci?: boolean | undefined;
|
|
34
34
|
commitPaths?: string[] | undefined;
|
|
35
|
+
dir?: string | undefined;
|
|
35
36
|
details?: boolean | undefined;
|
|
36
37
|
editor?: string | undefined;
|
|
37
38
|
fork?: boolean | undefined;
|
|
@@ -46,6 +47,7 @@ export declare function getOptionsFromGithub(options: {
|
|
|
46
47
|
prDescription?: string | undefined;
|
|
47
48
|
prFilter?: string | undefined;
|
|
48
49
|
prTitle?: string | undefined;
|
|
50
|
+
publishStatusComment?: boolean | undefined;
|
|
49
51
|
pullNumber?: number | undefined;
|
|
50
52
|
repoName?: string | undefined;
|
|
51
53
|
repoOwner?: string | undefined;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getOptionsFromGithub = void 0;
|
|
7
|
-
const ora_1 = __importDefault(require("ora"));
|
|
8
4
|
const readConfigFile_1 = require("../../../../options/config/readConfigFile");
|
|
9
5
|
const filterEmpty_1 = require("../../../../utils/filterEmpty");
|
|
10
6
|
const HandledError_1 = require("../../../HandledError");
|
|
@@ -16,7 +12,6 @@ const query_1 = require("./query");
|
|
|
16
12
|
async function getOptionsFromGithub(options) {
|
|
17
13
|
const { accessToken, githubApiBaseUrlV4, repoName, repoOwner } = options;
|
|
18
14
|
let res;
|
|
19
|
-
const spinner = (0, ora_1.default)().start('Initializing...');
|
|
20
15
|
try {
|
|
21
16
|
res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
22
17
|
githubApiBaseUrlV4,
|
|
@@ -25,10 +20,8 @@ async function getOptionsFromGithub(options) {
|
|
|
25
20
|
variables: { repoOwner, repoName },
|
|
26
21
|
handleError: false,
|
|
27
22
|
});
|
|
28
|
-
spinner.stop();
|
|
29
23
|
}
|
|
30
24
|
catch (e) {
|
|
31
|
-
spinner.stop();
|
|
32
25
|
const error = e;
|
|
33
26
|
(0, throwOnInvalidAccessToken_1.throwOnInvalidAccessToken)({
|
|
34
27
|
error,
|
|
@@ -9,7 +9,6 @@ export declare const logger: {
|
|
|
9
9
|
debug: (message: string, meta?: unknown) => void;
|
|
10
10
|
};
|
|
11
11
|
export declare function updateLogger(options: ConfigFileOptions): void;
|
|
12
|
-
export declare function redactAccessToken(str: string): string;
|
|
13
12
|
export declare function initLogger(): {
|
|
14
13
|
error: (message: string, meta?: unknown) => void;
|
|
15
14
|
warn: (message: string, meta?: unknown) => void;
|
package/dist/services/logger.js
CHANGED
|
@@ -22,11 +22,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.initLogger = exports.
|
|
25
|
+
exports.initLogger = exports.updateLogger = exports.logger = exports.consoleLog = void 0;
|
|
26
26
|
const dedent_1 = __importDefault(require("dedent"));
|
|
27
27
|
const lodash_1 = require("lodash");
|
|
28
28
|
const safe_json_stringify_1 = __importDefault(require("safe-json-stringify"));
|
|
29
29
|
const winston_1 = __importStar(require("winston"));
|
|
30
|
+
const redact_1 = require("../utils/redact");
|
|
30
31
|
const env_1 = require("./env");
|
|
31
32
|
const { combine } = winston_1.format;
|
|
32
33
|
let winstonInstance;
|
|
@@ -68,11 +69,10 @@ exports.updateLogger = updateLogger;
|
|
|
68
69
|
function redactAccessToken(str) {
|
|
69
70
|
// `redactAccessToken` might be called before access token is set
|
|
70
71
|
if (accessToken) {
|
|
71
|
-
return
|
|
72
|
+
return (0, redact_1.redact)(accessToken, str);
|
|
72
73
|
}
|
|
73
74
|
return str;
|
|
74
75
|
}
|
|
75
|
-
exports.redactAccessToken = redactAccessToken;
|
|
76
76
|
function initLogger() {
|
|
77
77
|
winstonInstance = winston_1.default.createLogger({
|
|
78
78
|
transports: [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const entrypoint_module_1 = require("./entrypoint.module");
|
|
4
|
+
async function init() {
|
|
5
|
+
const { accessToken } = await (0, entrypoint_module_1.getLocalGlobalConfig)();
|
|
6
|
+
if (!accessToken) {
|
|
7
|
+
throw new Error('Missing access token');
|
|
8
|
+
}
|
|
9
|
+
const commit = await (0, entrypoint_module_1.getCommits)({
|
|
10
|
+
accessToken: accessToken,
|
|
11
|
+
repoOwner: 'backport-org',
|
|
12
|
+
repoName: 'repo-with-conflicts',
|
|
13
|
+
pullNumber: 8,
|
|
14
|
+
});
|
|
15
|
+
console.log({ commit });
|
|
16
|
+
}
|
|
17
|
+
init();
|
|
@@ -154,7 +154,7 @@ async function waitForCherrypick(options, commit, targetBranch) {
|
|
|
154
154
|
}
|
|
155
155
|
(0, logger_1.consoleLog)(chalk_1.default.bold('\nThe commit could not be backported due to conflicts\n'));
|
|
156
156
|
if (commitsWithoutBackports.length > 0) {
|
|
157
|
-
(0, logger_1.consoleLog)(chalk_1.default.italic(`Hint: Before fixing the conflicts manually you should consider backporting the following
|
|
157
|
+
(0, logger_1.consoleLog)(chalk_1.default.italic(`Hint: Before fixing the conflicts manually you should consider backporting the following pull requests to "${targetBranch}":`));
|
|
158
158
|
(0, logger_1.consoleLog)(`${commitsWithoutBackports.map((c) => c.formatted).join('\n')}\n\n`);
|
|
159
159
|
}
|
|
160
160
|
/*
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.maybeSetupRepo = void 0;
|
|
7
|
-
const make_dir_1 = __importDefault(require("make-dir"));
|
|
8
4
|
const ora = require("ora");
|
|
9
|
-
const env_1 = require("../services/env");
|
|
10
5
|
const git_1 = require("../services/git");
|
|
11
6
|
async function maybeSetupRepo(options) {
|
|
12
7
|
const isAlreadyCloned = await (0, git_1.repoExists)(options);
|
|
@@ -16,7 +11,6 @@ async function maybeSetupRepo(options) {
|
|
|
16
11
|
try {
|
|
17
12
|
const spinnerCloneText = 'Cloning repository (one-time operation)';
|
|
18
13
|
spinner.text = `0% ${spinnerCloneText}`;
|
|
19
|
-
await (0, make_dir_1.default)((0, env_1.getRepoOwnerPath)(options));
|
|
20
14
|
await (0, git_1.cloneRepo)(options, (progress) => {
|
|
21
15
|
spinner.text = `${progress}% ${spinnerCloneText}`;
|
|
22
16
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function redact(stringToRedact: string, str: string): string;
|