backport 5.6.3 → 6.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 +48 -39
- package/dist/entrypoint.cli.js +1 -1
- package/dist/entrypoint.module.d.ts +6 -5
- package/dist/entrypoint.module.js +8 -6
- package/dist/ink.d.ts +1 -0
- package/dist/ink.js +49 -0
- package/dist/main.d.ts +11 -6
- package/dist/main.js +40 -24
- package/dist/options/ConfigOptions.d.ts +47 -39
- package/dist/options/cliArgs.d.ts +28 -34
- package/dist/options/cliArgs.js +113 -94
- package/dist/options/cliArgs.test.js +103 -119
- package/dist/options/config/config.d.ts +81 -2
- package/dist/options/config/config.js +46 -6
- package/dist/options/config/config.test.js +24 -2
- package/dist/options/config/getOptionsFromGit.d.ts +3 -0
- package/dist/options/config/getOptionsFromGit.js +10 -0
- package/dist/options/config/globalConfig.d.ts +2 -1
- package/dist/options/config/globalConfig.js +8 -8
- package/dist/options/config/globalConfig.test.js +7 -3
- package/dist/options/config/projectConfig.d.ts +2 -1
- package/dist/options/config/projectConfig.js +3 -3
- package/dist/options/config/projectConfig.test.js +4 -4
- package/dist/options/config/readConfigFile.d.ts +2 -2
- package/dist/options/config/readConfigFile.js +3 -3
- package/dist/options/options.d.ts +40 -27
- package/dist/options/options.js +8 -16
- package/dist/options/options.test.js +66 -26
- package/dist/options/parseRequiredOptions.d.ts +71 -0
- package/dist/options/parseRequiredOptions.js +70 -0
- package/dist/options/parseRequiredOptions.test.d.ts +1 -0
- package/dist/options/parseRequiredOptions.test.js +127 -0
- package/dist/runSequentially.d.ts +20 -0
- package/dist/runSequentially.js +41 -0
- package/dist/runSequentially.test.d.ts +1 -0
- package/dist/runSequentially.test.js +235 -0
- package/dist/runWithOptions.js +7 -14
- package/dist/runWithOptions.test.js +142 -16
- package/dist/scripts/generate-gql.d.ts +1 -0
- package/dist/scripts/generate-gql.js +15 -0
- package/dist/scripts/postinstall.js +4 -4
- package/dist/scripts/postinstall.test.js +9 -2
- package/dist/scripts/runPostinstall.js +1 -1
- package/dist/services/HandledError.d.ts +11 -1
- package/dist/services/HandledError.js +2 -1
- package/dist/services/child-process-promisified.d.ts +1 -1
- package/dist/services/child-process-promisified.js +2 -2
- package/dist/services/env.js +5 -5
- package/dist/services/env.test.js +11 -4
- package/dist/services/fs-promisified.js +4 -4
- package/dist/services/getExpectedTarget.d.ts +9 -0
- package/dist/services/getExpectedTarget.js +77 -0
- package/dist/services/getExpectedTargetPullRequests.d.ts +9 -0
- package/dist/services/getExpectedTargetPullRequests.js +77 -0
- package/dist/services/git.d.ts +19 -4
- package/dist/services/git.integration.test.d.ts +1 -0
- package/dist/services/git.integration.test.js +168 -0
- package/dist/services/git.js +129 -57
- package/dist/services/git.test.js +155 -51
- package/dist/services/github/commitFormatters.d.ts +3 -7
- package/dist/services/github/commitFormatters.js +10 -19
- package/dist/services/github/commitFormatters.test.js +2 -24
- package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.js +2 -6
- package/dist/services/github/v3/addAssigneesToPullRequest.test.js +2 -3
- package/dist/services/github/v3/addLabelsToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addLabelsToPullRequest.js +2 -6
- package/dist/services/github/v3/addReviewersToPullRequest.d.ts +2 -0
- package/dist/services/github/v3/addReviewersToPullRequest.js +34 -0
- package/dist/services/github/v3/createPullRequest.d.ts +3 -2
- package/dist/services/github/v3/createPullRequest.js +33 -24
- package/dist/services/github/v3/createStatusComment.d.ts +11 -0
- package/dist/services/github/v3/createStatusComment.js +97 -0
- package/dist/services/github/v3/createStatusComment.test.d.ts +1 -0
- package/dist/services/github/v3/createStatusComment.test.js +209 -0
- package/dist/services/github/v4/FetchPullRequestId.d.ts +9 -0
- package/dist/services/github/v4/FetchPullRequestId.js +32 -0
- package/dist/services/github/v4/apiRequestV4.d.ts +1 -1
- package/dist/services/github/v4/apiRequestV4.js +8 -10
- package/dist/services/github/v4/apiRequestV4.test.js +7 -7
- package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +9 -0
- package/dist/services/github/v4/disablePullRequestAutoMerge.js +28 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +9 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +51 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +113 -0
- package/dist/services/github/v4/fetchAuthorId.d.ts +5 -0
- package/dist/services/github/v4/fetchAuthorId.js +1 -1
- package/dist/services/github/v4/fetchAuthorId.private.test.js +3 -3
- package/dist/services/github/v4/fetchCommitByPullNumber.js +11 -9
- package/dist/services/github/v4/fetchCommitByPullNumber.private.test.js +6 -6
- package/dist/services/github/v4/fetchCommitBySha.js +14 -12
- package/dist/services/github/v4/fetchCommitBySha.private.test.js +7 -5
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +5 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +46 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +67 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +5 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +36 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +55 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +16 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +90 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +130 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +127 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.d.ts +28 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.js +52 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +10 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +49 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +81 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.js +252 -0
- package/dist/services/github/v4/fetchCommitsByAuthor.d.ts +3 -2
- package/dist/services/github/v4/fetchCommitsByAuthor.js +81 -70
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.js +81 -8
- package/dist/services/github/v4/fetchCommitsByAuthor.test.js +29 -21
- package/dist/services/github/v4/fetchDefaultBranch.d.ts +1 -1
- package/dist/services/github/v4/fetchDefaultBranch.js +1 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +4 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.js +52 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +32 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.d.ts +4 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.js +72 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.js +34 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.d.ts +40 -0
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.js +72 -0
- package/dist/services/github/v4/fetchExistingPullRequest.js +2 -3
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +3 -3
- package/dist/services/github/v4/fetchMergedPullRequests.d.ts +19 -20
- package/dist/services/github/v4/fetchMergedPullRequests.js +22 -68
- package/dist/services/github/v4/fetchMergedPullRequests.private.test.js +8 -9
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +11 -0
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +35 -0
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.d.ts +1 -1
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.js +12 -10
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.js +8 -6
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.js +2 -2
- package/dist/services/github/v4/getExistingTargetPullRequests.d.ts +4 -58
- package/dist/services/github/v4/getExistingTargetPullRequests.js +3 -58
- package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +61 -0
- package/dist/services/github/v4/getOptionsFromGithub/index.js +139 -0
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.d.ts +1 -0
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +126 -0
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +34 -0
- package/dist/services/github/v4/getOptionsFromGithub/query.js +44 -0
- package/dist/services/github/v4/getTargetBranchesFromLabels.d.ts +0 -7
- package/dist/services/github/v4/getTargetBranchesFromLabels.js +1 -26
- package/dist/services/github/v4/getTargetBranchesFromLabels.test.js +69 -32
- package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +2 -2
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +39 -25
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.d.ts +2 -2
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.js +10 -0
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.d.ts +2 -2
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.js +4 -1
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.d.ts +1 -1
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.js +1 -0
- package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +1 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -15
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +7 -7
- package/dist/services/logger.d.ts +3 -3
- package/dist/services/logger.js +24 -24
- package/dist/services/prompt.test.d.ts +1 -0
- package/dist/services/prompt.test.js +87 -0
- package/dist/services/prompts.d.ts +10 -4
- package/dist/services/prompts.js +85 -22
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +9 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +92 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +396 -0
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +21 -0
- package/dist/services/sourceCommit/getMockSourceCommit.js +67 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.d.ts +5 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.js +20 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.d.ts +1 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.js +201 -0
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +78 -0
- package/dist/services/sourceCommit/parseSourceCommit.js +96 -0
- package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +1 -0
- package/dist/services/sourceCommit/parseSourceCommit.test.js +114 -0
- package/dist/services/sourceCommit/sourceCommit.d.ts +78 -0
- package/dist/services/sourceCommit/sourceCommit.js +86 -0
- package/dist/services/sourceCommit/sourceCommit.test.d.ts +1 -0
- package/dist/services/sourceCommit/sourceCommit.test.js +287 -0
- package/dist/services/sourceCommit.d.ts +78 -0
- package/dist/services/sourceCommit.js +86 -0
- package/dist/services/sourceCommit.test.d.ts +1 -0
- package/dist/services/sourceCommit.test.js +280 -0
- package/dist/test/inquirer.private.test.js +81 -45
- package/dist/test/integration/createSpies.d.ts +1 -1
- package/dist/test/integration/createSpies.js +21 -9
- package/dist/test/integration/envConstants.js +5 -6
- package/dist/test/integration/helpers.js +1 -1
- package/dist/test/integration/integration.private.test.d.ts +1 -0
- package/dist/test/integration/integration.private.test.js +308 -0
- package/dist/test/integration/integration.test.js +30 -31
- package/dist/test/nockHelpers.d.ts +2 -2
- package/dist/test/nockHelpers.js +3 -7
- package/dist/test/setupFiles/automatic-mocks.d.ts +0 -1
- package/dist/test/setupFiles/automatic-mocks.js +0 -22
- package/dist/types/Commit.d.ts +85 -0
- package/dist/types/Commit.js +139 -0
- package/dist/types/commitNode.d.ts +89 -0
- package/dist/types/commitNode.js +139 -0
- package/dist/types/commitNode.test.d.ts +1 -0
- package/dist/types/commitNode.test.js +255 -0
- package/dist/types/commitWithAssociatedPullRequests.d.ts +86 -0
- package/dist/types/commitWithAssociatedPullRequests.js +145 -0
- package/dist/ui/cherrypickAndCreatePullRequest.test.js +277 -59
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +11 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +135 -67
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +468 -0
- package/dist/ui/getCommits.d.ts +1 -1
- package/dist/ui/getCommits.js +55 -25
- package/dist/ui/getTargetBranches.d.ts +2 -2
- package/dist/ui/getTargetBranches.js +16 -17
- package/dist/ui/getTargetBranches.test.js +75 -99
- package/dist/ui/getTargetBranchesFromLabels.d.ts +6 -0
- package/dist/ui/getTargetBranchesFromLabels.js +40 -0
- package/dist/ui/getTargetBranchesFromLabels.test.d.ts +1 -0
- package/dist/ui/getTargetBranchesFromLabels.test.js +288 -0
- package/dist/ui/maybeSetupRepo.js +9 -9
- package/dist/ui/maybeSetupRepo.test.js +5 -1
- package/package.json +36 -51
- package/yarn.lock +2387 -2979
|
@@ -1,2 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare
|
|
1
|
+
import { ConfigFileOptions } from '../ConfigOptions';
|
|
2
|
+
export declare const defaultConfigOptions: {
|
|
3
|
+
all: boolean;
|
|
4
|
+
assignees: string[];
|
|
5
|
+
autoAssign: boolean;
|
|
6
|
+
autoMerge: boolean;
|
|
7
|
+
autoMergeMethod: string;
|
|
8
|
+
ci: boolean;
|
|
9
|
+
cherrypickRef: boolean;
|
|
10
|
+
details: boolean;
|
|
11
|
+
fork: boolean;
|
|
12
|
+
gitHostname: string;
|
|
13
|
+
githubApiBaseUrlV3: string;
|
|
14
|
+
githubApiBaseUrlV4: string;
|
|
15
|
+
maxNumber: number;
|
|
16
|
+
multipleBranches: boolean;
|
|
17
|
+
multipleCommits: boolean;
|
|
18
|
+
noVerify: boolean;
|
|
19
|
+
prTitle: string;
|
|
20
|
+
resetAuthor: boolean;
|
|
21
|
+
sourcePRLabels: never[];
|
|
22
|
+
targetBranchChoices: never[];
|
|
23
|
+
targetBranches: never[];
|
|
24
|
+
targetPRLabels: never[];
|
|
25
|
+
verbose: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare type OptionsFromConfigFiles = Awaited<ReturnType<typeof getOptionsFromConfigFiles>>;
|
|
28
|
+
export declare function getOptionsFromConfigFiles(optionsFromModule?: ConfigFileOptions): Promise<{
|
|
29
|
+
targetPRLabels: string[];
|
|
30
|
+
targetBranchChoices: import("../ConfigOptions").TargetBranchChoiceOrString[];
|
|
31
|
+
accessToken?: string | undefined;
|
|
32
|
+
all: boolean;
|
|
33
|
+
assignees: string[];
|
|
34
|
+
author?: string | undefined;
|
|
35
|
+
autoAssign: boolean;
|
|
36
|
+
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
37
|
+
files: string[];
|
|
38
|
+
directory: string;
|
|
39
|
+
logger: {
|
|
40
|
+
error: (message: string, meta?: unknown) => void;
|
|
41
|
+
warn: (message: string, meta?: unknown) => void;
|
|
42
|
+
info: (message: string, meta?: unknown) => void;
|
|
43
|
+
verbose: (message: string, meta?: unknown) => void;
|
|
44
|
+
debug: (message: string, meta?: unknown) => void;
|
|
45
|
+
};
|
|
46
|
+
targetBranch: string;
|
|
47
|
+
}) => boolean | Promise<boolean>) | undefined;
|
|
48
|
+
autoMerge: boolean;
|
|
49
|
+
autoMergeMethod: string;
|
|
50
|
+
ci: boolean;
|
|
51
|
+
cherrypickRef: boolean;
|
|
52
|
+
commitPaths?: string[] | undefined;
|
|
53
|
+
details: boolean;
|
|
54
|
+
editor?: string | undefined;
|
|
55
|
+
forceLocalConfig?: boolean | undefined;
|
|
56
|
+
fork: boolean;
|
|
57
|
+
gitHostname: string;
|
|
58
|
+
githubApiBaseUrlV3: string;
|
|
59
|
+
githubApiBaseUrlV4: string;
|
|
60
|
+
maxNumber: number;
|
|
61
|
+
multiple?: boolean | undefined;
|
|
62
|
+
multipleBranches: boolean;
|
|
63
|
+
multipleCommits: boolean;
|
|
64
|
+
noVerify: boolean;
|
|
65
|
+
prDescription?: string | undefined;
|
|
66
|
+
prFilter?: string | undefined;
|
|
67
|
+
prTitle: string;
|
|
68
|
+
pullNumber?: number | undefined;
|
|
69
|
+
resetAuthor: boolean;
|
|
70
|
+
reviewers?: string[] | undefined;
|
|
71
|
+
sha?: string | undefined;
|
|
72
|
+
sourceBranch?: string | undefined;
|
|
73
|
+
sourcePRLabels: string[] | never[];
|
|
74
|
+
targetBranches: string[] | never[];
|
|
75
|
+
upstream: string | undefined;
|
|
76
|
+
username?: string | undefined;
|
|
77
|
+
verbose: boolean;
|
|
78
|
+
branchLabelMapping?: Record<string, string> | undefined;
|
|
79
|
+
branches?: import("../ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
80
|
+
labels?: string[] | undefined;
|
|
81
|
+
}>;
|
|
@@ -1,14 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOptionsFromConfigFiles = void 0;
|
|
3
|
+
exports.getOptionsFromConfigFiles = exports.defaultConfigOptions = void 0;
|
|
4
|
+
const getOptionsFromGit_1 = require("./getOptionsFromGit");
|
|
4
5
|
const globalConfig_1 = require("./globalConfig");
|
|
5
6
|
const projectConfig_1 = require("./projectConfig");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
exports.defaultConfigOptions = {
|
|
8
|
+
all: false,
|
|
9
|
+
assignees: [],
|
|
10
|
+
autoAssign: false,
|
|
11
|
+
autoMerge: false,
|
|
12
|
+
autoMergeMethod: 'merge',
|
|
13
|
+
ci: false,
|
|
14
|
+
cherrypickRef: true,
|
|
15
|
+
details: false,
|
|
16
|
+
fork: true,
|
|
17
|
+
gitHostname: 'github.com',
|
|
18
|
+
githubApiBaseUrlV3: 'https://api.github.com',
|
|
19
|
+
githubApiBaseUrlV4: 'https://api.github.com/graphql',
|
|
20
|
+
maxNumber: 10,
|
|
21
|
+
multipleBranches: true,
|
|
22
|
+
multipleCommits: false,
|
|
23
|
+
noVerify: true,
|
|
24
|
+
prTitle: '[{targetBranch}] {commitMessages}',
|
|
25
|
+
resetAuthor: false,
|
|
26
|
+
sourcePRLabels: [],
|
|
27
|
+
targetBranchChoices: [],
|
|
28
|
+
targetBranches: [],
|
|
29
|
+
targetPRLabels: [],
|
|
30
|
+
verbose: false,
|
|
31
|
+
};
|
|
32
|
+
async function getOptionsFromConfigFiles(optionsFromModule) {
|
|
33
|
+
const [gitConfig, projectConfig, globalConfig] = await Promise.all([
|
|
34
|
+
(0, getOptionsFromGit_1.getOptionsFromGit)(),
|
|
35
|
+
(0, projectConfig_1.getProjectConfig)(),
|
|
36
|
+
(0, globalConfig_1.getGlobalConfig)(optionsFromModule?.ci),
|
|
10
37
|
]);
|
|
11
38
|
// global and project config combined
|
|
12
|
-
|
|
39
|
+
const combinedConfig = {
|
|
40
|
+
...gitConfig,
|
|
41
|
+
...globalConfig,
|
|
42
|
+
...projectConfig,
|
|
43
|
+
...optionsFromModule,
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
...exports.defaultConfigOptions,
|
|
47
|
+
...combinedConfig,
|
|
48
|
+
// backwards-compatability: `labels` was renamed `targetPRLabels`
|
|
49
|
+
targetPRLabels: combinedConfig.targetPRLabels ?? combinedConfig.labels ?? [],
|
|
50
|
+
// backwards-compatability: `branches` was renamed `targetBranchChoices`
|
|
51
|
+
targetBranchChoices: combinedConfig.targetBranchChoices ?? combinedConfig.branches ?? [],
|
|
52
|
+
};
|
|
13
53
|
}
|
|
14
54
|
exports.getOptionsFromConfigFiles = getOptionsFromConfigFiles;
|
|
@@ -4,14 +4,36 @@ const config_1 = require("./config");
|
|
|
4
4
|
describe('getOptionsFromConfigFiles', () => {
|
|
5
5
|
let res;
|
|
6
6
|
beforeEach(async () => {
|
|
7
|
-
res = await config_1.getOptionsFromConfigFiles();
|
|
7
|
+
res = await (0, config_1.getOptionsFromConfigFiles)();
|
|
8
8
|
});
|
|
9
|
-
it('should return
|
|
9
|
+
it('should return values from (mock) config files incl. default values', () => {
|
|
10
10
|
expect(res).toEqual({
|
|
11
11
|
accessToken: 'myAccessToken',
|
|
12
|
+
all: false,
|
|
13
|
+
assignees: [],
|
|
14
|
+
autoAssign: false,
|
|
15
|
+
autoMerge: false,
|
|
16
|
+
autoMergeMethod: 'merge',
|
|
17
|
+
ci: false,
|
|
18
|
+
cherrypickRef: true,
|
|
19
|
+
details: false,
|
|
20
|
+
fork: true,
|
|
21
|
+
gitHostname: 'github.com',
|
|
22
|
+
githubApiBaseUrlV3: 'https://api.github.com',
|
|
23
|
+
githubApiBaseUrlV4: 'https://api.github.com/graphql',
|
|
24
|
+
maxNumber: 10,
|
|
25
|
+
multipleBranches: true,
|
|
26
|
+
multipleCommits: false,
|
|
27
|
+
noVerify: true,
|
|
28
|
+
prTitle: '[{targetBranch}] {commitMessages}',
|
|
29
|
+
resetAuthor: false,
|
|
30
|
+
sourcePRLabels: [],
|
|
12
31
|
targetBranchChoices: ['6.0', '5.9'],
|
|
32
|
+
targetBranches: [],
|
|
33
|
+
targetPRLabels: [],
|
|
13
34
|
upstream: 'backport-org/backport-demo',
|
|
14
35
|
username: 'sqren',
|
|
36
|
+
verbose: false,
|
|
15
37
|
});
|
|
16
38
|
});
|
|
17
39
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOptionsFromGit = void 0;
|
|
4
|
+
const git_1 = require("../../services/git");
|
|
5
|
+
async function getOptionsFromGit() {
|
|
6
|
+
return {
|
|
7
|
+
upstream: await (0, git_1.getUpstreamFromGitRemote)(),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
exports.getOptionsFromGit = getOptionsFromGit;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { ConfigFileOptions } from '../ConfigOptions';
|
|
2
|
+
export declare function getGlobalConfig(ci?: boolean): Promise<ConfigFileOptions | undefined>;
|
|
2
3
|
export declare function createGlobalConfigAndFolderIfNotExist(): Promise<boolean>;
|
|
3
4
|
export declare function createGlobalConfigIfNotExist(globalConfigPath: string, configTemplate: string): Promise<boolean>;
|
|
@@ -14,28 +14,28 @@ async function getGlobalConfig(ci) {
|
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
await createGlobalConfigAndFolderIfNotExist();
|
|
17
|
-
const globalConfigPath = env_1.getGlobalConfigPath();
|
|
18
|
-
return readConfigFile_1.readConfigFile(globalConfigPath);
|
|
17
|
+
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
18
|
+
return (0, readConfigFile_1.readConfigFile)(globalConfigPath);
|
|
19
19
|
}
|
|
20
20
|
exports.getGlobalConfig = getGlobalConfig;
|
|
21
21
|
async function createGlobalConfigAndFolderIfNotExist() {
|
|
22
|
-
const reposPath = env_1.getReposPath();
|
|
23
|
-
const globalConfigPath = env_1.getGlobalConfigPath();
|
|
22
|
+
const reposPath = (0, env_1.getReposPath)();
|
|
23
|
+
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
24
24
|
const configTemplate = getConfigTemplate();
|
|
25
|
-
await make_dir_1.default(reposPath);
|
|
25
|
+
await (0, make_dir_1.default)(reposPath);
|
|
26
26
|
const didCreate = await createGlobalConfigIfNotExist(globalConfigPath, configTemplate);
|
|
27
27
|
await ensureCorrectPermissions(globalConfigPath);
|
|
28
28
|
return didCreate;
|
|
29
29
|
}
|
|
30
30
|
exports.createGlobalConfigAndFolderIfNotExist = createGlobalConfigAndFolderIfNotExist;
|
|
31
31
|
function ensureCorrectPermissions(globalConfigPath) {
|
|
32
|
-
return fs_promisified_1.chmod(globalConfigPath, '600');
|
|
32
|
+
return (0, fs_promisified_1.chmod)(globalConfigPath, '600');
|
|
33
33
|
}
|
|
34
34
|
async function createGlobalConfigIfNotExist(globalConfigPath, configTemplate) {
|
|
35
35
|
try {
|
|
36
|
-
await fs_promisified_1.writeFile(globalConfigPath, configTemplate, {
|
|
36
|
+
await (0, fs_promisified_1.writeFile)(globalConfigPath, configTemplate, {
|
|
37
37
|
flag: 'wx',
|
|
38
|
-
mode: 0o600,
|
|
38
|
+
mode: 0o600, // give the owner read-write privleges, no access for others
|
|
39
39
|
});
|
|
40
40
|
return true;
|
|
41
41
|
}
|
|
@@ -22,11 +22,15 @@ 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
|
+
const os_1 = __importDefault(require("os"));
|
|
25
26
|
const make_dir_1 = __importDefault(require("make-dir"));
|
|
26
27
|
const fs = __importStar(require("../../services/fs-promisified"));
|
|
27
28
|
const globalConfig_1 = require("./globalConfig");
|
|
28
29
|
describe('config', () => {
|
|
29
30
|
afterEach(() => jest.clearAllMocks());
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
|
|
33
|
+
});
|
|
30
34
|
describe('getGlobalConfig', () => {
|
|
31
35
|
let res;
|
|
32
36
|
beforeEach(async () => {
|
|
@@ -36,7 +40,7 @@ describe('config', () => {
|
|
|
36
40
|
accessToken: 'myAccessToken',
|
|
37
41
|
username: 'sqren',
|
|
38
42
|
}));
|
|
39
|
-
res = await globalConfig_1.getGlobalConfig();
|
|
43
|
+
res = await (0, globalConfig_1.getGlobalConfig)();
|
|
40
44
|
});
|
|
41
45
|
it("should create config if it doesn't exist", () => {
|
|
42
46
|
expect(fs.writeFile).toHaveBeenCalledWith('/myHomeDir/.backport/config.json', expect.any(String), { flag: 'wx', mode: 384 });
|
|
@@ -57,7 +61,7 @@ describe('config', () => {
|
|
|
57
61
|
describe('createGlobalConfigIfNotExist', () => {
|
|
58
62
|
it('should create config and succeed', async () => {
|
|
59
63
|
jest.spyOn(fs, 'writeFile').mockResolvedValueOnce(undefined);
|
|
60
|
-
const didCreate = await globalConfig_1.createGlobalConfigIfNotExist('/path/to/globalConfig', 'myConfigTemplate');
|
|
64
|
+
const didCreate = await (0, globalConfig_1.createGlobalConfigIfNotExist)('/path/to/globalConfig', 'myConfigTemplate');
|
|
61
65
|
expect(didCreate).toEqual(true);
|
|
62
66
|
expect(fs.writeFile).toHaveBeenCalledWith('/path/to/globalConfig', expect.stringContaining('myConfigTemplate'), { flag: 'wx', mode: 384 });
|
|
63
67
|
});
|
|
@@ -65,7 +69,7 @@ describe('config', () => {
|
|
|
65
69
|
const err = new Error();
|
|
66
70
|
err.code = 'EEXIST';
|
|
67
71
|
jest.spyOn(fs, 'writeFile').mockRejectedValueOnce(err);
|
|
68
|
-
const didCreate = await globalConfig_1.createGlobalConfigIfNotExist('myPath', 'myConfigTemplate');
|
|
72
|
+
const didCreate = await (0, globalConfig_1.createGlobalConfigIfNotExist)('myPath', 'myConfigTemplate');
|
|
69
73
|
expect(didCreate).toEqual(false);
|
|
70
74
|
});
|
|
71
75
|
});
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { ConfigFileOptions } from '../ConfigOptions';
|
|
2
|
+
export declare function getProjectConfig(): Promise<ConfigFileOptions | undefined>;
|
|
@@ -7,10 +7,10 @@ exports.getProjectConfig = void 0;
|
|
|
7
7
|
const find_up_1 = __importDefault(require("find-up"));
|
|
8
8
|
const readConfigFile_1 = require("../config/readConfigFile");
|
|
9
9
|
async function getProjectConfig() {
|
|
10
|
-
const filepath = await find_up_1.default('.backportrc.json');
|
|
10
|
+
const filepath = await (0, find_up_1.default)('.backportrc.json');
|
|
11
11
|
if (!filepath) {
|
|
12
|
-
return
|
|
12
|
+
return;
|
|
13
13
|
}
|
|
14
|
-
return readConfigFile_1.readConfigFile(filepath);
|
|
14
|
+
return (0, readConfigFile_1.readConfigFile)(filepath);
|
|
15
15
|
}
|
|
16
16
|
exports.getProjectConfig = getProjectConfig;
|
|
@@ -33,7 +33,7 @@ describe('getProjectConfig', () => {
|
|
|
33
33
|
jest
|
|
34
34
|
.spyOn(fs, 'readFile')
|
|
35
35
|
.mockResolvedValueOnce(JSON.stringify({ upstream: 'elastic/kibana', branches: ['6.x'] }));
|
|
36
|
-
projectConfig = await projectConfig_1.getProjectConfig();
|
|
36
|
+
projectConfig = await (0, projectConfig_1.getProjectConfig)();
|
|
37
37
|
});
|
|
38
38
|
it('should call findUp', () => {
|
|
39
39
|
expect(find_up_1.default).toHaveBeenCalledWith('.backportrc.json');
|
|
@@ -48,15 +48,15 @@ describe('getProjectConfig', () => {
|
|
|
48
48
|
describe('when projectConfig is empty', () => {
|
|
49
49
|
it('should return empty config', async () => {
|
|
50
50
|
jest.spyOn(fs, 'readFile').mockResolvedValueOnce('{}');
|
|
51
|
-
const projectConfig = await projectConfig_1.getProjectConfig();
|
|
51
|
+
const projectConfig = await (0, projectConfig_1.getProjectConfig)();
|
|
52
52
|
expect(projectConfig).toEqual({ targetBranchChoices: undefined });
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
describe('when projectConfig is missing', () => {
|
|
56
56
|
it('should return empty config', async () => {
|
|
57
57
|
find_up_1.default.mockReturnValueOnce(undefined);
|
|
58
|
-
const projectConfig = await projectConfig_1.getProjectConfig();
|
|
59
|
-
expect(projectConfig).toEqual(
|
|
58
|
+
const projectConfig = await (0, projectConfig_1.getProjectConfig)();
|
|
59
|
+
expect(projectConfig).toEqual(undefined);
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
62
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function readConfigFile(filepath: string): Promise<
|
|
1
|
+
import { ConfigFileOptions } from '../ConfigOptions';
|
|
2
|
+
export declare function readConfigFile(filepath: string): Promise<ConfigFileOptions>;
|
|
@@ -8,13 +8,13 @@ const strip_json_comments_1 = __importDefault(require("strip-json-comments"));
|
|
|
8
8
|
const HandledError_1 = require("../../services/HandledError");
|
|
9
9
|
const fs_promisified_1 = require("../../services/fs-promisified");
|
|
10
10
|
async function readConfigFile(filepath) {
|
|
11
|
-
const fileContents = await fs_promisified_1.readFile(filepath, 'utf8');
|
|
12
|
-
const configWithoutComments = strip_json_comments_1.default(fileContents);
|
|
11
|
+
const fileContents = await (0, fs_promisified_1.readFile)(filepath, 'utf8');
|
|
12
|
+
const configWithoutComments = (0, strip_json_comments_1.default)(fileContents);
|
|
13
13
|
try {
|
|
14
14
|
return JSON.parse(configWithoutComments);
|
|
15
15
|
}
|
|
16
16
|
catch (e) {
|
|
17
|
-
throw new HandledError_1.HandledError(`"${filepath}" contains invalid JSON:\n\n${fileContents}
|
|
17
|
+
throw new HandledError_1.HandledError(`"${filepath}" contains invalid JSON:\n\n${fileContents}`);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
exports.readConfigFile = readConfigFile;
|
|
@@ -1,50 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
sourceBranch: string;
|
|
1
|
+
import { ConfigFileOptions } from './ConfigOptions';
|
|
2
|
+
export declare type ValidConfigOptions = Readonly<Awaited<ReturnType<typeof getOptions>>>;
|
|
3
|
+
export declare function getOptions(argv: string[], optionsFromModule?: ConfigFileOptions): Promise<{
|
|
4
|
+
targetBranchChoices: import("./ConfigOptions").TargetBranchChoice[];
|
|
6
5
|
accessToken: string;
|
|
7
6
|
username: string;
|
|
8
7
|
repoName: string;
|
|
9
8
|
repoOwner: string;
|
|
9
|
+
assignees: string[];
|
|
10
10
|
author: string;
|
|
11
11
|
all: boolean;
|
|
12
|
-
autoFixConflicts: (({ files, directory, logger, targetBranch, }: {
|
|
13
|
-
files: string[];
|
|
14
|
-
directory: string;
|
|
15
|
-
logger: {
|
|
16
|
-
error: (message: string, meta?: unknown) => void;
|
|
17
|
-
warn: (message: string, meta?: unknown) => void;
|
|
18
|
-
info: (message: string, meta?: unknown) => void;
|
|
19
|
-
verbose: (message: string, meta?: unknown) => void;
|
|
20
|
-
debug: (message: string, meta?: unknown) => void;
|
|
21
|
-
};
|
|
22
|
-
targetBranch: string;
|
|
23
|
-
}) => boolean | Promise<boolean>) | undefined;
|
|
24
|
-
assignees: string[];
|
|
25
|
-
branchLabelMapping: Record<string, string> | undefined;
|
|
26
12
|
multipleBranches: boolean;
|
|
27
13
|
multipleCommits: boolean;
|
|
14
|
+
commitPaths: string[];
|
|
15
|
+
reviewers: string[];
|
|
16
|
+
sourcePRLabels: (string[] | undefined) & (string[] | never[]);
|
|
17
|
+
targetBranches: (string[] | undefined) & (string[] | never[]);
|
|
18
|
+
targetPRLabels: string[];
|
|
19
|
+
cherrypickRef: boolean;
|
|
20
|
+
fork: boolean;
|
|
28
21
|
noVerify: boolean;
|
|
29
|
-
|
|
22
|
+
autoAssign: boolean;
|
|
23
|
+
autoMerge: boolean;
|
|
24
|
+
autoMergeMethod: string;
|
|
30
25
|
ci: boolean;
|
|
31
|
-
|
|
26
|
+
details: boolean;
|
|
32
27
|
editor: string | undefined;
|
|
33
|
-
|
|
28
|
+
forceLocalConfig: boolean | undefined;
|
|
34
29
|
gitHostname: string;
|
|
35
30
|
githubApiBaseUrlV3: string;
|
|
36
31
|
githubApiBaseUrlV4: string;
|
|
37
32
|
mainline: number | undefined;
|
|
38
33
|
maxNumber: number;
|
|
39
|
-
path: string | undefined;
|
|
40
|
-
prTitle: string;
|
|
41
34
|
prDescription: string | undefined;
|
|
35
|
+
prTitle: string;
|
|
42
36
|
prFilter: string | undefined;
|
|
43
37
|
pullNumber: number | undefined;
|
|
44
38
|
resetAuthor: boolean;
|
|
45
39
|
sha: string | undefined;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
targetPRLabels: string[];
|
|
40
|
+
sourceBranch: string;
|
|
41
|
+
upstream: string | undefined;
|
|
49
42
|
verbose: boolean;
|
|
43
|
+
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
44
|
+
files: string[];
|
|
45
|
+
directory: string;
|
|
46
|
+
logger: {
|
|
47
|
+
error: (message: string, meta?: unknown) => void;
|
|
48
|
+
warn: (message: string, meta?: unknown) => void;
|
|
49
|
+
info: (message: string, meta?: unknown) => void;
|
|
50
|
+
verbose: (message: string, meta?: unknown) => void;
|
|
51
|
+
debug: (message: string, meta?: unknown) => void;
|
|
52
|
+
};
|
|
53
|
+
targetBranch: string;
|
|
54
|
+
}) => boolean | Promise<boolean>) | undefined;
|
|
55
|
+
multiple?: boolean | undefined;
|
|
56
|
+
branchLabelMapping?: Record<string, string> | undefined;
|
|
57
|
+
branches?: import("./ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
58
|
+
labels?: string[] | undefined;
|
|
59
|
+
historicalBranchLabelMappings: {
|
|
60
|
+
branchLabelMapping: Record<string, string>;
|
|
61
|
+
committedDate: string;
|
|
62
|
+
}[];
|
|
50
63
|
}>;
|
package/dist/options/options.js
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOptions = void 0;
|
|
4
|
-
const
|
|
4
|
+
const getOptionsFromGithub_1 = require("../services/github/v4/getOptionsFromGithub");
|
|
5
5
|
const logger_1 = require("./../services/logger");
|
|
6
6
|
const cliArgs_1 = require("./cliArgs");
|
|
7
7
|
const config_1 = require("./config/config");
|
|
8
|
-
const
|
|
8
|
+
const parseRequiredOptions_1 = require("./parseRequiredOptions");
|
|
9
9
|
async function getOptions(argv, optionsFromModule) {
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const optionsFromConfigFiles = await (0, config_1.getOptionsFromConfigFiles)(optionsFromModule);
|
|
11
|
+
const optionsFromCliArgs = (0, cliArgs_1.getOptionsFromCliArgs)(argv);
|
|
12
12
|
// update logger
|
|
13
|
-
logger_1.updateLogger(
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const { defaultBranch } = await fetchDefaultRepoBranchAndPerformStartupChecks_1.fetchDefaultRepoBranchAndPerformStartupChecks(validatedOptions);
|
|
18
|
-
return {
|
|
19
|
-
...validatedOptions,
|
|
20
|
-
// use the default branch as source branch (normally "master") unless an explicit `sourceBranch` has been given
|
|
21
|
-
sourceBranch: validatedOptions.sourceBranch
|
|
22
|
-
? validatedOptions.sourceBranch
|
|
23
|
-
: defaultBranch,
|
|
24
|
-
};
|
|
13
|
+
(0, logger_1.updateLogger)({ ...optionsFromConfigFiles, ...optionsFromCliArgs });
|
|
14
|
+
const optionsFromGithub = await (0, getOptionsFromGithub_1.getOptionsFromGithub)(optionsFromConfigFiles, optionsFromCliArgs);
|
|
15
|
+
const parsedOptions = (0, parseRequiredOptions_1.parseRequiredOptions)(optionsFromConfigFiles, optionsFromCliArgs, optionsFromGithub);
|
|
16
|
+
return parsedOptions;
|
|
25
17
|
}
|
|
26
18
|
exports.getOptions = getOptions;
|
|
@@ -26,15 +26,20 @@ const nock_1 = __importDefault(require("nock"));
|
|
|
26
26
|
const logger = __importStar(require("../services/logger"));
|
|
27
27
|
const nockHelpers_1 = require("../test/nockHelpers");
|
|
28
28
|
const options_1 = require("./options");
|
|
29
|
-
function
|
|
30
|
-
return nockHelpers_1.mockGqlRequest({
|
|
31
|
-
name: '
|
|
29
|
+
function mockGetGithubConfigOptions({ defaultBranch, refName, }) {
|
|
30
|
+
return (0, nockHelpers_1.mockGqlRequest)({
|
|
31
|
+
name: 'GithubConfigOptions',
|
|
32
32
|
statusCode: 200,
|
|
33
33
|
body: {
|
|
34
34
|
data: {
|
|
35
35
|
repository: {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
isFork: false,
|
|
37
|
+
parent: null,
|
|
38
|
+
ref: refName ? { name: refName } : null,
|
|
39
|
+
defaultBranchRef: {
|
|
40
|
+
name: defaultBranch,
|
|
41
|
+
target: { history: { edges: [] } },
|
|
42
|
+
},
|
|
38
43
|
},
|
|
39
44
|
},
|
|
40
45
|
},
|
|
@@ -57,10 +62,10 @@ describe('getOptions', () => {
|
|
|
57
62
|
nock_1.default.cleanAll();
|
|
58
63
|
});
|
|
59
64
|
it('should use the default repository branch as sourceBranch', async () => {
|
|
60
|
-
const mockCalls =
|
|
65
|
+
const mockCalls = mockGetGithubConfigOptions({
|
|
61
66
|
defaultBranch: 'my-default-branch',
|
|
62
67
|
});
|
|
63
|
-
const options = await options_1.getOptions(defaultArgs);
|
|
68
|
+
const options = await (0, options_1.getOptions)(defaultArgs);
|
|
64
69
|
expect(mockCalls.length).toBe(1);
|
|
65
70
|
expect(options.sourceBranch).toBe('my-default-branch');
|
|
66
71
|
});
|
|
@@ -77,48 +82,48 @@ describe('getOptions', () => {
|
|
|
77
82
|
'--github-api-base-url-v4',
|
|
78
83
|
'http://localhost/graphql',
|
|
79
84
|
];
|
|
80
|
-
|
|
81
|
-
const options = await options_1.getOptions(argv);
|
|
85
|
+
mockGetGithubConfigOptions({ defaultBranch: 'my-default-branch' });
|
|
86
|
+
const options = await (0, options_1.getOptions)(argv);
|
|
82
87
|
expect(options.sourceBranch).toBe('my-source-branch');
|
|
83
88
|
});
|
|
84
89
|
it('should ensure that "backport" branch does not exist', async () => {
|
|
85
|
-
|
|
90
|
+
mockGetGithubConfigOptions({
|
|
86
91
|
defaultBranch: 'my-default-branch',
|
|
87
92
|
refName: 'backport',
|
|
88
93
|
});
|
|
89
|
-
await expect(options_1.getOptions(defaultArgs)).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
90
|
-
});
|
|
91
|
-
it('should omit upstream', async () => {
|
|
92
|
-
mockGetDefaultRepoBranch({ defaultBranch: 'my-default-branch' });
|
|
93
|
-
const options = await options_1.getOptions(defaultArgs);
|
|
94
|
-
//@ts-expect-error
|
|
95
|
-
expect(options.upstream).toBe(undefined);
|
|
94
|
+
await expect((0, options_1.getOptions)(defaultArgs)).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
96
95
|
});
|
|
97
96
|
it('should merge config options and module options', async () => {
|
|
98
|
-
|
|
97
|
+
mockGetGithubConfigOptions({ defaultBranch: 'my-default-branch' });
|
|
99
98
|
const myFn = async () => true;
|
|
100
|
-
const options = await options_1.getOptions(defaultArgs, { autoFixConflicts: myFn });
|
|
99
|
+
const options = await (0, options_1.getOptions)(defaultArgs, { autoFixConflicts: myFn });
|
|
101
100
|
expect(options.autoFixConflicts).toBe(myFn);
|
|
102
101
|
});
|
|
103
102
|
it('should call updateLogger', async () => {
|
|
104
|
-
|
|
105
|
-
await options_1.getOptions(defaultArgs);
|
|
103
|
+
mockGetGithubConfigOptions({ defaultBranch: 'my-default-branch' });
|
|
104
|
+
await (0, options_1.getOptions)(defaultArgs);
|
|
106
105
|
expect(logger.updateLogger).toHaveBeenCalledTimes(1);
|
|
107
106
|
});
|
|
108
107
|
it('should return options', async () => {
|
|
109
|
-
|
|
110
|
-
const options = await options_1.getOptions(defaultArgs);
|
|
108
|
+
mockGetGithubConfigOptions({ defaultBranch: 'default-branch-from-github' });
|
|
109
|
+
const options = await (0, options_1.getOptions)(defaultArgs);
|
|
111
110
|
expect(options).toEqual({
|
|
112
111
|
accessToken: 'myAccessToken',
|
|
113
112
|
all: false,
|
|
114
|
-
author: 'sqren',
|
|
115
113
|
assignees: [],
|
|
114
|
+
author: 'sqren',
|
|
115
|
+
autoAssign: false,
|
|
116
|
+
autoMerge: false,
|
|
117
|
+
autoMergeMethod: 'merge',
|
|
116
118
|
ci: false,
|
|
117
|
-
|
|
119
|
+
cherrypickRef: true,
|
|
120
|
+
details: false,
|
|
118
121
|
fork: true,
|
|
119
122
|
gitHostname: 'github.com',
|
|
120
123
|
githubApiBaseUrlV3: 'https://api.github.com',
|
|
121
124
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
125
|
+
commitPaths: [],
|
|
126
|
+
mainline: 1,
|
|
122
127
|
maxNumber: 10,
|
|
123
128
|
multipleBranches: true,
|
|
124
129
|
multipleCommits: false,
|
|
@@ -127,7 +132,8 @@ describe('getOptions', () => {
|
|
|
127
132
|
repoName: 'kibana',
|
|
128
133
|
repoOwner: 'elastic',
|
|
129
134
|
resetAuthor: false,
|
|
130
|
-
|
|
135
|
+
reviewers: [],
|
|
136
|
+
sourceBranch: 'default-branch-from-github',
|
|
131
137
|
sourcePRLabels: [],
|
|
132
138
|
targetBranchChoices: [
|
|
133
139
|
{ checked: false, name: '6.0' },
|
|
@@ -135,8 +141,42 @@ describe('getOptions', () => {
|
|
|
135
141
|
],
|
|
136
142
|
targetBranches: ['6.0', '6.1'],
|
|
137
143
|
targetPRLabels: [],
|
|
144
|
+
upstream: 'elastic/kibana',
|
|
138
145
|
username: 'sqren',
|
|
139
146
|
verbose: false,
|
|
140
147
|
});
|
|
141
148
|
});
|
|
149
|
+
describe('cherrypickRef', () => {
|
|
150
|
+
beforeEach(() => {
|
|
151
|
+
mockGetGithubConfigOptions({ defaultBranch: 'my-default-branch' });
|
|
152
|
+
});
|
|
153
|
+
const defaultArgs = [
|
|
154
|
+
// use localhost to avoid CORS issues with nock
|
|
155
|
+
'--github-api-base-url-v4',
|
|
156
|
+
'http://localhost/graphql',
|
|
157
|
+
];
|
|
158
|
+
it('should default to true', async () => {
|
|
159
|
+
const { cherrypickRef } = await (0, options_1.getOptions)(defaultArgs);
|
|
160
|
+
expect(cherrypickRef).toBe(true);
|
|
161
|
+
});
|
|
162
|
+
it('should negate with `noCherrypickRef` cli arg', async () => {
|
|
163
|
+
const { cherrypickRef } = await (0, options_1.getOptions)([
|
|
164
|
+
...defaultArgs,
|
|
165
|
+
'--no-cherrypick-ref',
|
|
166
|
+
]);
|
|
167
|
+
expect(cherrypickRef).toBe(false);
|
|
168
|
+
});
|
|
169
|
+
it('should be settable via config file', async () => {
|
|
170
|
+
const { cherrypickRef } = await (0, options_1.getOptions)([...defaultArgs], {
|
|
171
|
+
cherrypickRef: false,
|
|
172
|
+
});
|
|
173
|
+
expect(cherrypickRef).toBe(false);
|
|
174
|
+
});
|
|
175
|
+
it('cli args overwrites config', async () => {
|
|
176
|
+
const { cherrypickRef } = await (0, options_1.getOptions)([...defaultArgs, '--cherrypick-ref'], {
|
|
177
|
+
cherrypickRef: false,
|
|
178
|
+
});
|
|
179
|
+
expect(cherrypickRef).toBe(true);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
142
182
|
});
|