backport 6.1.5 → 6.3.0-beta-2
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 +15 -6
- package/dist/{main.d.ts → backportRun.d.ts} +3 -3
- package/dist/{main.js → backportRun.js} +21 -10
- package/dist/{entrypoint.module.private.test.d.ts → entrypoint.cli.e2e.private.test.d.ts} +0 -0
- package/dist/entrypoint.cli.e2e.private.test.js +277 -0
- package/dist/entrypoint.cli.js +3 -5
- package/dist/{options/getValidatedOptions.test.d.ts → entrypoint.cli.private.test.d.ts} +0 -0
- package/dist/{entrypoint.module.private.test.js → entrypoint.cli.private.test.js} +17 -8
- package/dist/entrypoint.module.d.ts +2 -2
- package/dist/entrypoint.module.js +4 -4
- package/dist/options/ConfigOptions.d.ts +5 -1
- package/dist/options/cliArgs.d.ts +16 -14
- package/dist/options/cliArgs.js +15 -5
- package/dist/options/cliArgs.test.js +28 -10
- package/dist/options/config/config.d.ts +10 -4
- package/dist/options/config/config.js +7 -6
- package/dist/options/config/config.test.js +11 -1
- package/dist/options/config/globalConfig.d.ts +1 -1
- package/dist/options/config/globalConfig.js +15 -9
- package/dist/options/config/globalConfig.test.js +19 -32
- package/dist/options/config/projectConfig.d.ts +3 -1
- package/dist/options/config/projectConfig.js +5 -2
- package/dist/options/config/projectConfig.test.js +41 -31
- package/dist/options/config/readConfigFile.d.ts +27 -23
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +18 -39
- package/dist/options/options.js +40 -32
- package/dist/options/options.test.js +83 -47
- package/dist/runSequentially.d.ts +0 -1
- package/dist/runSequentially.js +0 -1
- package/dist/runSequentially.test.js +39 -20
- package/dist/scripts/postinstall.js +3 -3
- package/dist/services/HandledError.d.ts +6 -4
- package/dist/services/HandledError.js +18 -3
- package/dist/services/child-process-promisified.d.ts +3 -1
- package/dist/services/env.d.ts +3 -1
- package/dist/services/env.js +4 -1
- package/dist/services/env.test.js +2 -2
- package/dist/services/git.d.ts +22 -9
- package/dist/services/git.integration.test.js +123 -24
- package/dist/services/git.js +66 -54
- package/dist/services/git.test.js +35 -20
- package/dist/services/github/commitFormatters.d.ts +0 -1
- package/dist/services/github/commitFormatters.js +1 -8
- package/dist/services/github/v3/createPullRequest.js +16 -10
- package/dist/services/github/v3/createPullRequest.test.js +248 -33
- package/dist/services/github/v3/createStatusComment.d.ts +1 -1
- package/dist/services/github/v3/createStatusComment.js +26 -15
- package/dist/services/github/v3/createStatusComment.test.js +165 -70
- package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +2 -1
- package/dist/services/github/v4/FetchPullRequestId.d.ts +0 -7
- package/dist/services/github/v4/apiRequestV4.d.ts +21 -17
- package/dist/services/github/v4/apiRequestV4.js +38 -28
- package/dist/services/github/v4/apiRequestV4.test.js +4 -4
- package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -7
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -7
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +37 -19
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +17 -8
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +23 -14
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +4 -4
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +41 -19
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +1 -8
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +31 -14
- package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -4
- package/dist/services/github/v4/fetchExistingPullRequest.js +1 -2
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -9
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +6 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +41 -34
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +6 -0
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +2 -1
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +56 -0
- package/dist/{options/parseRequiredOptions.test.d.ts → services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts} +0 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +71 -0
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +11 -11
- package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +4 -5
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -7
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +5 -5
- package/dist/services/logger.d.ts +9 -3
- package/dist/services/logger.js +38 -35
- package/dist/services/prompt.test.js +66 -19
- package/dist/services/prompts.js +12 -10
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +1 -1
- package/dist/services/sourceCommit/getMockSourceCommit.js +6 -6
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +18 -10
- package/dist/services/sourceCommit/parseSourceCommit.js +20 -14
- package/dist/services/sourceCommit/parseSourceCommit.test.js +18 -20
- package/dist/{runWithOptions.test.d.ts → test/backport-e2e.mutation.test.d.ts} +0 -0
- package/dist/test/{integration/integration.private.test.js → backport-e2e.mutation.test.js} +143 -123
- package/dist/{scripts/generate-gql.d.ts → test/handleUnbackportedPullRequests.private.test.d.ts} +0 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.js +57 -0
- package/dist/test/mockConfigFiles.js +4 -20
- package/dist/test/mocks.d.ts +10 -0
- package/dist/test/mocks.js +23 -0
- package/dist/test/private/getDevAccessToken.js +5 -4
- package/dist/test/sandbox.d.ts +5 -0
- package/dist/test/sandbox.js +43 -0
- package/dist/test/setupFiles/automatic-mocks.d.ts +1 -0
- package/dist/test/setupFiles/automatic-mocks.js +27 -11
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +12 -13
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +50 -27
- package/dist/ui/getCommits.js +8 -14
- package/dist/ui/getCommitsWithoutBackports.js +6 -6
- package/dist/ui/getCommitsWithoutBackports.test.js +91 -39
- package/dist/ui/getTargetBranches.js +1 -1
- package/dist/ui/getTargetBranches.test.js +26 -8
- package/dist/ui/maybeSetupRepo.js +25 -5
- package/dist/ui/maybeSetupRepo.test.js +144 -14
- package/dist/utils/maybe.d.ts +1 -0
- package/dist/utils/maybe.js +7 -0
- package/dist/utils/packageVersion.d.ts +1 -0
- package/dist/{types/PromiseReturnType.js → utils/packageVersion.js} +2 -0
- package/package.json +24 -20
- package/yarn.lock +160 -237
- package/dist/index.d.ts +0 -783
- package/dist/index.js +0 -8001
- package/dist/ink.d.ts +0 -1
- package/dist/ink.js +0 -49
- package/dist/options/config/getOptionsFromGit.d.ts +0 -4
- package/dist/options/config/getOptionsFromGit.js +0 -8
- package/dist/options/getValidatedOptions.d.ts +0 -49
- package/dist/options/getValidatedOptions.js +0 -45
- package/dist/options/getValidatedOptions.test.js +0 -97
- package/dist/options/parseRequiredOptions.d.ts +0 -71
- package/dist/options/parseRequiredOptions.js +0 -68
- package/dist/options/parseRequiredOptions.test.js +0 -122
- package/dist/runWithOptions.d.ts +0 -9
- package/dist/runWithOptions.js +0 -43
- package/dist/runWithOptions.test.js +0 -304
- package/dist/scripts/generate-gql.js +0 -15
- package/dist/services/fs-promisified.d.ts +0 -6
- package/dist/services/fs-promisified.js +0 -12
- package/dist/services/getExpectedTarget.d.ts +0 -9
- package/dist/services/getExpectedTarget.js +0 -77
- package/dist/services/getExpectedTargetPullRequests.d.ts +0 -9
- package/dist/services/getExpectedTargetPullRequests.js +0 -77
- package/dist/services/github/v4/fetchCommitByPullNumber.d.ts +0 -5
- package/dist/services/github/v4/fetchCommitByPullNumber.js +0 -86
- package/dist/services/github/v4/fetchCommitByPullNumber.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitByPullNumber.private.test.js +0 -57
- package/dist/services/github/v4/fetchCommitBySha.d.ts +0 -5
- package/dist/services/github/v4/fetchCommitBySha.js +0 -95
- package/dist/services/github/v4/fetchCommitBySha.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitBySha.private.test.js +0 -50
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.d.ts +0 -28
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.js +0 -52
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.d.ts +0 -3
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.js +0 -55
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.js +0 -252
- package/dist/services/github/v4/fetchCommitsByAuthor.d.ts +0 -28
- package/dist/services/github/v4/fetchCommitsByAuthor.js +0 -161
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.js +0 -115
- package/dist/services/github/v4/fetchCommitsByAuthor.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitsByAuthor.test.js +0 -272
- package/dist/services/github/v4/fetchDefaultBranch.d.ts +0 -9
- package/dist/services/github/v4/fetchDefaultBranch.js +0 -24
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +0 -4
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.js +0 -52
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +0 -32
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.d.ts +0 -4
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.js +0 -72
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.js +0 -34
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.d.ts +0 -40
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.js +0 -72
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +0 -17
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.js +0 -69
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +0 -32
- package/dist/services/github/v4/fetchMergedPullRequests.d.ts +0 -37
- package/dist/services/github/v4/fetchMergedPullRequests.js +0 -37
- package/dist/services/github/v4/fetchMergedPullRequests.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchMergedPullRequests.private.test.js +0 -59
- package/dist/services/github/v4/fetchMergedPullRequests.test.d.ts +0 -1
- package/dist/services/github/v4/fetchMergedPullRequests.test.js +0 -22
- package/dist/services/github/v4/fetchProjectConfig.d.ts +0 -8
- package/dist/services/github/v4/fetchProjectConfig.js +0 -56
- package/dist/services/github/v4/fetchProjectConfig.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchProjectConfig.private.test.js +0 -52
- package/dist/services/github/v4/fetchProjectConfig.test.d.ts +0 -1
- package/dist/services/github/v4/fetchProjectConfig.test.js +0 -37
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.d.ts +0 -9
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.js +0 -92
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.js +0 -66
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.d.ts +0 -1
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.js +0 -242
- package/dist/services/github/v4/getExistingTargetPullRequests.d.ts +0 -7
- package/dist/services/github/v4/getExistingTargetPullRequests.js +0 -45
- package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +0 -63
- package/dist/services/github/v4/getOptionsFromGithub/index.js +0 -139
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.d.ts +0 -1
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +0 -147
- package/dist/services/github/v4/getTargetBranchesFromLabels.d.ts +0 -5
- package/dist/services/github/v4/getTargetBranchesFromLabels.js +0 -20
- package/dist/services/github/v4/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/services/github/v4/getTargetBranchesFromLabels.test.js +0 -201
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.js +0 -843
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.js +0 -73
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.d.ts +0 -12
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.js +0 -44
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.d.ts +0 -5
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.js +0 -20
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.js +0 -201
- package/dist/services/sourceCommit/sourceCommit.d.ts +0 -78
- package/dist/services/sourceCommit/sourceCommit.js +0 -86
- package/dist/services/sourceCommit/sourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit/sourceCommit.test.js +0 -287
- package/dist/services/sourceCommit.d.ts +0 -78
- package/dist/services/sourceCommit.js +0 -86
- package/dist/services/sourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit.test.js +0 -280
- package/dist/test/inquirer.private.test.d.ts +0 -1
- package/dist/test/inquirer.private.test.js +0 -168
- package/dist/test/integration/createSpies.d.ts +0 -17
- package/dist/test/integration/createSpies.js +0 -85
- package/dist/test/integration/envConstants.d.ts +0 -5
- package/dist/test/integration/envConstants.js +0 -9
- package/dist/test/integration/helpers.d.ts +0 -7
- package/dist/test/integration/helpers.js +0 -31
- package/dist/test/integration/integration.private.test.d.ts +0 -1
- package/dist/test/integration/integration.test.d.ts +0 -1
- package/dist/test/integration/integration.test.js +0 -214
- package/dist/todo-delete.d.ts +0 -1
- package/dist/todo-delete.js +0 -17
- package/dist/types/Commit.d.ts +0 -85
- package/dist/types/Commit.js +0 -139
- package/dist/types/PromiseReturnType.d.ts +0 -1
- package/dist/types/commitNode.d.ts +0 -89
- package/dist/types/commitNode.js +0 -139
- package/dist/types/commitNode.test.d.ts +0 -1
- package/dist/types/commitNode.test.js +0 -255
- package/dist/types/commitWithAssociatedPullRequests.d.ts +0 -86
- package/dist/types/commitWithAssociatedPullRequests.js +0 -145
- package/dist/ui/cherrypickAndCreatePullRequest.test.d.ts +0 -1
- package/dist/ui/cherrypickAndCreatePullRequest.test.js +0 -617
- package/dist/ui/getTargetBranchesFromLabels.d.ts +0 -6
- package/dist/ui/getTargetBranchesFromLabels.js +0 -40
- package/dist/ui/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/ui/getTargetBranchesFromLabels.test.js +0 -288
|
@@ -1,72 +1,48 @@
|
|
|
1
1
|
import { ConfigFileOptions, TargetBranchChoiceOrString } from './ConfigOptions';
|
|
2
2
|
export declare type ValidConfigOptions = Readonly<Awaited<ReturnType<typeof getOptions>>>;
|
|
3
|
-
export declare
|
|
4
|
-
assignees: string[];
|
|
5
|
-
autoAssign: boolean;
|
|
6
|
-
autoMerge: boolean;
|
|
7
|
-
autoMergeMethod: string;
|
|
8
|
-
backportBinary: string;
|
|
9
|
-
cherrypickRef: boolean;
|
|
10
|
-
ci: boolean;
|
|
11
|
-
commitPaths: string[];
|
|
12
|
-
dateSince: null;
|
|
13
|
-
dateUntil: null;
|
|
14
|
-
details: boolean;
|
|
15
|
-
fork: boolean;
|
|
16
|
-
maxNumber: number;
|
|
17
|
-
multipleBranches: boolean;
|
|
18
|
-
multipleCommits: boolean;
|
|
19
|
-
noVerify: boolean;
|
|
20
|
-
publishStatusComment: boolean;
|
|
21
|
-
resetAuthor: boolean;
|
|
22
|
-
reviewers: string[];
|
|
23
|
-
sourcePRLabels: string[];
|
|
24
|
-
targetBranchChoices: TargetBranchChoiceOrString[];
|
|
25
|
-
targetBranches: string[];
|
|
26
|
-
targetPRLabels: string[];
|
|
27
|
-
verbose: boolean;
|
|
28
|
-
};
|
|
29
|
-
export declare function getOptions(argv: string[], optionsFromModule?: ConfigFileOptions): Promise<{
|
|
3
|
+
export declare function getOptions(processArgs: string[], optionsFromModule: ConfigFileOptions): Promise<{
|
|
30
4
|
accessToken: string;
|
|
31
5
|
repoName: string;
|
|
32
6
|
repoOwner: string;
|
|
33
7
|
fork: boolean;
|
|
34
8
|
dir?: string | undefined;
|
|
35
9
|
verbose: boolean;
|
|
36
|
-
ci: boolean;
|
|
37
|
-
assignees: string[];
|
|
38
10
|
author: string | null;
|
|
39
11
|
autoAssign: boolean;
|
|
12
|
+
assignees: string[];
|
|
40
13
|
autoMerge: boolean;
|
|
41
14
|
autoMergeMethod: string;
|
|
15
|
+
ci: boolean;
|
|
42
16
|
cherrypickRef: boolean;
|
|
43
|
-
|
|
17
|
+
configFile?: string | undefined;
|
|
44
18
|
details: boolean;
|
|
45
19
|
editor?: string | undefined;
|
|
46
|
-
|
|
20
|
+
skipRemoteConfig?: boolean | undefined;
|
|
21
|
+
gitHostname: string;
|
|
47
22
|
githubApiBaseUrlV3?: string | undefined;
|
|
48
23
|
githubApiBaseUrlV4?: string | undefined;
|
|
24
|
+
logFilePath?: string | undefined;
|
|
25
|
+
mainline?: number | undefined;
|
|
49
26
|
maxNumber: number;
|
|
50
27
|
multipleBranches: boolean;
|
|
51
28
|
multipleCommits: boolean;
|
|
52
29
|
noVerify: boolean;
|
|
53
30
|
prDescription?: string | undefined;
|
|
54
|
-
prFilter?: string | undefined;
|
|
55
31
|
prTitle?: string | undefined;
|
|
56
|
-
|
|
32
|
+
prFilter?: string | undefined;
|
|
57
33
|
pullNumber?: number | undefined;
|
|
58
|
-
resetAuthor: boolean;
|
|
59
|
-
reviewers: string[];
|
|
60
34
|
sha?: string | undefined;
|
|
61
|
-
|
|
35
|
+
resetAuthor: boolean;
|
|
62
36
|
sourceBranch: string;
|
|
37
|
+
dateSince: string | null;
|
|
38
|
+
dateUntil: string | null;
|
|
39
|
+
commitPaths: string[];
|
|
40
|
+
reviewers: string[];
|
|
63
41
|
sourcePRLabels: string[];
|
|
64
42
|
targetBranchChoices: string[] | TargetBranchChoiceOrString[];
|
|
65
43
|
targetBranches: string[];
|
|
66
44
|
targetPRLabels: string[];
|
|
67
|
-
|
|
68
|
-
dateSince: string | null;
|
|
69
|
-
dateUntil: string | null;
|
|
45
|
+
publishStatusComment: boolean;
|
|
70
46
|
historicalBranchLabelMappings: {
|
|
71
47
|
branchLabelMapping: Record<string, string>;
|
|
72
48
|
committedDate: string;
|
|
@@ -85,9 +61,12 @@ export declare function getOptions(argv: string[], optionsFromModule?: ConfigFil
|
|
|
85
61
|
}) => boolean | Promise<boolean>) | undefined;
|
|
86
62
|
backportBinary: string;
|
|
87
63
|
multiple?: boolean | undefined;
|
|
64
|
+
help?: boolean | undefined;
|
|
65
|
+
version?: boolean | undefined;
|
|
88
66
|
branchLabelMapping?: Record<string, string> | undefined;
|
|
89
67
|
upstream?: string | undefined;
|
|
90
68
|
branches?: TargetBranchChoiceOrString[] | undefined;
|
|
91
69
|
labels?: string[] | undefined;
|
|
92
70
|
authenticatedUsername: string;
|
|
71
|
+
cwd: string;
|
|
93
72
|
}>;
|
package/dist/options/options.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOptions =
|
|
3
|
+
exports.getOptions = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const HandledError_1 = require("../services/HandledError");
|
|
6
6
|
const env_1 = require("../services/env");
|
|
7
7
|
const getOptionsFromGithub_1 = require("../services/github/v4/getOptionsFromGithub/getOptionsFromGithub");
|
|
8
|
+
const getRepoOwnerAndNameFromGitRemotes_1 = require("../services/github/v4/getRepoOwnerAndNameFromGitRemotes");
|
|
8
9
|
const logger_1 = require("./../services/logger");
|
|
9
10
|
const cliArgs_1 = require("./cliArgs");
|
|
10
11
|
const config_1 = require("./config/config");
|
|
11
12
|
const PROJECT_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson';
|
|
12
13
|
const GLOBAL_CONFIG_DOCS_LINK = 'https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson';
|
|
13
|
-
|
|
14
|
+
const defaultConfigOptions = {
|
|
14
15
|
assignees: [],
|
|
15
16
|
autoAssign: false,
|
|
16
17
|
autoMerge: false,
|
|
@@ -19,10 +20,12 @@ exports.defaultConfigOptions = {
|
|
|
19
20
|
cherrypickRef: true,
|
|
20
21
|
ci: false,
|
|
21
22
|
commitPaths: [],
|
|
23
|
+
cwd: process.cwd(),
|
|
22
24
|
dateSince: null,
|
|
23
25
|
dateUntil: null,
|
|
24
26
|
details: false,
|
|
25
27
|
fork: true,
|
|
28
|
+
gitHostname: 'github.com',
|
|
26
29
|
maxNumber: 10,
|
|
27
30
|
multipleBranches: true,
|
|
28
31
|
multipleCommits: false,
|
|
@@ -36,27 +39,24 @@ exports.defaultConfigOptions = {
|
|
|
36
39
|
targetPRLabels: [],
|
|
37
40
|
verbose: false,
|
|
38
41
|
};
|
|
39
|
-
async function getOptions(
|
|
40
|
-
const optionsFromCliArgs = (0, cliArgs_1.getOptionsFromCliArgs)(
|
|
41
|
-
const ci = optionsFromCliArgs.ci ?? optionsFromModule?.ci ?? exports.defaultConfigOptions.ci;
|
|
42
|
+
async function getOptions(processArgs, optionsFromModule) {
|
|
43
|
+
const optionsFromCliArgs = (0, cliArgs_1.getOptionsFromCliArgs)(processArgs);
|
|
42
44
|
const optionsFromConfigFiles = await (0, config_1.getOptionsFromConfigFiles)({
|
|
45
|
+
optionsFromCliArgs,
|
|
43
46
|
optionsFromModule,
|
|
44
|
-
|
|
47
|
+
defaultConfigOptions,
|
|
45
48
|
});
|
|
46
49
|
// combined options from cli and config files
|
|
47
50
|
const combined = getCombinedOptions({
|
|
48
51
|
optionsFromConfigFiles,
|
|
49
52
|
optionsFromCliArgs,
|
|
50
53
|
});
|
|
54
|
+
const { accessToken, repoName, repoOwner } = await getRequiredOptions(combined);
|
|
51
55
|
// update logger
|
|
52
|
-
(0, logger_1.updateLogger)(combined);
|
|
53
|
-
// required
|
|
54
|
-
const accessToken = requireAccessToken(combined);
|
|
55
|
-
const repoName = requireRepoName(combined);
|
|
56
|
-
const repoOwner = requireRepoOwner(combined);
|
|
56
|
+
(0, logger_1.updateLogger)({ accessToken, verbose: combined.verbose });
|
|
57
57
|
const optionsFromGithub = await (0, getOptionsFromGithub_1.getOptionsFromGithub)({
|
|
58
58
|
...combined,
|
|
59
|
-
// required
|
|
59
|
+
// required options
|
|
60
60
|
accessToken,
|
|
61
61
|
repoName,
|
|
62
62
|
repoOwner,
|
|
@@ -65,7 +65,7 @@ async function getOptions(argv, optionsFromModule) {
|
|
|
65
65
|
// default author
|
|
66
66
|
author: optionsFromGithub.authenticatedUsername,
|
|
67
67
|
// default values have lowest precedence
|
|
68
|
-
...
|
|
68
|
+
...defaultConfigOptions,
|
|
69
69
|
// local config options override default options
|
|
70
70
|
...optionsFromConfigFiles,
|
|
71
71
|
// remote config options override local config options
|
|
@@ -81,32 +81,40 @@ async function getOptions(argv, optionsFromModule) {
|
|
|
81
81
|
return res;
|
|
82
82
|
}
|
|
83
83
|
exports.getOptions = getOptions;
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
function requireAccessToken(combinedOptions) {
|
|
92
|
-
// accessToken must be supplied in config or via cli args
|
|
93
|
-
if (!combinedOptions.accessToken) {
|
|
84
|
+
async function getRequiredOptions(combined) {
|
|
85
|
+
const { accessToken, repoName, repoOwner } = combined;
|
|
86
|
+
if (accessToken && repoName && repoOwner) {
|
|
87
|
+
return { accessToken, repoName, repoOwner };
|
|
88
|
+
}
|
|
89
|
+
// require access token
|
|
90
|
+
if (!accessToken) {
|
|
94
91
|
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
95
92
|
throw new HandledError_1.HandledError(`Please update your config file: "${globalConfigPath}".\nIt must contain a valid "accessToken".\n\nRead more: ${GLOBAL_CONFIG_DOCS_LINK}`);
|
|
96
93
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
// attempt to retrieve repo-owner and repo-name from git remote
|
|
95
|
+
const gitRemote = await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
|
|
96
|
+
cwd: combined.cwd,
|
|
97
|
+
githubApiBaseUrlV4: combined.githubApiBaseUrlV4,
|
|
98
|
+
accessToken,
|
|
99
|
+
});
|
|
100
|
+
if (!gitRemote.repoName) {
|
|
101
101
|
throw new HandledError_1.HandledError(`Please specify a repo name: "--repo-name kibana".\n\nRead more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
102
102
|
}
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
function requireRepoOwner(combinedOptions) {
|
|
106
|
-
if (!combinedOptions.repoOwner) {
|
|
103
|
+
if (!gitRemote.repoOwner) {
|
|
107
104
|
throw new HandledError_1.HandledError(`Please specify a repo owner: "--repo-owner elastic".\n\nRead more: ${PROJECT_CONFIG_DOCS_LINK}`);
|
|
108
105
|
}
|
|
109
|
-
return
|
|
106
|
+
return {
|
|
107
|
+
accessToken,
|
|
108
|
+
repoName: gitRemote.repoName,
|
|
109
|
+
repoOwner: gitRemote.repoOwner,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function getCombinedOptions({ optionsFromConfigFiles, optionsFromCliArgs, }) {
|
|
113
|
+
return {
|
|
114
|
+
...defaultConfigOptions,
|
|
115
|
+
...optionsFromConfigFiles,
|
|
116
|
+
...optionsFromCliArgs,
|
|
117
|
+
};
|
|
110
118
|
}
|
|
111
119
|
function requireTargetBranch(config) {
|
|
112
120
|
// ensure `targetBranches` or `targetBranchChoices` are given
|
|
@@ -22,12 +22,14 @@ 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 promises_1 = __importDefault(require("fs/promises"));
|
|
26
|
+
const os_1 = __importDefault(require("os"));
|
|
25
27
|
const nock_1 = __importDefault(require("nock"));
|
|
28
|
+
const git = __importStar(require("../services/git"));
|
|
26
29
|
const logger = __importStar(require("../services/logger"));
|
|
27
30
|
const mockConfigFiles_1 = require("../test/mockConfigFiles");
|
|
28
31
|
const nockHelpers_1 = require("../test/nockHelpers");
|
|
29
32
|
const options_1 = require("./options");
|
|
30
|
-
jest.unmock('../services/fs-promisified');
|
|
31
33
|
const defaultConfigs = {
|
|
32
34
|
projectConfig: {
|
|
33
35
|
// use localhost to avoid CORS issues with nock
|
|
@@ -45,6 +47,9 @@ describe('getOptions', () => {
|
|
|
45
47
|
});
|
|
46
48
|
beforeEach(() => {
|
|
47
49
|
(0, mockConfigFiles_1.mockConfigFiles)(defaultConfigs);
|
|
50
|
+
jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
|
|
51
|
+
jest.spyOn(promises_1.default, 'writeFile').mockResolvedValue();
|
|
52
|
+
jest.spyOn(promises_1.default, 'chmod').mockResolvedValue();
|
|
48
53
|
});
|
|
49
54
|
describe('should throw', () => {
|
|
50
55
|
beforeEach(() => {
|
|
@@ -55,13 +60,13 @@ describe('getOptions', () => {
|
|
|
55
60
|
projectConfig: defaultConfigs.projectConfig,
|
|
56
61
|
globalConfig: { accessToken: undefined },
|
|
57
62
|
});
|
|
58
|
-
await expect(() => (0, options_1.getOptions)([])).rejects
|
|
63
|
+
await expect(() => (0, options_1.getOptions)([], { ci: true })).rejects
|
|
59
64
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
"Please update your config file: \\"/myHomeDir/.backport/config.json\\".
|
|
66
|
+
It must contain a valid \\"accessToken\\".
|
|
62
67
|
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#global-config-backportconfigjson"
|
|
69
|
+
`);
|
|
65
70
|
});
|
|
66
71
|
it('when `targetBranches`, `targetBranchChoices` and `branchLabelMapping` are all empty', async () => {
|
|
67
72
|
mockProjectConfig({
|
|
@@ -69,35 +74,44 @@ describe('getOptions', () => {
|
|
|
69
74
|
targetBranchChoices: undefined,
|
|
70
75
|
branchLabelMapping: undefined,
|
|
71
76
|
});
|
|
72
|
-
await expect(() => (0, options_1.getOptions)([])).rejects
|
|
77
|
+
await expect(() => (0, options_1.getOptions)([], {})).rejects
|
|
73
78
|
.toThrowErrorMatchingInlineSnapshot(`
|
|
74
79
|
"Please specify a target branch: \\"--branch 6.1\\".
|
|
75
80
|
|
|
76
81
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
77
82
|
`);
|
|
78
83
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
describe('when repoName and repoOwner are missing', () => {
|
|
85
|
+
beforeEach(() => {
|
|
86
|
+
mockProjectConfig({ repoName: undefined, repoOwner: undefined });
|
|
87
|
+
});
|
|
88
|
+
it('should throw if there are no remotes', async () => {
|
|
89
|
+
jest.spyOn(git, 'getRepoInfoFromGitRemotes').mockResolvedValue([]);
|
|
90
|
+
await expect(() => (0, options_1.getOptions)([], {})).rejects
|
|
91
|
+
.toThrowErrorMatchingInlineSnapshot(`
|
|
83
92
|
"Please specify a repo name: \\"--repo-name kibana\\".
|
|
84
93
|
|
|
85
94
|
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
86
95
|
`);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
});
|
|
97
|
+
it('should get repoName from the remote', async () => {
|
|
98
|
+
mockRepoOwnerAndName({
|
|
99
|
+
childRepoOwner: 'sqren',
|
|
100
|
+
parentRepoOwner: 'elastic',
|
|
101
|
+
repoName: 'kibana',
|
|
102
|
+
});
|
|
103
|
+
jest
|
|
104
|
+
.spyOn(git, 'getRepoInfoFromGitRemotes')
|
|
105
|
+
.mockResolvedValue([{ repoName: 'kibana', repoOwner: 'sqren' }]);
|
|
106
|
+
const options = await (0, options_1.getOptions)([], {});
|
|
107
|
+
expect(options.repoName).toBe('kibana');
|
|
108
|
+
expect(options.repoOwner).toBe('elastic');
|
|
109
|
+
});
|
|
96
110
|
});
|
|
97
111
|
});
|
|
98
112
|
it('should ensure that "backport" branch does not exist', async () => {
|
|
99
113
|
mockGithubConfigOptions({ refName: 'backport' });
|
|
100
|
-
await expect((0, options_1.getOptions)([])).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
114
|
+
await expect((0, options_1.getOptions)([], {})).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
101
115
|
});
|
|
102
116
|
it('should merge config options and module options', async () => {
|
|
103
117
|
mockGithubConfigOptions({});
|
|
@@ -107,7 +121,7 @@ describe('getOptions', () => {
|
|
|
107
121
|
});
|
|
108
122
|
it('should call updateLogger', async () => {
|
|
109
123
|
mockGithubConfigOptions({});
|
|
110
|
-
await (0, options_1.getOptions)([]);
|
|
124
|
+
await (0, options_1.getOptions)([], {});
|
|
111
125
|
expect(logger.updateLogger).toHaveBeenCalledTimes(1);
|
|
112
126
|
});
|
|
113
127
|
it('should return options', async () => {
|
|
@@ -121,12 +135,13 @@ describe('getOptions', () => {
|
|
|
121
135
|
},
|
|
122
136
|
],
|
|
123
137
|
});
|
|
124
|
-
const options = await (0, options_1.getOptions)([]);
|
|
138
|
+
const options = await (0, options_1.getOptions)([], {});
|
|
125
139
|
expect(options).toEqual({
|
|
126
140
|
accessToken: 'abc',
|
|
127
141
|
assignees: [],
|
|
128
|
-
autoAssign: false,
|
|
129
142
|
authenticatedUsername: 'john.diller',
|
|
143
|
+
author: 'john.diller',
|
|
144
|
+
autoAssign: false,
|
|
130
145
|
autoMerge: false,
|
|
131
146
|
autoMergeMethod: 'merge',
|
|
132
147
|
backportBinary: 'backport',
|
|
@@ -136,11 +151,13 @@ describe('getOptions', () => {
|
|
|
136
151
|
cherrypickRef: true,
|
|
137
152
|
ci: false,
|
|
138
153
|
commitPaths: [],
|
|
154
|
+
cwd: expect.any(String),
|
|
139
155
|
dateSince: null,
|
|
140
156
|
dateUntil: null,
|
|
141
157
|
details: false,
|
|
142
158
|
editor: 'code',
|
|
143
159
|
fork: true,
|
|
160
|
+
gitHostname: 'github.com',
|
|
144
161
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
145
162
|
historicalBranchLabelMappings: [
|
|
146
163
|
{
|
|
@@ -152,6 +169,7 @@ describe('getOptions', () => {
|
|
|
152
169
|
multipleBranches: true,
|
|
153
170
|
multipleCommits: false,
|
|
154
171
|
noVerify: true,
|
|
172
|
+
publishStatusComment: true,
|
|
155
173
|
repoName: 'kibana',
|
|
156
174
|
repoOwner: 'elastic',
|
|
157
175
|
resetAuthor: false,
|
|
@@ -161,7 +179,6 @@ describe('getOptions', () => {
|
|
|
161
179
|
targetBranchChoices: ['7.9', '8.0'],
|
|
162
180
|
targetBranches: [],
|
|
163
181
|
targetPRLabels: [],
|
|
164
|
-
author: 'john.diller',
|
|
165
182
|
verbose: false,
|
|
166
183
|
});
|
|
167
184
|
});
|
|
@@ -170,14 +187,11 @@ describe('getOptions', () => {
|
|
|
170
187
|
mockGithubConfigOptions({ defaultBranchRef: 'some-default-branch' });
|
|
171
188
|
});
|
|
172
189
|
it('uses the `defaultBranchRef` as default', async () => {
|
|
173
|
-
const options = await (0, options_1.getOptions)([]);
|
|
190
|
+
const options = await (0, options_1.getOptions)([], {});
|
|
174
191
|
expect(options.sourceBranch).toBe('some-default-branch');
|
|
175
192
|
});
|
|
176
193
|
it('uses the sourceBranch given via cli instead of `defaultBranchRef`', async () => {
|
|
177
|
-
const options = await (0, options_1.getOptions)([
|
|
178
|
-
'--source-branch',
|
|
179
|
-
'cli-source-branch',
|
|
180
|
-
]);
|
|
194
|
+
const options = await (0, options_1.getOptions)(['--source-branch', 'cli-source-branch'], {});
|
|
181
195
|
expect(options.sourceBranch).toBe('cli-source-branch');
|
|
182
196
|
});
|
|
183
197
|
});
|
|
@@ -186,16 +200,16 @@ describe('getOptions', () => {
|
|
|
186
200
|
mockGithubConfigOptions({});
|
|
187
201
|
});
|
|
188
202
|
it('is enabled by default', async () => {
|
|
189
|
-
const { fork } = await (0, options_1.getOptions)([]);
|
|
203
|
+
const { fork } = await (0, options_1.getOptions)([], {});
|
|
190
204
|
expect(fork).toBe(true);
|
|
191
205
|
});
|
|
192
206
|
it('can be disabled via `--no-fork` flag', async () => {
|
|
193
|
-
const { fork } = await (0, options_1.getOptions)(['--no-fork']);
|
|
207
|
+
const { fork } = await (0, options_1.getOptions)(['--no-fork'], {});
|
|
194
208
|
expect(fork).toBe(false);
|
|
195
209
|
});
|
|
196
210
|
it('can be disabled via config file', async () => {
|
|
197
211
|
mockProjectConfig({ fork: false });
|
|
198
|
-
const { fork } = await (0, options_1.getOptions)([]);
|
|
212
|
+
const { fork } = await (0, options_1.getOptions)([], {});
|
|
199
213
|
expect(fork).toBe(false);
|
|
200
214
|
});
|
|
201
215
|
});
|
|
@@ -204,12 +218,12 @@ describe('getOptions', () => {
|
|
|
204
218
|
mockGithubConfigOptions({});
|
|
205
219
|
});
|
|
206
220
|
it('can be set via `--reviewer` flag', async () => {
|
|
207
|
-
const { reviewers } = await (0, options_1.getOptions)(['--reviewer', 'peter']);
|
|
221
|
+
const { reviewers } = await (0, options_1.getOptions)(['--reviewer', 'peter'], {});
|
|
208
222
|
expect(reviewers).toEqual(['peter']);
|
|
209
223
|
});
|
|
210
224
|
it('can be set via config file', async () => {
|
|
211
225
|
mockProjectConfig({ reviewers: ['john'] });
|
|
212
|
-
const { reviewers } = await (0, options_1.getOptions)([]);
|
|
226
|
+
const { reviewers } = await (0, options_1.getOptions)([], {});
|
|
213
227
|
expect(reviewers).toEqual(['john']);
|
|
214
228
|
});
|
|
215
229
|
});
|
|
@@ -218,15 +232,15 @@ describe('getOptions', () => {
|
|
|
218
232
|
mockGithubConfigOptions({});
|
|
219
233
|
});
|
|
220
234
|
it('is not enabled by default', async () => {
|
|
221
|
-
const { mainline } = await (0, options_1.getOptions)([]);
|
|
235
|
+
const { mainline } = await (0, options_1.getOptions)([], {});
|
|
222
236
|
expect(mainline).toBe(undefined);
|
|
223
237
|
});
|
|
224
238
|
it('can be set via `--mainline` flag', async () => {
|
|
225
|
-
const { mainline } = await (0, options_1.getOptions)(['--mainline']);
|
|
239
|
+
const { mainline } = await (0, options_1.getOptions)(['--mainline'], {});
|
|
226
240
|
expect(mainline).toBe(1);
|
|
227
241
|
});
|
|
228
242
|
it('accepts numeric values', async () => {
|
|
229
|
-
const { mainline } = await (0, options_1.getOptions)(['--mainline', '2']);
|
|
243
|
+
const { mainline } = await (0, options_1.getOptions)(['--mainline', '2'], {});
|
|
230
244
|
expect(mainline).toBe(2);
|
|
231
245
|
});
|
|
232
246
|
});
|
|
@@ -235,25 +249,25 @@ describe('getOptions', () => {
|
|
|
235
249
|
mockGithubConfigOptions({ viewerLogin: 'billy.bob' });
|
|
236
250
|
});
|
|
237
251
|
it('defaults to authenticated user', async () => {
|
|
238
|
-
const { author } = await (0, options_1.getOptions)([]);
|
|
252
|
+
const { author } = await (0, options_1.getOptions)([], {});
|
|
239
253
|
expect(author).toBe('billy.bob');
|
|
240
254
|
});
|
|
241
255
|
it('can be overridden via `--author` flag', async () => {
|
|
242
|
-
const { author } = await (0, options_1.getOptions)(['--author', 'john.doe']);
|
|
256
|
+
const { author } = await (0, options_1.getOptions)(['--author', 'john.doe'], {});
|
|
243
257
|
expect(author).toBe('john.doe');
|
|
244
258
|
});
|
|
245
259
|
it('can be reset via `--all` flag', async () => {
|
|
246
|
-
const { author } = await (0, options_1.getOptions)(['--all']);
|
|
260
|
+
const { author } = await (0, options_1.getOptions)(['--all'], {});
|
|
247
261
|
expect(author).toBe(null);
|
|
248
262
|
});
|
|
249
263
|
it('can be reset via config file (similar to `--all` flag)', async () => {
|
|
250
264
|
mockProjectConfig({ author: null });
|
|
251
|
-
const { author } = await (0, options_1.getOptions)([]);
|
|
265
|
+
const { author } = await (0, options_1.getOptions)([], {});
|
|
252
266
|
expect(author).toBe(null);
|
|
253
267
|
});
|
|
254
268
|
it('can be overridden via config file', async () => {
|
|
255
269
|
mockProjectConfig({ author: 'jane.doe' });
|
|
256
|
-
const { author } = await (0, options_1.getOptions)([]);
|
|
270
|
+
const { author } = await (0, options_1.getOptions)([], {});
|
|
257
271
|
expect(author).toBe('jane.doe');
|
|
258
272
|
});
|
|
259
273
|
});
|
|
@@ -262,21 +276,21 @@ describe('getOptions', () => {
|
|
|
262
276
|
mockGithubConfigOptions({});
|
|
263
277
|
});
|
|
264
278
|
it('should default to true', async () => {
|
|
265
|
-
const { cherrypickRef } = await (0, options_1.getOptions)([]);
|
|
279
|
+
const { cherrypickRef } = await (0, options_1.getOptions)([], {});
|
|
266
280
|
expect(cherrypickRef).toBe(true);
|
|
267
281
|
});
|
|
268
282
|
it('should negate with `noCherrypickRef` cli arg', async () => {
|
|
269
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(['--no-cherrypick-ref']);
|
|
283
|
+
const { cherrypickRef } = await (0, options_1.getOptions)(['--no-cherrypick-ref'], {});
|
|
270
284
|
expect(cherrypickRef).toBe(false);
|
|
271
285
|
});
|
|
272
286
|
it('should be settable via config file', async () => {
|
|
273
287
|
mockProjectConfig({ cherrypickRef: false });
|
|
274
|
-
const { cherrypickRef } = await (0, options_1.getOptions)([]);
|
|
288
|
+
const { cherrypickRef } = await (0, options_1.getOptions)([], {});
|
|
275
289
|
expect(cherrypickRef).toBe(false);
|
|
276
290
|
});
|
|
277
291
|
it('cli args overwrites config', async () => {
|
|
278
292
|
mockProjectConfig({ cherrypickRef: false });
|
|
279
|
-
const { cherrypickRef } = await (0, options_1.getOptions)(['--cherrypick-ref']);
|
|
293
|
+
const { cherrypickRef } = await (0, options_1.getOptions)(['--cherrypick-ref'], {});
|
|
280
294
|
expect(cherrypickRef).toBe(true);
|
|
281
295
|
});
|
|
282
296
|
});
|
|
@@ -333,3 +347,25 @@ function mockGithubConfigOptions({ viewerLogin = 'DO_NOT_USE-sqren', defaultBran
|
|
|
333
347
|
},
|
|
334
348
|
});
|
|
335
349
|
}
|
|
350
|
+
function mockRepoOwnerAndName({ repoName, parentRepoOwner, childRepoOwner, }) {
|
|
351
|
+
return (0, nockHelpers_1.mockGqlRequest)({
|
|
352
|
+
name: 'RepoOwnerAndName',
|
|
353
|
+
statusCode: 200,
|
|
354
|
+
body: {
|
|
355
|
+
data: {
|
|
356
|
+
repository: {
|
|
357
|
+
isFork: true,
|
|
358
|
+
name: repoName,
|
|
359
|
+
owner: {
|
|
360
|
+
login: childRepoOwner,
|
|
361
|
+
},
|
|
362
|
+
parent: {
|
|
363
|
+
owner: {
|
|
364
|
+
login: parentRepoOwner,
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
});
|
|
371
|
+
}
|