backport 7.3.6 → 8.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/README.md +16 -21
- package/dist/backportRun.d.ts +18 -6
- package/dist/backportRun.js +70 -50
- package/dist/entrypoint.cli.js +4 -8
- package/dist/entrypoint.module.d.ts +13 -6
- package/dist/entrypoint.module.js +17 -19
- package/dist/entrypoint.module.private.test.js +129 -330
- package/dist/errors/BackportError.d.ts +19 -0
- package/dist/errors/BackportError.js +29 -0
- package/dist/lib/BackportError.d.ts +19 -0
- package/dist/lib/BackportError.js +29 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.d.ts +13 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.js +238 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.test.js +321 -0
- package/dist/lib/child-process-promisified.d.ts +25 -0
- package/dist/lib/child-process-promisified.js +58 -0
- package/dist/lib/env.d.ts +7 -0
- package/dist/lib/env.js +33 -0
- package/dist/lib/env.test.d.ts +1 -0
- package/dist/lib/env.test.js +26 -0
- package/dist/lib/getCommits.d.ts +2 -0
- package/dist/lib/getCommits.js +75 -0
- package/dist/lib/getCommitsWithoutBackports.d.ts +11 -0
- package/dist/lib/getCommitsWithoutBackports.js +68 -0
- package/dist/lib/getCommitsWithoutBackports.test.d.ts +1 -0
- package/dist/lib/getCommitsWithoutBackports.test.js +335 -0
- package/dist/lib/getGitConfigAuthor.d.ts +6 -0
- package/dist/lib/getGitConfigAuthor.js +15 -0
- package/dist/lib/getTargetBranches.d.ts +5 -0
- package/dist/lib/getTargetBranches.js +67 -0
- package/dist/lib/getTargetBranches.test.d.ts +1 -0
- package/dist/lib/getTargetBranches.test.js +206 -0
- package/dist/lib/git.d.ts +77 -0
- package/dist/lib/git.js +439 -0
- package/dist/lib/git.private.test.d.ts +1 -0
- package/dist/lib/git.private.test.js +618 -0
- package/dist/lib/git.test.d.ts +1 -0
- package/dist/lib/git.test.js +580 -0
- package/dist/lib/github/commitFormatters.d.ts +3 -0
- package/dist/lib/github/commitFormatters.js +17 -0
- package/dist/lib/github/commitFormatters.test.d.ts +1 -0
- package/dist/lib/github/commitFormatters.test.js +11 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.js +32 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.test.d.ts +1 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.test.js +27 -0
- package/dist/lib/github/v3/addLabelsToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addLabelsToPullRequest.js +30 -0
- package/dist/lib/github/v3/addReviewersToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addReviewersToPullRequest.js +32 -0
- package/dist/lib/github/v3/createPullRequest.d.ts +29 -0
- package/dist/lib/github/v3/createPullRequest.js +91 -0
- package/dist/lib/github/v3/createPullRequest.test.d.ts +1 -0
- package/dist/lib/github/v3/createPullRequest.test.js +377 -0
- package/dist/lib/github/v3/createStatusComment.d.ts +11 -0
- package/dist/lib/github/v3/createStatusComment.js +136 -0
- package/dist/lib/github/v3/createStatusComment.test.d.ts +1 -0
- package/dist/lib/github/v3/createStatusComment.test.js +461 -0
- package/dist/lib/github/v3/getGithubV3ErrorMessage.d.ts +14 -0
- package/dist/lib/github/v3/getGithubV3ErrorMessage.js +16 -0
- package/dist/lib/github/v4/FetchPullRequestId.d.ts +2 -0
- package/dist/lib/github/v4/FetchPullRequestId.js +36 -0
- package/dist/lib/github/v4/apiRequestV4.d.ts +31 -0
- package/dist/lib/github/v4/apiRequestV4.js +71 -0
- package/dist/lib/github/v4/apiRequestV4.test.d.ts +1 -0
- package/dist/lib/github/v4/apiRequestV4.test.js +109 -0
- package/dist/lib/github/v4/disablePullRequestAutoMerge.d.ts +2 -0
- package/dist/lib/github/v4/disablePullRequestAutoMerge.js +32 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.d.ts +2 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.js +50 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.js +112 -0
- package/dist/lib/github/v4/fetchAuthorId.d.ts +10 -0
- package/dist/lib/github/v4/fetchAuthorId.js +28 -0
- package/dist/lib/github/v4/fetchAuthorId.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchAuthorId.private.test.js +25 -0
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +93 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +11 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.js +58 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +136 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.d.ts +11 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.js +48 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.js +118 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +29 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.js +110 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +196 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +157 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +107 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +12 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +69 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.d.ts +9 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.js +64 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.private.test.js +44 -0
- package/dist/lib/github/v4/fetchPullRequestAutoMergeMethod.d.ts +2 -0
- package/dist/lib/github/v4/fetchPullRequestAutoMergeMethod.js +39 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.d.ts +8 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.js +49 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.private.test.js +49 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +72 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +78 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +116 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.d.ts +16 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.js +29 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.js +61 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +1 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +72 -0
- package/dist/lib/github/v4/mocks/commitsByAuthorMock.d.ts +2 -0
- package/dist/lib/github/v4/mocks/commitsByAuthorMock.js +176 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.d.ts +7 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.js +45 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.test.d.ts +1 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.test.js +87 -0
- package/dist/lib/logger.d.ts +9 -0
- package/dist/lib/logger.js +74 -0
- package/dist/lib/ora.d.ts +2 -0
- package/dist/lib/ora.js +21 -0
- package/dist/lib/prompt.test.d.ts +1 -0
- package/dist/lib/prompt.test.js +139 -0
- package/dist/lib/prompts.d.ts +17 -0
- package/dist/lib/prompts.js +132 -0
- package/dist/lib/remoteConfig.d.ts +20 -0
- package/dist/lib/remoteConfig.js +52 -0
- package/dist/lib/sequentially.d.ts +1 -0
- package/dist/lib/sequentially.js +10 -0
- package/dist/lib/setupRepo.d.ts +2 -0
- package/dist/lib/setupRepo.js +56 -0
- package/dist/lib/setupRepo.test.d.ts +1 -0
- package/dist/lib/setupRepo.test.js +278 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.d.ts +16 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.js +102 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.js +467 -0
- package/dist/lib/sourceCommit/getMockSourceCommit.d.ts +26 -0
- package/dist/lib/sourceCommit/getMockSourceCommit.js +103 -0
- package/dist/lib/sourceCommit/parseSourceCommit.d.ts +108 -0
- package/dist/lib/sourceCommit/parseSourceCommit.js +123 -0
- package/dist/lib/sourceCommit/parseSourceCommit.test.d.ts +1 -0
- package/dist/lib/sourceCommit/parseSourceCommit.test.js +226 -0
- package/dist/options/ConfigOptions.d.ts +6 -4
- package/dist/options/cliArgs.d.ts +16 -9
- package/dist/options/cliArgs.js +54 -28
- package/dist/options/cliArgs.test.js +128 -4
- package/dist/options/config/config.d.ts +7 -6
- package/dist/options/config/config.js +5 -7
- package/dist/options/config/config.test.js +0 -1
- package/dist/options/config/globalConfig.d.ts +5 -3
- package/dist/options/config/globalConfig.js +17 -14
- package/dist/options/config/projectConfig.d.ts +2 -2
- package/dist/options/config/projectConfig.js +3 -3
- package/dist/options/config/projectConfig.test.js +19 -7
- package/dist/options/config/readConfigFile.d.ts +9 -7
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +44 -9
- package/dist/options/options.js +22 -27
- package/dist/options/options.test.js +119 -58
- package/dist/runSequentially.d.ts +14 -7
- package/dist/runSequentially.js +26 -11
- package/dist/scripts/postinstall.js +4 -3
- package/dist/scripts/postinstall.test.js +6 -2
- package/dist/services/BackportError.d.ts +19 -0
- package/dist/services/BackportError.js +29 -0
- package/dist/services/HandledBackportError.d.ts +19 -0
- package/dist/services/HandledBackportError.js +29 -0
- package/dist/services/HandledError.d.ts +7 -3
- package/dist/services/HandledError.js +13 -13
- 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 +189 -127
- 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 -158
- 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 +4 -2
- package/dist/services/github/v3/createStatusComment.js +17 -17
- package/dist/services/github/v3/createStatusComment.test.js +22 -9
- package/dist/services/github/v4/apiRequestV4.js +8 -11
- package/dist/services/github/v4/apiRequestV4.test.js +2 -2
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +2 -4
- package/dist/services/github/v4/fetchAuthorId.private.test.js +3 -6
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +5 -6
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +4 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +10 -9
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +10 -9
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +4 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +9 -8
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +3 -6
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +3 -2
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +3 -6
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +4 -7
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +2 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +2 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +6 -7
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +9 -8
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +5 -5
- package/dist/services/logger.d.ts +1 -4
- package/dist/services/logger.js +14 -19
- package/dist/services/test.d.ts +1 -0
- package/dist/services/test.js +23 -0
- package/dist/state.d.ts +0 -0
- package/dist/state.js +1 -0
- package/dist/test/e2e/cli/commit-author.private.test.js +4 -4
- package/dist/test/e2e/cli/different-merge-strategies.private.test.js +26 -24
- package/dist/test/e2e/cli/entrypoint.cli.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +450 -0
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +27 -28
- package/dist/test/e2e/cli/runBackportViaCli.d.ts +6 -2
- package/dist/test/e2e/cli/runBackportViaCli.js +44 -23
- package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +22 -14
- package/dist/test/e2e/module/entrypoint.module.mutation.test.d.ts +1 -0
- package/dist/test/e2e/module/entrypoint.module.mutation.test.js +376 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.js +12 -10
- package/dist/test/sandbox.js +5 -1
- package/dist/test/setupFiles/automatic-mocks.js +17 -13
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +11 -7
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +7 -159
- package/dist/ui/getCommits.js +2 -2
- package/dist/ui/getCommitsWithoutBackports.test.js +5 -1
- package/dist/ui/getGitConfigAuthor.js +1 -1
- package/dist/ui/getTargetBranches.js +3 -3
- package/dist/ui/getTargetBranches.test.js +5 -1
- package/dist/ui/ora.d.ts +1 -8
- package/dist/ui/setupRepo.js +3 -3
- 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 +17 -17
- package/yarn.lock +461 -695
|
@@ -1,30 +1,64 @@
|
|
|
1
1
|
import { ConfigFileOptions, TargetBranchChoiceOrString } from './ConfigOptions';
|
|
2
|
+
import { OptionsFromCliArgs } from './cliArgs';
|
|
2
3
|
export declare type ValidConfigOptions = Readonly<Awaited<ReturnType<typeof getOptions>>>;
|
|
3
|
-
export declare
|
|
4
|
+
export declare const defaultConfigOptions: {
|
|
5
|
+
assignees: string[];
|
|
6
|
+
autoAssign: boolean;
|
|
7
|
+
autoMerge: boolean;
|
|
8
|
+
autoMergeMethod: string;
|
|
9
|
+
backportBinary: string;
|
|
10
|
+
cherrypickRef: boolean;
|
|
11
|
+
commitPaths: string[];
|
|
12
|
+
cwd: string;
|
|
13
|
+
dateSince: null;
|
|
14
|
+
dateUntil: null;
|
|
15
|
+
details: boolean;
|
|
16
|
+
fork: boolean;
|
|
17
|
+
gitHostname: string;
|
|
18
|
+
interactive: boolean;
|
|
19
|
+
maxNumber: number;
|
|
20
|
+
multipleBranches: boolean;
|
|
21
|
+
multipleCommits: boolean;
|
|
22
|
+
noVerify: boolean;
|
|
23
|
+
publishStatusCommentOnAbort: boolean;
|
|
24
|
+
publishStatusCommentOnSuccess: boolean;
|
|
25
|
+
publishStatusCommentOnFailure: boolean;
|
|
26
|
+
resetAuthor: boolean;
|
|
27
|
+
reviewers: string[];
|
|
28
|
+
sourcePRLabels: string[];
|
|
29
|
+
targetBranchChoices: TargetBranchChoiceOrString[];
|
|
30
|
+
targetBranches: string[];
|
|
31
|
+
targetPRLabels: string[];
|
|
32
|
+
};
|
|
33
|
+
export declare function getOptions({ optionsFromCliArgs, optionsFromModule, }: {
|
|
34
|
+
optionsFromCliArgs: OptionsFromCliArgs;
|
|
35
|
+
optionsFromModule: ConfigFileOptions;
|
|
36
|
+
}): Promise<{
|
|
4
37
|
accessToken: string;
|
|
5
38
|
repoName: string;
|
|
6
39
|
repoOwner: string;
|
|
7
|
-
fork: boolean;
|
|
8
|
-
dir?: string | undefined;
|
|
9
|
-
verbose: boolean;
|
|
10
40
|
logFilePath?: string | undefined;
|
|
11
41
|
author: string | null;
|
|
12
42
|
autoAssign: boolean;
|
|
13
43
|
assignees: string[];
|
|
14
44
|
autoMerge: boolean;
|
|
15
45
|
autoMergeMethod: string;
|
|
16
|
-
ci: boolean;
|
|
17
46
|
cherrypickRef: boolean;
|
|
18
|
-
|
|
47
|
+
cwd: string;
|
|
48
|
+
projectConfigFile?: string | undefined;
|
|
49
|
+
globalConfigFile?: string | undefined;
|
|
50
|
+
dir?: string | undefined;
|
|
19
51
|
details: boolean;
|
|
20
52
|
dryRun?: boolean | undefined;
|
|
21
53
|
editor?: string | undefined;
|
|
22
54
|
skipRemoteConfig?: boolean | undefined;
|
|
55
|
+
fork: boolean;
|
|
23
56
|
gitHostname: string;
|
|
24
57
|
githubApiBaseUrlV3?: string | undefined;
|
|
25
58
|
githubApiBaseUrlV4?: string | undefined;
|
|
26
59
|
gitAuthorName?: string | undefined;
|
|
27
60
|
gitAuthorEmail?: string | undefined;
|
|
61
|
+
interactive: boolean;
|
|
28
62
|
ls?: boolean | undefined;
|
|
29
63
|
mainline?: number | undefined;
|
|
30
64
|
maxNumber: number;
|
|
@@ -45,10 +79,12 @@ export declare function getOptions(processArgs: string[], optionsFromModule: Con
|
|
|
45
79
|
commitPaths: string[];
|
|
46
80
|
reviewers: string[];
|
|
47
81
|
sourcePRLabels: string[];
|
|
48
|
-
targetBranchChoices:
|
|
82
|
+
targetBranchChoices: TargetBranchChoiceOrString[];
|
|
49
83
|
targetBranches: string[];
|
|
50
84
|
targetPRLabels: string[];
|
|
51
|
-
|
|
85
|
+
publishStatusCommentOnSuccess: boolean;
|
|
86
|
+
publishStatusCommentOnFailure: boolean;
|
|
87
|
+
publishStatusCommentOnAbort: boolean;
|
|
52
88
|
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
53
89
|
files: string[];
|
|
54
90
|
directory: string;
|
|
@@ -65,5 +101,4 @@ export declare function getOptions(processArgs: string[], optionsFromModule: Con
|
|
|
65
101
|
branches?: TargetBranchChoiceOrString[] | undefined;
|
|
66
102
|
labels?: string[] | undefined;
|
|
67
103
|
authenticatedUsername: string;
|
|
68
|
-
cwd: string;
|
|
69
104
|
}>;
|
package/dist/options/options.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOptions = void 0;
|
|
3
|
+
exports.getOptions = exports.defaultConfigOptions = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
|
-
const
|
|
6
|
-
const env_1 = require("../
|
|
7
|
-
const getOptionsFromGithub_1 = require("../
|
|
8
|
-
const getRepoOwnerAndNameFromGitRemotes_1 = require("../
|
|
9
|
-
const logger_1 = require("
|
|
10
|
-
const cliArgs_1 = require("./cliArgs");
|
|
5
|
+
const BackportError_1 = require("../lib/BackportError");
|
|
6
|
+
const env_1 = require("../lib/env");
|
|
7
|
+
const getOptionsFromGithub_1 = require("../lib/github/v4/getOptionsFromGithub/getOptionsFromGithub");
|
|
8
|
+
const getRepoOwnerAndNameFromGitRemotes_1 = require("../lib/github/v4/getRepoOwnerAndNameFromGitRemotes");
|
|
9
|
+
const logger_1 = require("../lib/logger");
|
|
11
10
|
const config_1 = require("./config/config");
|
|
12
11
|
const PROJECT_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson';
|
|
13
12
|
const GLOBAL_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson';
|
|
14
|
-
|
|
13
|
+
exports.defaultConfigOptions = {
|
|
15
14
|
assignees: [],
|
|
16
15
|
autoAssign: false,
|
|
17
16
|
autoMerge: false,
|
|
18
17
|
autoMergeMethod: 'merge',
|
|
19
18
|
backportBinary: 'backport',
|
|
20
19
|
cherrypickRef: true,
|
|
21
|
-
ci: false,
|
|
22
20
|
commitPaths: [],
|
|
23
21
|
cwd: process.cwd(),
|
|
24
22
|
dateSince: null,
|
|
@@ -26,25 +24,25 @@ const defaultConfigOptions = {
|
|
|
26
24
|
details: false,
|
|
27
25
|
fork: true,
|
|
28
26
|
gitHostname: 'github.com',
|
|
27
|
+
interactive: true,
|
|
29
28
|
maxNumber: 10,
|
|
30
29
|
multipleBranches: true,
|
|
31
30
|
multipleCommits: false,
|
|
32
31
|
noVerify: true,
|
|
33
|
-
|
|
32
|
+
publishStatusCommentOnAbort: false,
|
|
33
|
+
publishStatusCommentOnSuccess: true,
|
|
34
|
+
publishStatusCommentOnFailure: false,
|
|
34
35
|
resetAuthor: false,
|
|
35
36
|
reviewers: [],
|
|
36
37
|
sourcePRLabels: [],
|
|
37
38
|
targetBranchChoices: [],
|
|
38
39
|
targetBranches: [],
|
|
39
40
|
targetPRLabels: [],
|
|
40
|
-
verbose: false,
|
|
41
41
|
};
|
|
42
|
-
async function getOptions(
|
|
43
|
-
const optionsFromCliArgs = (0, cliArgs_1.getOptionsFromCliArgs)(processArgs);
|
|
42
|
+
async function getOptions({ optionsFromCliArgs, optionsFromModule, }) {
|
|
44
43
|
const optionsFromConfigFiles = await (0, config_1.getOptionsFromConfigFiles)({
|
|
45
44
|
optionsFromCliArgs,
|
|
46
45
|
optionsFromModule,
|
|
47
|
-
defaultConfigOptions,
|
|
48
46
|
});
|
|
49
47
|
// combined options from cli and config files
|
|
50
48
|
const combined = getMergedOptionsFromConfigAndCli({
|
|
@@ -53,7 +51,7 @@ async function getOptions(processArgs, optionsFromModule) {
|
|
|
53
51
|
});
|
|
54
52
|
const { accessToken, repoName, repoOwner } = await getRequiredOptions(combined);
|
|
55
53
|
// update logger
|
|
56
|
-
(0, logger_1.
|
|
54
|
+
(0, logger_1.setAccessToken)(accessToken);
|
|
57
55
|
const optionsFromGithub = await (0, getOptionsFromGithub_1.getOptionsFromGithub)({
|
|
58
56
|
...combined,
|
|
59
57
|
// required options
|
|
@@ -67,7 +65,7 @@ async function getOptions(processArgs, optionsFromModule) {
|
|
|
67
65
|
// default fork owner
|
|
68
66
|
repoForkOwner: optionsFromGithub.authenticatedUsername,
|
|
69
67
|
// default values have lowest precedence
|
|
70
|
-
...defaultConfigOptions,
|
|
68
|
+
...exports.defaultConfigOptions,
|
|
71
69
|
// local config options override default options
|
|
72
70
|
...optionsFromConfigFiles,
|
|
73
71
|
// remote config options override local config options
|
|
@@ -84,17 +82,14 @@ async function getOptions(processArgs, optionsFromModule) {
|
|
|
84
82
|
}
|
|
85
83
|
exports.getOptions = getOptions;
|
|
86
84
|
async function getRequiredOptions(combined) {
|
|
87
|
-
const { accessToken, repoName, repoOwner } = combined;
|
|
85
|
+
const { accessToken, repoName, repoOwner, globalConfigFile } = combined;
|
|
88
86
|
if (accessToken && repoName && repoOwner) {
|
|
89
87
|
return { accessToken, repoName, repoOwner };
|
|
90
88
|
}
|
|
91
89
|
// require access token
|
|
92
90
|
if (!accessToken) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
97
|
-
throw new HandledError_1.HandledError(`Please update your config file: "${globalConfigPath}".\nIt must contain a valid "accessToken".\n\nRead more: ${GLOBAL_CONFIG_DOCS_LINK}`);
|
|
91
|
+
const globalConfigPath = (0, env_1.getGlobalConfigPath)(globalConfigFile);
|
|
92
|
+
throw new BackportError_1.BackportError(`Please update your config file: "${globalConfigPath}".\nIt must contain a valid "accessToken".\n\nRead more: ${GLOBAL_CONFIG_DOCS_LINK}`);
|
|
98
93
|
}
|
|
99
94
|
// attempt to retrieve repo-owner and repo-name from git remote
|
|
100
95
|
const gitRemote = await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
|
|
@@ -103,7 +98,7 @@ async function getRequiredOptions(combined) {
|
|
|
103
98
|
accessToken,
|
|
104
99
|
});
|
|
105
100
|
if (!gitRemote.repoName || !gitRemote.repoOwner) {
|
|
106
|
-
throw new
|
|
101
|
+
throw new BackportError_1.BackportError(`Please specify a repository: "--repo elastic/kibana".\n\nRead more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
107
102
|
}
|
|
108
103
|
return {
|
|
109
104
|
accessToken,
|
|
@@ -117,14 +112,13 @@ function throwForRequiredOptions(options) {
|
|
|
117
112
|
(0, lodash_1.isEmpty)(options.targetBranchChoices) &&
|
|
118
113
|
// this is primarily necessary on CI where `targetBranches` and `targetBranchChoices` and not given
|
|
119
114
|
(0, lodash_1.isEmpty)(options.branchLabelMapping)) {
|
|
120
|
-
throw new
|
|
115
|
+
throw new BackportError_1.BackportError(`Please specify a target branch: "--branch 6.1".\n\nRead more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
121
116
|
}
|
|
122
117
|
const optionKeys = [
|
|
123
118
|
'accessToken',
|
|
124
119
|
'author',
|
|
125
120
|
'autoMergeMethod',
|
|
126
121
|
'backportBinary',
|
|
127
|
-
'configFile',
|
|
128
122
|
'dir',
|
|
129
123
|
'editor',
|
|
130
124
|
'gitHostname',
|
|
@@ -133,6 +127,7 @@ function throwForRequiredOptions(options) {
|
|
|
133
127
|
'logFilePath',
|
|
134
128
|
'prDescription',
|
|
135
129
|
'prFilter',
|
|
130
|
+
'projectConfigFile',
|
|
136
131
|
'prTitle',
|
|
137
132
|
'repoForkOwner',
|
|
138
133
|
'repoName',
|
|
@@ -146,13 +141,13 @@ function throwForRequiredOptions(options) {
|
|
|
146
141
|
optionKeys.forEach((optionName) => {
|
|
147
142
|
const option = options[optionName];
|
|
148
143
|
if (option === '') {
|
|
149
|
-
throw new
|
|
144
|
+
throw new BackportError_1.BackportError(`"${optionName}" cannot be empty!`);
|
|
150
145
|
}
|
|
151
146
|
});
|
|
152
147
|
}
|
|
153
148
|
function getMergedOptionsFromConfigAndCli({ optionsFromConfigFiles, optionsFromCliArgs, }) {
|
|
154
149
|
return {
|
|
155
|
-
...defaultConfigOptions,
|
|
150
|
+
...exports.defaultConfigOptions,
|
|
156
151
|
...optionsFromConfigFiles,
|
|
157
152
|
...optionsFromCliArgs,
|
|
158
153
|
};
|
|
@@ -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];
|
|
@@ -25,8 +29,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
29
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
26
30
|
const os_1 = __importDefault(require("os"));
|
|
27
31
|
const nock_1 = __importDefault(require("nock"));
|
|
28
|
-
const git = __importStar(require("../
|
|
29
|
-
const logger = __importStar(require("../
|
|
32
|
+
const git = __importStar(require("../lib/git"));
|
|
33
|
+
const logger = __importStar(require("../lib/logger"));
|
|
30
34
|
const mockConfigFiles_1 = require("../test/mockConfigFiles");
|
|
31
35
|
const nockHelpers_1 = require("../test/nockHelpers");
|
|
32
36
|
const options_1 = require("./options");
|
|
@@ -60,29 +64,23 @@ describe('getOptions', () => {
|
|
|
60
64
|
projectConfig: defaultConfigs.projectConfig,
|
|
61
65
|
globalConfig: { accessToken: undefined },
|
|
62
66
|
});
|
|
63
|
-
await expect(() => (0, options_1.getOptions)(
|
|
64
|
-
|
|
67
|
+
await expect(() => (0, options_1.getOptions)({
|
|
68
|
+
optionsFromCliArgs: {},
|
|
69
|
+
optionsFromModule: {},
|
|
70
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
65
71
|
"Please update your config file: \\"/myHomeDir/.backport/config.json\\".
|
|
66
72
|
It must contain a valid \\"accessToken\\".
|
|
67
73
|
|
|
68
74
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
|
|
69
75
|
`);
|
|
70
76
|
});
|
|
71
|
-
it('when accessToken is missing with --ci', async () => {
|
|
72
|
-
(0, mockConfigFiles_1.mockConfigFiles)({
|
|
73
|
-
projectConfig: defaultConfigs.projectConfig,
|
|
74
|
-
globalConfig: { accessToken: undefined },
|
|
75
|
-
});
|
|
76
|
-
await expect(() => (0, options_1.getOptions)([], { ci: true })).rejects.toThrowErrorMatchingInlineSnapshot(`"Access token missing. It must be explicitly supplied when using \\"--ci\\" option. Example: --access-token very-secret"`);
|
|
77
|
-
});
|
|
78
77
|
it('when `targetBranches`, `targetBranchChoices` and `branchLabelMapping` are all empty', async () => {
|
|
79
78
|
mockProjectConfig({
|
|
80
79
|
targetBranches: undefined,
|
|
81
80
|
targetBranchChoices: undefined,
|
|
82
81
|
branchLabelMapping: undefined,
|
|
83
82
|
});
|
|
84
|
-
await expect(() => (0, options_1.getOptions)(
|
|
85
|
-
.toThrowErrorMatchingInlineSnapshot(`
|
|
83
|
+
await expect(() => (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
86
84
|
"Please specify a target branch: \\"--branch 6.1\\".
|
|
87
85
|
|
|
88
86
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
@@ -90,14 +88,22 @@ describe('getOptions', () => {
|
|
|
90
88
|
});
|
|
91
89
|
describe('whe option is an empty string', () => {
|
|
92
90
|
it('throws for "username"', async () => {
|
|
93
|
-
await expect(() => (0, options_1.getOptions)(
|
|
91
|
+
await expect(() => (0, options_1.getOptions)({
|
|
92
|
+
optionsFromCliArgs: {},
|
|
93
|
+
optionsFromModule: { repoForkOwner: '', author: 'sqren' },
|
|
94
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"repoForkOwner\\" cannot be empty!"`);
|
|
94
95
|
});
|
|
95
96
|
it('throws for "author"', async () => {
|
|
96
|
-
await expect(() => (0, options_1.getOptions)(
|
|
97
|
+
await expect(() => (0, options_1.getOptions)({
|
|
98
|
+
optionsFromCliArgs: {},
|
|
99
|
+
optionsFromModule: { author: '' },
|
|
100
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"author\\" cannot be empty!"`);
|
|
97
101
|
});
|
|
98
102
|
it('throws for "accessToken"', async () => {
|
|
99
|
-
await expect(() => (0, options_1.getOptions)(
|
|
100
|
-
|
|
103
|
+
await expect(() => (0, options_1.getOptions)({
|
|
104
|
+
optionsFromCliArgs: {},
|
|
105
|
+
optionsFromModule: { accessToken: '' },
|
|
106
|
+
})).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
101
107
|
"Please update your config file: \\"/myHomeDir/.backport/config.json\\".
|
|
102
108
|
It must contain a valid \\"accessToken\\".
|
|
103
109
|
|
|
@@ -111,8 +117,7 @@ describe('getOptions', () => {
|
|
|
111
117
|
});
|
|
112
118
|
it('should throw if there are no remotes', async () => {
|
|
113
119
|
jest.spyOn(git, 'getRepoInfoFromGitRemotes').mockResolvedValue([]);
|
|
114
|
-
await expect(() => (0, options_1.getOptions)(
|
|
115
|
-
.toThrowErrorMatchingInlineSnapshot(`
|
|
120
|
+
await expect(() => (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
116
121
|
"Please specify a repository: \\"--repo elastic/kibana\\".
|
|
117
122
|
|
|
118
123
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
@@ -127,7 +132,10 @@ describe('getOptions', () => {
|
|
|
127
132
|
jest
|
|
128
133
|
.spyOn(git, 'getRepoInfoFromGitRemotes')
|
|
129
134
|
.mockResolvedValue([{ repoName: 'kibana', repoOwner: 'sqren' }]);
|
|
130
|
-
const options = await (0, options_1.getOptions)(
|
|
135
|
+
const options = await (0, options_1.getOptions)({
|
|
136
|
+
optionsFromCliArgs: {},
|
|
137
|
+
optionsFromModule: {},
|
|
138
|
+
});
|
|
131
139
|
expect(options.repoName).toBe('kibana');
|
|
132
140
|
expect(options.repoOwner).toBe('elastic');
|
|
133
141
|
});
|
|
@@ -135,7 +143,10 @@ describe('getOptions', () => {
|
|
|
135
143
|
});
|
|
136
144
|
it('reads options from remote config', async () => {
|
|
137
145
|
mockGithubConfigOptions({ hasRemoteConfig: true });
|
|
138
|
-
const options = await (0, options_1.getOptions)(
|
|
146
|
+
const options = await (0, options_1.getOptions)({
|
|
147
|
+
optionsFromCliArgs: {},
|
|
148
|
+
optionsFromModule: {},
|
|
149
|
+
});
|
|
139
150
|
expect(options.branchLabelMapping).toEqual({
|
|
140
151
|
'^v8.2.0$': 'option-from-remote',
|
|
141
152
|
});
|
|
@@ -143,25 +154,31 @@ describe('getOptions', () => {
|
|
|
143
154
|
});
|
|
144
155
|
it('should ensure that "backport" branch does not exist', async () => {
|
|
145
156
|
mockGithubConfigOptions({ hasBackportBranch: true });
|
|
146
|
-
await expect((0, options_1.getOptions)(
|
|
157
|
+
await expect((0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} })).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
147
158
|
});
|
|
148
159
|
it('should merge config options and module options', async () => {
|
|
149
160
|
mockGithubConfigOptions({});
|
|
150
161
|
const myFn = async () => true;
|
|
151
|
-
const options = await (0, options_1.getOptions)(
|
|
162
|
+
const options = await (0, options_1.getOptions)({
|
|
163
|
+
optionsFromCliArgs: {},
|
|
164
|
+
optionsFromModule: { autoFixConflicts: myFn },
|
|
165
|
+
});
|
|
152
166
|
expect(options.autoFixConflicts).toBe(myFn);
|
|
153
167
|
});
|
|
154
|
-
it('should call
|
|
168
|
+
it('should call setAccessToken', async () => {
|
|
155
169
|
mockGithubConfigOptions({});
|
|
156
|
-
await (0, options_1.getOptions)(
|
|
157
|
-
expect(logger.
|
|
170
|
+
await (0, options_1.getOptions)({ optionsFromCliArgs: {}, optionsFromModule: {} });
|
|
171
|
+
expect(logger.setAccessToken).toHaveBeenCalledTimes(1);
|
|
158
172
|
});
|
|
159
173
|
it('should return options', async () => {
|
|
160
174
|
mockGithubConfigOptions({
|
|
161
175
|
viewerLogin: 'john.diller',
|
|
162
176
|
defaultBranchRef: 'default-branch-from-github',
|
|
163
177
|
});
|
|
164
|
-
const options = await (0, options_1.getOptions)(
|
|
178
|
+
const options = await (0, options_1.getOptions)({
|
|
179
|
+
optionsFromCliArgs: {},
|
|
180
|
+
optionsFromModule: {},
|
|
181
|
+
});
|
|
165
182
|
expect(options).toEqual({
|
|
166
183
|
accessToken: 'abc',
|
|
167
184
|
assignees: [],
|
|
@@ -172,7 +189,6 @@ describe('getOptions', () => {
|
|
|
172
189
|
autoMergeMethod: 'merge',
|
|
173
190
|
backportBinary: 'backport',
|
|
174
191
|
cherrypickRef: true,
|
|
175
|
-
ci: false,
|
|
176
192
|
commitPaths: [],
|
|
177
193
|
cwd: expect.any(String),
|
|
178
194
|
dateSince: null,
|
|
@@ -182,11 +198,14 @@ describe('getOptions', () => {
|
|
|
182
198
|
fork: true,
|
|
183
199
|
gitHostname: 'github.com',
|
|
184
200
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
201
|
+
interactive: true,
|
|
185
202
|
maxNumber: 10,
|
|
186
203
|
multipleBranches: true,
|
|
187
204
|
multipleCommits: false,
|
|
188
205
|
noVerify: true,
|
|
189
|
-
|
|
206
|
+
publishStatusCommentOnAbort: false,
|
|
207
|
+
publishStatusCommentOnSuccess: true,
|
|
208
|
+
publishStatusCommentOnFailure: false,
|
|
190
209
|
repoForkOwner: 'john.diller',
|
|
191
210
|
repoName: 'kibana',
|
|
192
211
|
repoOwner: 'elastic',
|
|
@@ -197,7 +216,6 @@ describe('getOptions', () => {
|
|
|
197
216
|
targetBranchChoices: ['7.9', '8.0'],
|
|
198
217
|
targetBranches: [],
|
|
199
218
|
targetPRLabels: [],
|
|
200
|
-
verbose: false,
|
|
201
219
|
});
|
|
202
220
|
});
|
|
203
221
|
describe('sourceBranch', () => {
|
|
@@ -205,11 +223,17 @@ describe('getOptions', () => {
|
|
|
205
223
|
mockGithubConfigOptions({ defaultBranchRef: 'some-default-branch' });
|
|
206
224
|
});
|
|
207
225
|
it('uses the `defaultBranchRef` as default', async () => {
|
|
208
|
-
const options = await (0, options_1.getOptions)(
|
|
226
|
+
const options = await (0, options_1.getOptions)({
|
|
227
|
+
optionsFromCliArgs: {},
|
|
228
|
+
optionsFromModule: {},
|
|
229
|
+
});
|
|
209
230
|
expect(options.sourceBranch).toBe('some-default-branch');
|
|
210
231
|
});
|
|
211
232
|
it('uses the sourceBranch given via cli instead of `defaultBranchRef`', async () => {
|
|
212
|
-
const options = await (0, options_1.getOptions)(
|
|
233
|
+
const options = await (0, options_1.getOptions)({
|
|
234
|
+
optionsFromCliArgs: { sourceBranch: 'cli-source-branch' },
|
|
235
|
+
optionsFromModule: {},
|
|
236
|
+
});
|
|
213
237
|
expect(options.sourceBranch).toBe('cli-source-branch');
|
|
214
238
|
});
|
|
215
239
|
});
|
|
@@ -218,16 +242,25 @@ describe('getOptions', () => {
|
|
|
218
242
|
mockGithubConfigOptions({});
|
|
219
243
|
});
|
|
220
244
|
it('is enabled by default', async () => {
|
|
221
|
-
const { fork } = await (0, options_1.getOptions)(
|
|
245
|
+
const { fork } = await (0, options_1.getOptions)({
|
|
246
|
+
optionsFromCliArgs: {},
|
|
247
|
+
optionsFromModule: {},
|
|
248
|
+
});
|
|
222
249
|
expect(fork).toBe(true);
|
|
223
250
|
});
|
|
224
|
-
it('can be disabled via
|
|
225
|
-
const { fork } = await (0, options_1.getOptions)(
|
|
251
|
+
it('can be disabled via cli', async () => {
|
|
252
|
+
const { fork } = await (0, options_1.getOptions)({
|
|
253
|
+
optionsFromCliArgs: { fork: false },
|
|
254
|
+
optionsFromModule: {},
|
|
255
|
+
});
|
|
226
256
|
expect(fork).toBe(false);
|
|
227
257
|
});
|
|
228
258
|
it('can be disabled via config file', async () => {
|
|
229
259
|
mockProjectConfig({ fork: false });
|
|
230
|
-
const { fork } = await (0, options_1.getOptions)(
|
|
260
|
+
const { fork } = await (0, options_1.getOptions)({
|
|
261
|
+
optionsFromCliArgs: {},
|
|
262
|
+
optionsFromModule: {},
|
|
263
|
+
});
|
|
231
264
|
expect(fork).toBe(false);
|
|
232
265
|
});
|
|
233
266
|
});
|
|
@@ -235,13 +268,19 @@ describe('getOptions', () => {
|
|
|
235
268
|
beforeEach(() => {
|
|
236
269
|
mockGithubConfigOptions({});
|
|
237
270
|
});
|
|
238
|
-
it('can be set via
|
|
239
|
-
const { reviewers } = await (0, options_1.getOptions)(
|
|
271
|
+
it('can be set via cli', async () => {
|
|
272
|
+
const { reviewers } = await (0, options_1.getOptions)({
|
|
273
|
+
optionsFromCliArgs: { reviewers: ['peter'] },
|
|
274
|
+
optionsFromModule: {},
|
|
275
|
+
});
|
|
240
276
|
expect(reviewers).toEqual(['peter']);
|
|
241
277
|
});
|
|
242
278
|
it('can be set via config file', async () => {
|
|
243
279
|
mockProjectConfig({ reviewers: ['john'] });
|
|
244
|
-
const { reviewers } = await (0, options_1.getOptions)(
|
|
280
|
+
const { reviewers } = await (0, options_1.getOptions)({
|
|
281
|
+
optionsFromCliArgs: {},
|
|
282
|
+
optionsFromModule: {},
|
|
283
|
+
});
|
|
245
284
|
expect(reviewers).toEqual(['john']);
|
|
246
285
|
});
|
|
247
286
|
});
|
|
@@ -250,15 +289,24 @@ describe('getOptions', () => {
|
|
|
250
289
|
mockGithubConfigOptions({});
|
|
251
290
|
});
|
|
252
291
|
it('is not enabled by default', async () => {
|
|
253
|
-
const { mainline } = await (0, options_1.getOptions)(
|
|
292
|
+
const { mainline } = await (0, options_1.getOptions)({
|
|
293
|
+
optionsFromCliArgs: {},
|
|
294
|
+
optionsFromModule: {},
|
|
295
|
+
});
|
|
254
296
|
expect(mainline).toBe(undefined);
|
|
255
297
|
});
|
|
256
298
|
it('can be set via `--mainline` flag', async () => {
|
|
257
|
-
const { mainline } = await (0, options_1.getOptions)(
|
|
299
|
+
const { mainline } = await (0, options_1.getOptions)({
|
|
300
|
+
optionsFromCliArgs: { mainline: 1 },
|
|
301
|
+
optionsFromModule: {},
|
|
302
|
+
});
|
|
258
303
|
expect(mainline).toBe(1);
|
|
259
304
|
});
|
|
260
305
|
it('accepts numeric values', async () => {
|
|
261
|
-
const { mainline } = await (0, options_1.getOptions)(
|
|
306
|
+
const { mainline } = await (0, options_1.getOptions)({
|
|
307
|
+
optionsFromCliArgs: { mainline: 2 },
|
|
308
|
+
optionsFromModule: {},
|
|
309
|
+
});
|
|
262
310
|
expect(mainline).toBe(2);
|
|
263
311
|
});
|
|
264
312
|
});
|
|
@@ -267,25 +315,33 @@ describe('getOptions', () => {
|
|
|
267
315
|
mockGithubConfigOptions({ viewerLogin: 'billy.bob' });
|
|
268
316
|
});
|
|
269
317
|
it('defaults to authenticated user', async () => {
|
|
270
|
-
const { author } = await (0, options_1.getOptions)(
|
|
318
|
+
const { author } = await (0, options_1.getOptions)({
|
|
319
|
+
optionsFromCliArgs: {},
|
|
320
|
+
optionsFromModule: {},
|
|
321
|
+
});
|
|
271
322
|
expect(author).toBe('billy.bob');
|
|
272
323
|
});
|
|
273
324
|
it('can be overridden via `--author` flag', async () => {
|
|
274
|
-
const { author } = await (0, options_1.getOptions)(
|
|
325
|
+
const { author } = await (0, options_1.getOptions)({
|
|
326
|
+
optionsFromCliArgs: { author: 'john.doe' },
|
|
327
|
+
optionsFromModule: {},
|
|
328
|
+
});
|
|
275
329
|
expect(author).toBe('john.doe');
|
|
276
330
|
});
|
|
277
|
-
it('can be reset via `--all` flag', async () => {
|
|
278
|
-
const { author } = await (0, options_1.getOptions)(['--all'], {});
|
|
279
|
-
expect(author).toBe(null);
|
|
280
|
-
});
|
|
281
331
|
it('can be reset via config file (similar to `--all` flag)', async () => {
|
|
282
332
|
mockProjectConfig({ author: null });
|
|
283
|
-
const { author } = await (0, options_1.getOptions)(
|
|
333
|
+
const { author } = await (0, options_1.getOptions)({
|
|
334
|
+
optionsFromCliArgs: {},
|
|
335
|
+
optionsFromModule: {},
|
|
336
|
+
});
|
|
284
337
|
expect(author).toBe(null);
|
|
285
338
|
});
|
|
286
339
|
it('can be overridden via config file', async () => {
|
|
287
340
|
mockProjectConfig({ author: 'jane.doe' });
|
|
288
|
-
const { author } = await (0, options_1.getOptions)(
|
|
341
|
+
const { author } = await (0, options_1.getOptions)({
|
|
342
|
+
optionsFromCliArgs: {},
|
|
343
|
+
optionsFromModule: {},
|
|
344
|
+
});
|
|
289
345
|
expect(author).toBe('jane.doe');
|
|
290
346
|
});
|
|
291
347
|
});
|
|
@@ -294,21 +350,26 @@ describe('getOptions', () => {
|
|
|
294
350
|
mockGithubConfigOptions({});
|
|
295
351
|
});
|
|
296
352
|
it('should default to true', async () => {
|
|
297
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(
|
|
353
|
+
const { cherrypickRef } = await (0, options_1.getOptions)({
|
|
354
|
+
optionsFromCliArgs: {},
|
|
355
|
+
optionsFromModule: {},
|
|
356
|
+
});
|
|
298
357
|
expect(cherrypickRef).toBe(true);
|
|
299
358
|
});
|
|
300
|
-
it('should negate with `noCherrypickRef` cli arg', async () => {
|
|
301
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(['--no-cherrypick-ref'], {});
|
|
302
|
-
expect(cherrypickRef).toBe(false);
|
|
303
|
-
});
|
|
304
359
|
it('should be settable via config file', async () => {
|
|
305
360
|
mockProjectConfig({ cherrypickRef: false });
|
|
306
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(
|
|
361
|
+
const { cherrypickRef } = await (0, options_1.getOptions)({
|
|
362
|
+
optionsFromCliArgs: {},
|
|
363
|
+
optionsFromModule: {},
|
|
364
|
+
});
|
|
307
365
|
expect(cherrypickRef).toBe(false);
|
|
308
366
|
});
|
|
309
367
|
it('cli args overwrites config', async () => {
|
|
310
368
|
mockProjectConfig({ cherrypickRef: false });
|
|
311
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(
|
|
369
|
+
const { cherrypickRef } = await (0, options_1.getOptions)({
|
|
370
|
+
optionsFromCliArgs: { cherrypickRef: true },
|
|
371
|
+
optionsFromModule: {},
|
|
372
|
+
});
|
|
312
373
|
expect(cherrypickRef).toBe(true);
|
|
313
374
|
});
|
|
314
375
|
});
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
+
import { BackportError } from './lib/BackportError';
|
|
2
|
+
import { GitConfigAuthor } from './lib/getGitConfigAuthor';
|
|
3
|
+
import { Commit } from './lib/sourceCommit/parseSourceCommit';
|
|
1
4
|
import { ValidConfigOptions } from './options/options';
|
|
2
|
-
|
|
3
|
-
import { Commit } from './services/sourceCommit/parseSourceCommit';
|
|
4
|
-
import { GitConfigAuthor } from './ui/getGitConfigAuthor';
|
|
5
|
-
export declare type Result = {
|
|
5
|
+
export declare type SuccessResult = {
|
|
6
6
|
status: 'success';
|
|
7
7
|
didUpdate: boolean;
|
|
8
8
|
targetBranch: string;
|
|
9
9
|
pullRequestUrl: string;
|
|
10
10
|
pullRequestNumber: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
11
|
+
};
|
|
12
|
+
export declare type HandledErrorResult = {
|
|
13
|
+
status: 'handled-error';
|
|
14
|
+
targetBranch: string;
|
|
15
|
+
error: BackportError;
|
|
16
|
+
};
|
|
17
|
+
export declare type UnhandledErrorResult = {
|
|
18
|
+
status: 'unhandled-error';
|
|
13
19
|
targetBranch: string;
|
|
14
|
-
error:
|
|
20
|
+
error: Error;
|
|
15
21
|
};
|
|
22
|
+
export declare type Result = SuccessResult | HandledErrorResult | UnhandledErrorResult;
|
|
16
23
|
export declare function runSequentially({ options, commits, targetBranches, gitConfigAuthor, }: {
|
|
17
24
|
options: ValidConfigOptions;
|
|
18
25
|
commits: Commit[];
|