backport 8.3.0-beta.1 → 8.4.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/dist/backportRun.js +1 -1
- package/dist/entrypoint.module.d.ts +2 -2
- package/dist/entrypoint.module.js +2 -0
- package/dist/entrypoint.module.private.test.js +11 -10
- package/dist/lib/child-process-promisified.js +2 -2
- package/dist/lib/getCommits.js +1 -1
- package/dist/lib/git.js +3 -1
- package/dist/lib/git.test.js +26 -0
- package/dist/lib/github/v3/createStatusComment.js +3 -2
- package/dist/lib/github/v3/createStatusComment.test.js +61 -0
- package/dist/lib/github/v4/apiRequestV4.js +1 -1
- package/dist/lib/github/v4/enablePullRequestAutoMerge.js +2 -1
- package/dist/{entrypoint.cli.private.test.d.ts → lib/github/v4/enablePullRequestAutoMerge.mutation.test.d.ts} +0 -0
- package/dist/lib/github/v4/{enablePullRequestAutoMerge.private.test.js → enablePullRequestAutoMerge.mutation.test.js} +34 -8
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +5 -3
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.js +0 -1
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.js +0 -1
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.js +5 -6
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +7 -3
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +2 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +23 -7
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +2 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +1 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +2 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.d.ts +1 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.js +1 -0
- package/dist/lib/remoteConfig.d.ts +1 -1
- package/dist/lib/remoteConfig.js +4 -0
- package/dist/options/ConfigOptions.d.ts +1 -0
- package/dist/options/cliArgs.d.ts +3 -2
- package/dist/options/cliArgs.js +21 -6
- package/dist/options/config/config.d.ts +1 -0
- package/dist/options/config/readConfigFile.d.ts +1 -0
- package/dist/options/options.d.ts +5 -2
- package/dist/options/options.js +1 -1
- package/dist/options/options.test.js +3 -0
- package/dist/{lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts → test/e2e/cli/date-filters.private.test.d.ts} +0 -0
- package/dist/test/e2e/cli/date-filters.private.test.js +47 -0
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +4 -18
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +14 -15
- package/yarn.lock +165 -171
- package/dist/entrypoint.cli.private.test.js +0 -47
- package/dist/errors/BackportError.d.ts +0 -19
- package/dist/errors/BackportError.js +0 -29
- package/dist/runSequentially.test.d.ts +0 -1
- package/dist/runSequentially.test.js +0 -243
- package/dist/services/BackportError.d.ts +0 -19
- package/dist/services/BackportError.js +0 -29
- package/dist/services/HandledBackportError.d.ts +0 -19
- package/dist/services/HandledBackportError.js +0 -29
- package/dist/services/HandledError.d.ts +0 -19
- package/dist/services/HandledError.js +0 -29
- package/dist/services/child-process-promisified.d.ts +0 -25
- package/dist/services/child-process-promisified.js +0 -58
- package/dist/services/env.d.ts +0 -7
- package/dist/services/env.js +0 -30
- package/dist/services/env.test.d.ts +0 -1
- package/dist/services/env.test.js +0 -21
- package/dist/services/git.d.ts +0 -77
- package/dist/services/git.integration.test.d.ts +0 -1
- package/dist/services/git.integration.test.js +0 -616
- package/dist/services/git.js +0 -439
- package/dist/services/git.private.test.d.ts +0 -1
- package/dist/services/git.private.test.js +0 -618
- package/dist/services/git.test.d.ts +0 -1
- package/dist/services/git.test.js +0 -580
- package/dist/services/github/commitFormatters.d.ts +0 -3
- package/dist/services/github/commitFormatters.js +0 -17
- package/dist/services/github/commitFormatters.test.d.ts +0 -1
- package/dist/services/github/commitFormatters.test.js +0 -11
- package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +0 -2
- package/dist/services/github/v3/addAssigneesToPullRequest.js +0 -32
- package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +0 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.test.js +0 -27
- package/dist/services/github/v3/addLabelsToPullRequest.d.ts +0 -2
- package/dist/services/github/v3/addLabelsToPullRequest.js +0 -30
- package/dist/services/github/v3/addReviewersToPullRequest.d.ts +0 -2
- package/dist/services/github/v3/addReviewersToPullRequest.js +0 -32
- package/dist/services/github/v3/createPullRequest.d.ts +0 -29
- package/dist/services/github/v3/createPullRequest.js +0 -91
- package/dist/services/github/v3/createPullRequest.test.d.ts +0 -1
- package/dist/services/github/v3/createPullRequest.test.js +0 -377
- package/dist/services/github/v3/createStatusComment.d.ts +0 -11
- package/dist/services/github/v3/createStatusComment.js +0 -131
- package/dist/services/github/v3/createStatusComment.test.d.ts +0 -1
- package/dist/services/github/v3/createStatusComment.test.js +0 -409
- package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +0 -14
- package/dist/services/github/v3/getGithubV3ErrorMessage.js +0 -16
- package/dist/services/github/v4/FetchPullRequestId.d.ts +0 -2
- package/dist/services/github/v4/FetchPullRequestId.js +0 -36
- package/dist/services/github/v4/apiRequestV4.d.ts +0 -31
- package/dist/services/github/v4/apiRequestV4.js +0 -71
- package/dist/services/github/v4/apiRequestV4.test.d.ts +0 -1
- package/dist/services/github/v4/apiRequestV4.test.js +0 -109
- package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -2
- package/dist/services/github/v4/disablePullRequestAutoMerge.js +0 -32
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -2
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +0 -50
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +0 -1
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
- package/dist/services/github/v4/fetchAuthorId.d.ts +0 -10
- package/dist/services/github/v4/fetchAuthorId.js +0 -28
- package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchAuthorId.private.test.js +0 -25
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -93
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +0 -11
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +0 -58
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +0 -136
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +0 -11
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +0 -48
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +0 -118
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +0 -29
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +0 -110
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +0 -196
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -157
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +0 -3
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +0 -61
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +0 -107
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +0 -12
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +0 -69
- package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -9
- package/dist/services/github/v4/fetchExistingPullRequest.js +0 -64
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -44
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -2
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +0 -39
- package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +0 -8
- package/dist/services/github/v4/fetchRemoteProjectConfig.js +0 -49
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +0 -49
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +0 -69
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +0 -73
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +0 -1
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -116
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +0 -16
- package/dist/services/github/v4/getOptionsFromGithub/query.js +0 -29
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +0 -29
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +0 -61
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +0 -1
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +0 -72
- package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +0 -176
- package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +0 -6
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +0 -45
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +0 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +0 -87
- package/dist/services/logger.d.ts +0 -9
- package/dist/services/logger.js +0 -74
- package/dist/services/prompt.test.d.ts +0 -1
- package/dist/services/prompt.test.js +0 -139
- package/dist/services/prompts.d.ts +0 -17
- package/dist/services/prompts.js +0 -132
- package/dist/services/remoteConfig.d.ts +0 -20
- package/dist/services/remoteConfig.js +0 -52
- package/dist/services/sequentially.d.ts +0 -1
- package/dist/services/sequentially.js +0 -10
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +0 -16
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +0 -102
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +0 -1
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +0 -467
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +0 -26
- package/dist/services/sourceCommit/getMockSourceCommit.js +0 -103
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +0 -108
- package/dist/services/sourceCommit/parseSourceCommit.js +0 -123
- package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit/parseSourceCommit.test.js +0 -226
- package/dist/services/test.d.ts +0 -1
- package/dist/services/test.js +0 -23
- package/dist/state.d.ts +0 -0
- package/dist/state.js +0 -1
- package/dist/test/ExecError.d.ts +0 -16
- package/dist/test/ExecError.js +0 -15
- package/dist/test/e2e/cli/cli.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/cli.private.test.js +0 -222
- package/dist/test/e2e/cli/interactive-error-handling.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/interactive-error-handling.private.test.js +0 -80
- package/dist/test/e2e/cli/non-interactive-error-handling.private.test.d.ts +0 -1
- package/dist/test/e2e/cli/non-interactive-error-handling.private.test.js +0 -198
- package/dist/test/e2e/cli.e2e.private.test.d.ts +0 -1
- package/dist/test/e2e/cli.e2e.private.test.js +0 -433
- package/dist/test/e2e/module/module.mutation.test.d.ts +0 -1
- package/dist/test/e2e/module/module.mutation.test.js +0 -369
- package/dist/test/e2e/module.e2e.mutation.test.d.ts +0 -1
- package/dist/test/e2e/module.e2e.mutation.test.js +0 -369
- package/dist/test/e2e/module.e2e.private.test.d.ts +0 -1
- package/dist/test/e2e/module.e2e.private.test.js +0 -369
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -13
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +0 -243
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +0 -320
- package/dist/ui/getCommits.d.ts +0 -2
- package/dist/ui/getCommits.js +0 -75
- package/dist/ui/getCommitsWithoutBackports.d.ts +0 -11
- package/dist/ui/getCommitsWithoutBackports.js +0 -68
- package/dist/ui/getCommitsWithoutBackports.test.d.ts +0 -1
- package/dist/ui/getCommitsWithoutBackports.test.js +0 -335
- package/dist/ui/getGitConfigAuthor.d.ts +0 -6
- package/dist/ui/getGitConfigAuthor.js +0 -15
- package/dist/ui/getTargetBranches.d.ts +0 -5
- package/dist/ui/getTargetBranches.js +0 -67
- package/dist/ui/getTargetBranches.test.d.ts +0 -1
- package/dist/ui/getTargetBranches.test.js +0 -204
- package/dist/ui/maybeSetupRepo.d.ts +0 -2
- package/dist/ui/maybeSetupRepo.js +0 -53
- package/dist/ui/maybeSetupRepo.test.d.ts +0 -1
- package/dist/ui/maybeSetupRepo.test.js +0 -238
- package/dist/ui/ora.d.ts +0 -2
- package/dist/ui/ora.js +0 -21
- package/dist/ui/setupRepo.d.ts +0 -2
- package/dist/ui/setupRepo.js +0 -56
- package/dist/ui/setupRepo.test.d.ts +0 -1
- package/dist/ui/setupRepo.test.js +0 -273
- package/dist/utils/filterMissingCommits.d.ts +0 -2
- package/dist/utils/filterMissingCommits.js +0 -7
- package/dist/utils/redact.d.ts +0 -1
- package/dist/utils/redact.js +0 -7
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
4
|
-
const fetchRemoteProjectConfig_1 = require("./fetchRemoteProjectConfig");
|
|
5
|
-
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
6
|
-
describe('fetchRemoteProjectConfig', () => {
|
|
7
|
-
it('returns the backport config from "main" branch', async () => {
|
|
8
|
-
const projectConfig = await (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
9
|
-
repoOwner: 'backport-org',
|
|
10
|
-
repoName: 'repo-with-project-config',
|
|
11
|
-
accessToken,
|
|
12
|
-
sourceBranch: 'main',
|
|
13
|
-
});
|
|
14
|
-
expect(projectConfig).toEqual({
|
|
15
|
-
autoMerge: true,
|
|
16
|
-
autoMergeMethod: 'squash',
|
|
17
|
-
branchLabelMapping: {
|
|
18
|
-
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
19
|
-
'^v8.1.0$': 'main',
|
|
20
|
-
},
|
|
21
|
-
targetBranchChoices: ['main', '8.0', '7.17', '7.16'],
|
|
22
|
-
targetPRLabels: ['backport'],
|
|
23
|
-
repoOwner: 'backport-org',
|
|
24
|
-
repoName: 'repo-with-project-config',
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
it('returns the backport config from "branch-with-legacy-config" branch', async () => {
|
|
28
|
-
const projectConfig = await (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
29
|
-
repoOwner: 'backport-org',
|
|
30
|
-
repoName: 'repo-with-project-config',
|
|
31
|
-
accessToken,
|
|
32
|
-
sourceBranch: 'branch-with-legacy-config',
|
|
33
|
-
});
|
|
34
|
-
expect(projectConfig).toEqual({
|
|
35
|
-
targetBranchChoices: ['main', '8.0', '7.17', '7.16'],
|
|
36
|
-
repoOwner: 'backport-org',
|
|
37
|
-
repoName: 'repo-with-project-config',
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
it('throws an error if config does not exist', async () => {
|
|
41
|
-
const promise = (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
42
|
-
repoOwner: 'backport-org',
|
|
43
|
-
repoName: 'repo-with-project-config',
|
|
44
|
-
accessToken,
|
|
45
|
-
sourceBranch: 'branch-with-no-config',
|
|
46
|
-
});
|
|
47
|
-
await expect(promise).rejects.toThrowError('Project config does not exist');
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
export declare type OptionsFromGithub = Awaited<ReturnType<typeof getOptionsFromGithub>>;
|
|
2
|
-
export declare function getOptionsFromGithub(options: {
|
|
3
|
-
accessToken: string;
|
|
4
|
-
cwd?: string;
|
|
5
|
-
githubApiBaseUrlV4?: string;
|
|
6
|
-
repoName: string;
|
|
7
|
-
repoOwner: string;
|
|
8
|
-
skipRemoteConfig?: boolean;
|
|
9
|
-
}): Promise<{
|
|
10
|
-
accessToken?: string | undefined;
|
|
11
|
-
assignees?: string[] | undefined;
|
|
12
|
-
author?: string | null | undefined;
|
|
13
|
-
autoAssign?: boolean | undefined;
|
|
14
|
-
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
15
|
-
files: string[];
|
|
16
|
-
directory: string;
|
|
17
|
-
logger: import("winston").Logger;
|
|
18
|
-
targetBranch: string;
|
|
19
|
-
}) => boolean | Promise<boolean>) | undefined;
|
|
20
|
-
autoMerge?: boolean | undefined;
|
|
21
|
-
autoMergeMethod?: string | undefined;
|
|
22
|
-
backportBinary?: string | undefined;
|
|
23
|
-
cherrypickRef?: boolean | undefined;
|
|
24
|
-
ci?: boolean | undefined;
|
|
25
|
-
commitPaths?: string[] | undefined;
|
|
26
|
-
details?: boolean | undefined;
|
|
27
|
-
dir?: string | undefined;
|
|
28
|
-
dryRun?: boolean | undefined;
|
|
29
|
-
editor?: string | undefined;
|
|
30
|
-
fork?: boolean | undefined;
|
|
31
|
-
gitAuthorEmail?: string | undefined;
|
|
32
|
-
gitAuthorName?: string | undefined;
|
|
33
|
-
gitHostname?: string | undefined;
|
|
34
|
-
githubApiBaseUrlV3?: string | undefined;
|
|
35
|
-
githubApiBaseUrlV4?: string | undefined;
|
|
36
|
-
logFilePath?: string | undefined;
|
|
37
|
-
ls?: boolean | undefined;
|
|
38
|
-
maxNumber?: number | undefined;
|
|
39
|
-
multiple?: boolean | undefined;
|
|
40
|
-
multipleBranches?: boolean | undefined;
|
|
41
|
-
multipleCommits?: boolean | undefined;
|
|
42
|
-
noVerify?: boolean | undefined;
|
|
43
|
-
prDescription?: string | undefined;
|
|
44
|
-
prFilter?: string | undefined;
|
|
45
|
-
projectConfigFile?: string | undefined;
|
|
46
|
-
prTitle?: string | undefined;
|
|
47
|
-
publishStatusComment?: boolean | undefined;
|
|
48
|
-
pullNumber?: number | undefined;
|
|
49
|
-
repoForkOwner?: string | undefined;
|
|
50
|
-
repoName?: string | undefined;
|
|
51
|
-
repoOwner?: string | undefined;
|
|
52
|
-
resetAuthor?: boolean | undefined;
|
|
53
|
-
reviewers?: string[] | undefined;
|
|
54
|
-
sha?: string | string[] | undefined;
|
|
55
|
-
skipRemoteConfig?: boolean | undefined;
|
|
56
|
-
sourceBranch: string;
|
|
57
|
-
sourcePRLabels?: string[] | undefined;
|
|
58
|
-
targetBranchChoices?: import("../../../../options/ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
59
|
-
targetBranches?: string[] | undefined;
|
|
60
|
-
targetPRLabels?: string[] | undefined;
|
|
61
|
-
help?: boolean | undefined;
|
|
62
|
-
version?: boolean | undefined;
|
|
63
|
-
v?: boolean | undefined;
|
|
64
|
-
branchLabelMapping?: Record<string, string> | undefined;
|
|
65
|
-
upstream?: string | undefined;
|
|
66
|
-
branches?: import("../../../../options/ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
67
|
-
labels?: string[] | undefined;
|
|
68
|
-
authenticatedUsername: string;
|
|
69
|
-
}>;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOptionsFromGithub = void 0;
|
|
4
|
-
const BackportError_1 = require("../../../BackportError");
|
|
5
|
-
const git_1 = require("../../../git");
|
|
6
|
-
const logger_1 = require("../../../logger");
|
|
7
|
-
const remoteConfig_1 = require("../../../remoteConfig");
|
|
8
|
-
const apiRequestV4_1 = require("../apiRequestV4");
|
|
9
|
-
const throwOnInvalidAccessToken_1 = require("../throwOnInvalidAccessToken");
|
|
10
|
-
const query_1 = require("./query");
|
|
11
|
-
async function getOptionsFromGithub(options) {
|
|
12
|
-
const { accessToken, githubApiBaseUrlV4, repoName, repoOwner } = options;
|
|
13
|
-
let res;
|
|
14
|
-
try {
|
|
15
|
-
res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
16
|
-
githubApiBaseUrlV4,
|
|
17
|
-
accessToken,
|
|
18
|
-
query: query_1.query,
|
|
19
|
-
variables: { repoOwner, repoName },
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
if (!(e instanceof apiRequestV4_1.GithubV4Exception)) {
|
|
24
|
-
throw e;
|
|
25
|
-
}
|
|
26
|
-
(0, throwOnInvalidAccessToken_1.throwOnInvalidAccessToken)({ error: e, repoName, repoOwner });
|
|
27
|
-
res = (0, remoteConfig_1.swallowMissingConfigFileException)(e);
|
|
28
|
-
}
|
|
29
|
-
// it is not possible to have a branch named "backport"
|
|
30
|
-
if (res.repository.illegalBackportBranch) {
|
|
31
|
-
throw new BackportError_1.BackportError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
32
|
-
}
|
|
33
|
-
const remoteConfig = await getRemoteConfigFileOptions(res, options.cwd, options.skipRemoteConfig);
|
|
34
|
-
return {
|
|
35
|
-
authenticatedUsername: res.viewer.login,
|
|
36
|
-
sourceBranch: res.repository.defaultBranchRef.name,
|
|
37
|
-
...remoteConfig,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
exports.getOptionsFromGithub = getOptionsFromGithub;
|
|
41
|
-
async function getRemoteConfigFileOptions(res, cwd, skipRemoteConfig) {
|
|
42
|
-
if (skipRemoteConfig) {
|
|
43
|
-
logger_1.logger.info('Skipping remote config: `--skip-remote-config` specified via config file or cli');
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const remoteConfig = res.repository.defaultBranchRef.target.remoteConfigHistory.edges?.[0]
|
|
47
|
-
?.remoteConfig;
|
|
48
|
-
if (!remoteConfig) {
|
|
49
|
-
logger_1.logger.info("Skipping remote config: remote config doesn't exist");
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (cwd) {
|
|
53
|
-
const [isLocalConfigModified, isLocalConfigUntracked, localCommitDate] = await Promise.all([
|
|
54
|
-
(0, git_1.isLocalConfigFileModified)({ cwd }),
|
|
55
|
-
(0, git_1.isLocalConfigFileUntracked)({ cwd }),
|
|
56
|
-
(0, git_1.getLocalConfigFileCommitDate)({ cwd }),
|
|
57
|
-
]);
|
|
58
|
-
if (isLocalConfigUntracked) {
|
|
59
|
-
logger_1.logger.info('Skipping remote config: local config is new');
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (isLocalConfigModified) {
|
|
63
|
-
logger_1.logger.info('Skipping remote config: local config is modified');
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (localCommitDate &&
|
|
67
|
-
localCommitDate > Date.parse(remoteConfig.committedDate)) {
|
|
68
|
-
logger_1.logger.info(`Skipping remote config: local config is newer: ${new Date(localCommitDate).toISOString()} > ${remoteConfig.committedDate}`);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return (0, remoteConfig_1.parseRemoteConfig)(remoteConfig);
|
|
73
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const os_1 = __importDefault(require("os"));
|
|
7
|
-
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
8
|
-
const getOptionsFromGithub_1 = require("./getOptionsFromGithub");
|
|
9
|
-
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
10
|
-
describe('getOptionsFromGithub', () => {
|
|
11
|
-
beforeAll(async () => {
|
|
12
|
-
jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
|
|
13
|
-
});
|
|
14
|
-
describe('access token', () => {
|
|
15
|
-
describe('is invalid', () => {
|
|
16
|
-
it('throws an error', async () => {
|
|
17
|
-
const combinedOptions = {
|
|
18
|
-
author: 'sqren',
|
|
19
|
-
accessToken: 'foo',
|
|
20
|
-
repoOwner: 'backport-org',
|
|
21
|
-
repoName: 'backport-e2e',
|
|
22
|
-
cwd: process.cwd(),
|
|
23
|
-
};
|
|
24
|
-
await expect((0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions)).rejects.toThrowError('Please check your access token and make sure it is valid.\nConfig: /myHomeDir/.backport/config.json');
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe('is valid', () => {
|
|
28
|
-
it('returns the options', async () => {
|
|
29
|
-
const combinedOptions = {
|
|
30
|
-
author: 'sqren',
|
|
31
|
-
accessToken,
|
|
32
|
-
repoOwner: 'backport-org',
|
|
33
|
-
repoName: 'backport-e2e',
|
|
34
|
-
cwd: process.cwd(),
|
|
35
|
-
};
|
|
36
|
-
expect(await (0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions)).toEqual({
|
|
37
|
-
authenticatedUsername: 'sqren',
|
|
38
|
-
branchLabelMapping: {
|
|
39
|
-
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
40
|
-
'^v7.9.0$': '7.x',
|
|
41
|
-
'^v8.0.0$': 'master',
|
|
42
|
-
},
|
|
43
|
-
sourceBranch: 'master',
|
|
44
|
-
targetBranchChoices: [
|
|
45
|
-
{ checked: true, name: 'master' },
|
|
46
|
-
{ checked: true, name: '7.x' },
|
|
47
|
-
'7.8',
|
|
48
|
-
],
|
|
49
|
-
targetPRLabels: ['backport'],
|
|
50
|
-
repoOwner: 'backport-org',
|
|
51
|
-
repoName: 'backport-e2e',
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
describe('when `repoOwner` is fork', () => {
|
|
57
|
-
it('returns original repoOwner', async () => {
|
|
58
|
-
const combinedOptions = {
|
|
59
|
-
author: 'sqren',
|
|
60
|
-
accessToken,
|
|
61
|
-
repoOwner: 'sqren',
|
|
62
|
-
repoName: 'backport-e2e',
|
|
63
|
-
cwd: process.cwd(),
|
|
64
|
-
};
|
|
65
|
-
const options = await (0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions);
|
|
66
|
-
await expect(options.repoOwner).toEqual('backport-org');
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
describe('sourceBranch', () => {
|
|
70
|
-
describe('when no sourceBranch is specified', () => {
|
|
71
|
-
it('uses the default branch of the repo', async () => {
|
|
72
|
-
const combinedOptions = {
|
|
73
|
-
author: 'sqren',
|
|
74
|
-
accessToken,
|
|
75
|
-
repoOwner: 'backport-org',
|
|
76
|
-
repoName: 'repo-with-non-standard-main-branch',
|
|
77
|
-
cwd: process.cwd(),
|
|
78
|
-
};
|
|
79
|
-
const options = await (0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions);
|
|
80
|
-
await expect(options.sourceBranch).toEqual('my-custom-default-branch');
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
describe('when a branch named "backport"', () => {
|
|
85
|
-
describe('exists', () => {
|
|
86
|
-
it('shows a warning', async () => {
|
|
87
|
-
const combinedOptions = {
|
|
88
|
-
author: 'sqren',
|
|
89
|
-
accessToken,
|
|
90
|
-
repoOwner: 'backport-org',
|
|
91
|
-
repoName: 'repo-with-branch-named-backport',
|
|
92
|
-
cwd: process.cwd(),
|
|
93
|
-
};
|
|
94
|
-
await expect(async () => {
|
|
95
|
-
await (0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions);
|
|
96
|
-
}).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
describe('when a backportrc.json config was deleted from repo', () => {
|
|
101
|
-
it('does not throw', async () => {
|
|
102
|
-
const combinedOptions = {
|
|
103
|
-
author: 'sqren',
|
|
104
|
-
accessToken,
|
|
105
|
-
repoOwner: 'backport-org',
|
|
106
|
-
repoName: 'repo-with-backportrc-removed',
|
|
107
|
-
cwd: process.cwd(),
|
|
108
|
-
};
|
|
109
|
-
const options = await (0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions);
|
|
110
|
-
expect(options).toEqual({
|
|
111
|
-
authenticatedUsername: 'sqren',
|
|
112
|
-
sourceBranch: 'main',
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { RemoteConfigHistory } from '../../../remoteConfig';
|
|
2
|
-
export interface GithubConfigOptionsResponse {
|
|
3
|
-
viewer: {
|
|
4
|
-
login: string;
|
|
5
|
-
};
|
|
6
|
-
repository: {
|
|
7
|
-
illegalBackportBranch: {
|
|
8
|
-
id: string;
|
|
9
|
-
} | null;
|
|
10
|
-
defaultBranchRef: {
|
|
11
|
-
name: string;
|
|
12
|
-
target: RemoteConfigHistory;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export declare const query: import("graphql").DocumentNode;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.query = void 0;
|
|
7
|
-
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
-
const remoteConfig_1 = require("../../../remoteConfig");
|
|
9
|
-
exports.query = (0, graphql_tag_1.default) `
|
|
10
|
-
query GithubConfigOptions($repoOwner: String!, $repoName: String!) {
|
|
11
|
-
viewer {
|
|
12
|
-
login
|
|
13
|
-
}
|
|
14
|
-
repository(owner: $repoOwner, name: $repoName) {
|
|
15
|
-
# check to see if a branch named "backport" exists
|
|
16
|
-
illegalBackportBranch: ref(qualifiedName: "refs/heads/backport") {
|
|
17
|
-
id
|
|
18
|
-
}
|
|
19
|
-
defaultBranchRef {
|
|
20
|
-
name
|
|
21
|
-
target {
|
|
22
|
-
...RemoteConfigHistoryFragment
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
${remoteConfig_1.RemoteConfigHistoryFragment}
|
|
29
|
-
`;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export declare function getRepoOwnerAndNameFromGitRemotes({ accessToken, githubApiBaseUrlV4, cwd, }: {
|
|
2
|
-
accessToken: string;
|
|
3
|
-
githubApiBaseUrlV4?: string;
|
|
4
|
-
cwd: string;
|
|
5
|
-
}): Promise<{
|
|
6
|
-
repoOwner?: string;
|
|
7
|
-
repoName?: string;
|
|
8
|
-
}>;
|
|
9
|
-
export interface RepoOwnerAndNameResponse {
|
|
10
|
-
repository: {
|
|
11
|
-
isFork: true;
|
|
12
|
-
name: string;
|
|
13
|
-
owner: {
|
|
14
|
-
login: string;
|
|
15
|
-
};
|
|
16
|
-
parent: {
|
|
17
|
-
owner: {
|
|
18
|
-
login: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
} | {
|
|
22
|
-
isFork: false;
|
|
23
|
-
name: string;
|
|
24
|
-
owner: {
|
|
25
|
-
login: string;
|
|
26
|
-
};
|
|
27
|
-
parent: null;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getRepoOwnerAndNameFromGitRemotes = void 0;
|
|
7
|
-
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
-
const maybe_1 = require("../../../utils/maybe");
|
|
9
|
-
const git_1 = require("../../git");
|
|
10
|
-
const logger_1 = require("../../logger");
|
|
11
|
-
const apiRequestV4_1 = require("./apiRequestV4");
|
|
12
|
-
// This method should be used to get the origin owner (instead of a fork owner)
|
|
13
|
-
async function getRepoOwnerAndNameFromGitRemotes({ accessToken, githubApiBaseUrlV4, cwd, }) {
|
|
14
|
-
const remotes = await (0, git_1.getRepoInfoFromGitRemotes)({ cwd });
|
|
15
|
-
const firstRemote = (0, maybe_1.maybe)(remotes[0]);
|
|
16
|
-
if (!firstRemote) {
|
|
17
|
-
return {};
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
const res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
21
|
-
githubApiBaseUrlV4,
|
|
22
|
-
accessToken,
|
|
23
|
-
query,
|
|
24
|
-
variables: {
|
|
25
|
-
repoOwner: firstRemote.repoOwner,
|
|
26
|
-
repoName: firstRemote.repoName,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
return {
|
|
30
|
-
repoName: res.repository.name,
|
|
31
|
-
// get the original owner (not the fork owner)
|
|
32
|
-
repoOwner: res.repository.isFork
|
|
33
|
-
? res.repository.parent.owner.login
|
|
34
|
-
: res.repository.owner.login,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
if (e instanceof apiRequestV4_1.GithubV4Exception) {
|
|
39
|
-
logger_1.logger.error(e.message);
|
|
40
|
-
return {};
|
|
41
|
-
}
|
|
42
|
-
throw e;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.getRepoOwnerAndNameFromGitRemotes = getRepoOwnerAndNameFromGitRemotes;
|
|
46
|
-
const query = (0, graphql_tag_1.default) `
|
|
47
|
-
query RepoOwnerAndName($repoOwner: String!, $repoName: String!) {
|
|
48
|
-
repository(owner: $repoOwner, name: $repoName) {
|
|
49
|
-
isFork
|
|
50
|
-
name
|
|
51
|
-
owner {
|
|
52
|
-
login
|
|
53
|
-
}
|
|
54
|
-
parent {
|
|
55
|
-
owner {
|
|
56
|
-
login
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
27
|
-
const sandbox_1 = require("../../../test/sandbox");
|
|
28
|
-
const childProcess = __importStar(require("../../child-process-promisified"));
|
|
29
|
-
const getRepoOwnerAndNameFromGitRemotes_1 = require("./getRepoOwnerAndNameFromGitRemotes");
|
|
30
|
-
const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
31
|
-
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
32
|
-
describe('fetchRemoteProjectConfig', () => {
|
|
33
|
-
describe('when the remote is a fork', () => {
|
|
34
|
-
it('retrives the original owner from github', async () => {
|
|
35
|
-
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
36
|
-
const execOpts = { cwd: sandboxPath };
|
|
37
|
-
await childProcess.exec(`git init`, execOpts);
|
|
38
|
-
await childProcess.exec(`git remote add sqren git@github.com:sqren/kibana.git`, execOpts);
|
|
39
|
-
expect(await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
|
|
40
|
-
accessToken,
|
|
41
|
-
cwd: sandboxPath,
|
|
42
|
-
})).toEqual({
|
|
43
|
-
repoName: 'kibana',
|
|
44
|
-
repoOwner: 'elastic',
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
describe('when none of the git remotes are found', () => {
|
|
49
|
-
it('swallows the error and returns empty', async () => {
|
|
50
|
-
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
51
|
-
const execOpts = { cwd: sandboxPath };
|
|
52
|
-
await childProcess.exec(`git init`, execOpts);
|
|
53
|
-
await childProcess.exec(`git remote add foo git@github.com:foo/kibana.git`, execOpts);
|
|
54
|
-
await childProcess.exec(`git remote add bar git@github.com:bar/kibana.git`, execOpts);
|
|
55
|
-
expect(await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
|
|
56
|
-
accessToken,
|
|
57
|
-
cwd: sandboxPath,
|
|
58
|
-
})).toEqual({});
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
describe('when there are no git remotes', () => {
|
|
62
|
-
it('returns empty', async () => {
|
|
63
|
-
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
64
|
-
const execOpts = { cwd: sandboxPath };
|
|
65
|
-
await childProcess.exec(`git init`, execOpts);
|
|
66
|
-
expect(await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
|
|
67
|
-
accessToken,
|
|
68
|
-
cwd: sandboxPath,
|
|
69
|
-
})).toEqual({});
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|