backport 6.1.4 → 6.3.0-beta
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 +53 -42
- package/dist/{main.d.ts → backportRun.d.ts} +3 -3
- package/dist/{main.js → backportRun.js} +24 -9
- package/dist/entrypoint.cli.js +3 -5
- package/dist/entrypoint.module.d.ts +4 -3
- package/dist/entrypoint.module.js +9 -7
- package/dist/options/ConfigOptions.d.ts +6 -0
- package/dist/options/cliArgs.d.ts +17 -13
- package/dist/options/cliArgs.js +25 -6
- package/dist/options/config/config.d.ts +12 -1
- package/dist/options/config/config.js +8 -7
- package/dist/options/config/globalConfig.d.ts +2 -2
- package/dist/options/config/globalConfig.js +18 -16
- package/dist/options/config/projectConfig.d.ts +3 -1
- package/dist/options/config/projectConfig.js +5 -2
- package/dist/options/config/readConfigFile.d.ts +28 -22
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +19 -37
- package/dist/options/options.js +44 -31
- package/dist/runSequentially.d.ts +0 -1
- package/dist/runSequentially.js +0 -1
- 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 +5 -4
- package/dist/services/env.js +13 -11
- package/dist/services/git.d.ts +22 -9
- package/dist/services/git.js +66 -54
- 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/createStatusComment.d.ts +1 -1
- package/dist/services/github/v3/createStatusComment.js +34 -18
- 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/disablePullRequestAutoMerge.d.ts +0 -7
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -7
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +1 -8
- 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/{fetchProjectConfig.d.ts → fetchRemoteProjectConfig.d.ts} +1 -1
- package/dist/services/github/v4/{fetchProjectConfig.js → fetchRemoteProjectConfig.js} +3 -3
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +7 -1
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +38 -39
- 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/services/github/v4/throwOnInvalidAccessToken.d.ts +4 -5
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -7
- package/dist/services/logger.d.ts +9 -4
- package/dist/services/logger.js +40 -37
- 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/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +13 -14
- package/dist/ui/getCommits.js +8 -14
- package/dist/ui/getCommitsWithoutBackports.js +6 -6
- package/dist/ui/getTargetBranches.js +1 -1
- package/dist/ui/maybeSetupRepo.js +24 -10
- 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/dist/utils/redact.d.ts +1 -0
- package/dist/utils/redact.js +7 -0
- package/package.json +24 -20
- package/yarn.lock +160 -237
- package/dist/entrypoint.module.private.test.d.ts +0 -1
- package/dist/entrypoint.module.private.test.js +0 -37
- 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/cliArgs.test.d.ts +0 -1
- package/dist/options/cliArgs.test.js +0 -152
- package/dist/options/config/config.test.d.ts +0 -1
- package/dist/options/config/config.test.js +0 -22
- package/dist/options/config/getOptionsFromGit.d.ts +0 -4
- package/dist/options/config/getOptionsFromGit.js +0 -8
- package/dist/options/config/globalConfig.test.d.ts +0 -1
- package/dist/options/config/globalConfig.test.js +0 -74
- package/dist/options/config/projectConfig.test.d.ts +0 -1
- package/dist/options/config/projectConfig.test.js +0 -99
- package/dist/options/getValidatedOptions.d.ts +0 -49
- package/dist/options/getValidatedOptions.js +0 -45
- package/dist/options/getValidatedOptions.test.d.ts +0 -1
- package/dist/options/getValidatedOptions.test.js +0 -97
- package/dist/options/options.test.d.ts +0 -1
- package/dist/options/options.test.js +0 -335
- package/dist/options/parseRequiredOptions.d.ts +0 -71
- package/dist/options/parseRequiredOptions.js +0 -68
- package/dist/options/parseRequiredOptions.test.d.ts +0 -1
- package/dist/options/parseRequiredOptions.test.js +0 -122
- package/dist/runSequentially.test.d.ts +0 -1
- package/dist/runSequentially.test.js +0 -199
- package/dist/runWithOptions.d.ts +0 -9
- package/dist/runWithOptions.js +0 -43
- package/dist/runWithOptions.test.d.ts +0 -1
- package/dist/runWithOptions.test.js +0 -304
- package/dist/scripts/generate-gql.d.ts +0 -1
- package/dist/scripts/generate-gql.js +0 -15
- package/dist/scripts/postinstall.test.d.ts +0 -1
- package/dist/scripts/postinstall.test.js +0 -53
- package/dist/services/env.test.d.ts +0 -1
- package/dist/services/env.test.js +0 -27
- 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/git.integration.test.d.ts +0 -1
- package/dist/services/git.integration.test.js +0 -168
- package/dist/services/git.test.d.ts +0 -1
- package/dist/services/git.test.js +0 -503
- 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.test.d.ts +0 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.test.js +0 -27
- package/dist/services/github/v3/createPullRequest.test.d.ts +0 -1
- package/dist/services/github/v3/createPullRequest.test.js +0 -110
- package/dist/services/github/v3/createStatusComment.test.d.ts +0 -1
- package/dist/services/github/v3/createStatusComment.test.js +0 -291
- package/dist/services/github/v4/apiRequestV4.test.d.ts +0 -1
- package/dist/services/github/v4/apiRequestV4.test.js +0 -82
- 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.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchAuthorId.private.test.js +0 -28
- 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/allFetchers.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -78
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +0 -134
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +0 -115
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +0 -200
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -131
- 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.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +0 -85
- 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/fetchExistingPullRequest.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -47
- 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.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/getOptionsFromGithub.private.test.d.ts +0 -1
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -130
- 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/commitsByAuthorMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +0 -154
- 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/github/v4/throwOnInvalidAccessToken.test.d.ts +0 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +0 -87
- package/dist/services/prompt.test.d.ts +0 -1
- package/dist/services/prompt.test.js +0 -87
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +0 -1
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +0 -433
- 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/parseSourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit/parseSourceCommit.test.js +0 -237
- 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/ExecError.d.ts +0 -16
- package/dist/test/ExecError.js +0 -15
- 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.private.test.js +0 -327
- package/dist/test/integration/integration.test.d.ts +0 -1
- package/dist/test/integration/integration.test.js +0 -214
- package/dist/test/mockConfigFiles.d.ts +0 -5
- package/dist/test/mockConfigFiles.js +0 -37
- package/dist/test/nockHelpers.d.ts +0 -16
- package/dist/test/nockHelpers.js +0 -32
- package/dist/test/private/getDevAccessToken.d.ts +0 -1
- package/dist/test/private/getDevAccessToken.js +0 -24
- package/dist/test/setupFiles/automatic-mocks.d.ts +0 -0
- package/dist/test/setupFiles/automatic-mocks.js +0 -43
- 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/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +0 -432
- package/dist/ui/getCommitsWithoutBackports.test.d.ts +0 -1
- package/dist/ui/getCommitsWithoutBackports.test.js +0 -259
- package/dist/ui/getTargetBranches.test.d.ts +0 -1
- package/dist/ui/getTargetBranches.test.js +0 -180
- 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
- package/dist/ui/maybeSetupRepo.test.d.ts +0 -1
- package/dist/ui/maybeSetupRepo.test.js +0 -74
- package/dist/utils/excludeUndefined.test.d.ts +0 -1
- package/dist/utils/excludeUndefined.test.js +0 -24
|
@@ -1,214 +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 lodash_1 = require("lodash");
|
|
7
|
-
const nock_1 = __importDefault(require("nock"));
|
|
8
|
-
const options_1 = require("../../options/options");
|
|
9
|
-
const runWithOptions_1 = require("../../runWithOptions");
|
|
10
|
-
const createSpies_1 = require("./createSpies");
|
|
11
|
-
const envConstants_1 = require("./envConstants");
|
|
12
|
-
const helpers_1 = require("./helpers");
|
|
13
|
-
jest.unmock('make-dir');
|
|
14
|
-
jest.unmock('del');
|
|
15
|
-
describe('integration', () => {
|
|
16
|
-
afterAll(() => {
|
|
17
|
-
nock_1.default.cleanAll();
|
|
18
|
-
});
|
|
19
|
-
describe('when a single commit is backported', () => {
|
|
20
|
-
let res;
|
|
21
|
-
let spies;
|
|
22
|
-
beforeEach((0, lodash_1.once)(async () => {
|
|
23
|
-
jest.clearAllMocks();
|
|
24
|
-
spies = (0, createSpies_1.createSpies)({ commitCount: 1 });
|
|
25
|
-
await (0, helpers_1.deleteAndSetupEnvironment)();
|
|
26
|
-
const options = await (0, options_1.getOptions)([], {
|
|
27
|
-
// use localhost to avoid CORS issues
|
|
28
|
-
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
29
|
-
});
|
|
30
|
-
res = await (0, runWithOptions_1.runWithOptions)(options);
|
|
31
|
-
}));
|
|
32
|
-
it('returns pull request', () => {
|
|
33
|
-
expect(res).toEqual([
|
|
34
|
-
{ pullRequestUrl: 'myHtmlUrl', success: true, targetBranch: '6.0' },
|
|
35
|
-
]);
|
|
36
|
-
});
|
|
37
|
-
it('sends the correct http body when creating pull request', () => {
|
|
38
|
-
expect(spies.createPullRequestCalls).toEqual([
|
|
39
|
-
{
|
|
40
|
-
base: '6.0',
|
|
41
|
-
body: 'Backports the following commits to 6.0:\n - #85',
|
|
42
|
-
head: 'sqren:backport/6.0/pr-85',
|
|
43
|
-
title: '[6.0] Add witch (#85)',
|
|
44
|
-
},
|
|
45
|
-
]);
|
|
46
|
-
});
|
|
47
|
-
it('should make correct API requests', () => {
|
|
48
|
-
expect(spies.getGithubConfigOptionsCalls).toMatchSnapshot();
|
|
49
|
-
expect(spies.authorIdCalls).toMatchSnapshot();
|
|
50
|
-
expect(spies.commitsByAuthorCalls).toMatchSnapshot();
|
|
51
|
-
});
|
|
52
|
-
it('should not create new branches in origin (backport-org/backport-demo)', async () => {
|
|
53
|
-
const branches = await (0, helpers_1.getBranches)(envConstants_1.REMOTE_ORIGIN_REPO_PATH);
|
|
54
|
-
expect(branches).toEqual(['6.0', '* master']);
|
|
55
|
-
});
|
|
56
|
-
it('should create branch in the fork (sqren/backport-demo)', async () => {
|
|
57
|
-
const branches = await (0, helpers_1.getBranches)(envConstants_1.REMOTE_FORK_REPO_PATH);
|
|
58
|
-
expect(branches).toEqual(['6.0', 'backport/6.0/pr-85', '* master']);
|
|
59
|
-
});
|
|
60
|
-
it('should have cherry picked the correct commit', async () => {
|
|
61
|
-
const commit = await (0, helpers_1.getLatestCommit)({
|
|
62
|
-
branch: 'backport/6.0/pr-85',
|
|
63
|
-
commitCount: 1,
|
|
64
|
-
cwd: envConstants_1.REMOTE_FORK_REPO_PATH,
|
|
65
|
-
});
|
|
66
|
-
expect(commit).toMatchInlineSnapshot(`
|
|
67
|
-
" romeo-and-juliet.txt | 2 +-
|
|
68
|
-
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
69
|
-
|
|
70
|
-
diff --git a/romeo-and-juliet.txt b/romeo-and-juliet.txt
|
|
71
|
-
index 87f1ac7..51e1e4b 100644
|
|
72
|
-
--- a/romeo-and-juliet.txt
|
|
73
|
-
+++ b/romeo-and-juliet.txt
|
|
74
|
-
@@ -158 +158 @@ Thereto prick'd on by a most emulate pride,
|
|
75
|
-
-Dared to the combat; in which our valiant Hamlet--
|
|
76
|
-
+Dared to the combat; in 🧙♀️ our valiant Hamlet--
|
|
77
|
-
"
|
|
78
|
-
`);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
describe('when two commits are backported', () => {
|
|
82
|
-
let spies;
|
|
83
|
-
let res;
|
|
84
|
-
beforeEach((0, lodash_1.once)(async () => {
|
|
85
|
-
jest.clearAllMocks();
|
|
86
|
-
spies = (0, createSpies_1.createSpies)({ commitCount: 2 });
|
|
87
|
-
await (0, helpers_1.deleteAndSetupEnvironment)();
|
|
88
|
-
const options = await (0, options_1.getOptions)([], {
|
|
89
|
-
// use localhost to avoid CORS issues
|
|
90
|
-
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
91
|
-
});
|
|
92
|
-
res = await (0, runWithOptions_1.runWithOptions)(options);
|
|
93
|
-
}));
|
|
94
|
-
it('sends the correct http body when creating pull request', () => {
|
|
95
|
-
expect(spies.createPullRequestCalls).toEqual([
|
|
96
|
-
{
|
|
97
|
-
title: '[6.0] Add witch (#85) | Add 👻',
|
|
98
|
-
head: 'sqren:backport/6.0/pr-85_commit-2e63475c',
|
|
99
|
-
base: '6.0',
|
|
100
|
-
body: 'Backports the following commits to 6.0:\n - #85\n - Add 👻 (2e63475c)',
|
|
101
|
-
},
|
|
102
|
-
]);
|
|
103
|
-
});
|
|
104
|
-
it('returns pull request', () => {
|
|
105
|
-
expect(res).toEqual([
|
|
106
|
-
{ pullRequestUrl: 'myHtmlUrl', success: true, targetBranch: '6.0' },
|
|
107
|
-
]);
|
|
108
|
-
});
|
|
109
|
-
it('should make correct API requests', () => {
|
|
110
|
-
expect(spies.getGithubConfigOptionsCalls).toMatchSnapshot();
|
|
111
|
-
expect(spies.authorIdCalls).toMatchSnapshot();
|
|
112
|
-
expect(spies.commitsByAuthorCalls).toMatchSnapshot();
|
|
113
|
-
});
|
|
114
|
-
it('should not create new branches in origin (backport-org/backport-demo)', async () => {
|
|
115
|
-
const branches = await (0, helpers_1.getBranches)(envConstants_1.REMOTE_ORIGIN_REPO_PATH);
|
|
116
|
-
expect(branches).toEqual(['6.0', '* master']);
|
|
117
|
-
});
|
|
118
|
-
it('should create branch in the fork (sqren/backport-demo)', async () => {
|
|
119
|
-
const branches = await (0, helpers_1.getBranches)(envConstants_1.REMOTE_FORK_REPO_PATH);
|
|
120
|
-
expect(branches).toEqual([
|
|
121
|
-
'6.0',
|
|
122
|
-
'backport/6.0/pr-85_commit-2e63475c',
|
|
123
|
-
'* master',
|
|
124
|
-
]);
|
|
125
|
-
});
|
|
126
|
-
it('should have cherry picked the correct commit', async () => {
|
|
127
|
-
const commit = await (0, helpers_1.getLatestCommit)({
|
|
128
|
-
branch: 'backport/6.0/pr-85_commit-2e63475c',
|
|
129
|
-
commitCount: 2,
|
|
130
|
-
cwd: envConstants_1.REMOTE_FORK_REPO_PATH,
|
|
131
|
-
});
|
|
132
|
-
expect(commit).toMatchInlineSnapshot(`
|
|
133
|
-
" romeo-and-juliet.txt | 2 +-
|
|
134
|
-
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
135
|
-
|
|
136
|
-
diff --git a/romeo-and-juliet.txt b/romeo-and-juliet.txt
|
|
137
|
-
index 51e1e4b..4814bb0 100644
|
|
138
|
-
--- a/romeo-and-juliet.txt
|
|
139
|
-
+++ b/romeo-and-juliet.txt
|
|
140
|
-
@@ -203 +203 @@ But soft, behold! lo, where it comes again!
|
|
141
|
-
-Re-enter Ghost
|
|
142
|
-
+Re-enter 👻
|
|
143
|
-
romeo-and-juliet.txt | 2 +-
|
|
144
|
-
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
145
|
-
|
|
146
|
-
diff --git a/romeo-and-juliet.txt b/romeo-and-juliet.txt
|
|
147
|
-
index 87f1ac7..51e1e4b 100644
|
|
148
|
-
--- a/romeo-and-juliet.txt
|
|
149
|
-
+++ b/romeo-and-juliet.txt
|
|
150
|
-
@@ -158 +158 @@ Thereto prick'd on by a most emulate pride,
|
|
151
|
-
-Dared to the combat; in which our valiant Hamlet--
|
|
152
|
-
+Dared to the combat; in 🧙♀️ our valiant Hamlet--
|
|
153
|
-
"
|
|
154
|
-
`);
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
describe('when disabling fork mode', () => {
|
|
158
|
-
let res;
|
|
159
|
-
let spies;
|
|
160
|
-
beforeEach((0, lodash_1.once)(async () => {
|
|
161
|
-
jest.clearAllMocks();
|
|
162
|
-
spies = (0, createSpies_1.createSpies)({ commitCount: 1 });
|
|
163
|
-
await (0, helpers_1.deleteAndSetupEnvironment)();
|
|
164
|
-
const options = await (0, options_1.getOptions)(['--fork=false'], {
|
|
165
|
-
// use localhost to avoid CORS issues
|
|
166
|
-
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
167
|
-
});
|
|
168
|
-
res = await (0, runWithOptions_1.runWithOptions)(options);
|
|
169
|
-
}));
|
|
170
|
-
it('sends the correct http body when creating pull request', () => {
|
|
171
|
-
expect(spies.createPullRequestCalls).toEqual([
|
|
172
|
-
{
|
|
173
|
-
base: '6.0',
|
|
174
|
-
body: 'Backports the following commits to 6.0:\n - #85',
|
|
175
|
-
head: 'backport-org:backport/6.0/pr-85',
|
|
176
|
-
title: '[6.0] Add witch (#85)',
|
|
177
|
-
},
|
|
178
|
-
]);
|
|
179
|
-
});
|
|
180
|
-
it('returns pull request', () => {
|
|
181
|
-
expect(res).toEqual([
|
|
182
|
-
{ pullRequestUrl: 'myHtmlUrl', success: true, targetBranch: '6.0' },
|
|
183
|
-
]);
|
|
184
|
-
});
|
|
185
|
-
it('should create new branches in origin (backport-org/backport-demo)', async () => {
|
|
186
|
-
const branches = await (0, helpers_1.getBranches)(envConstants_1.REMOTE_ORIGIN_REPO_PATH);
|
|
187
|
-
expect(branches).toEqual(['6.0', 'backport/6.0/pr-85', '* master']);
|
|
188
|
-
});
|
|
189
|
-
it('should NOT create branch in the fork (sqren/backport-demo)', async () => {
|
|
190
|
-
const branches = await (0, helpers_1.getBranches)(envConstants_1.REMOTE_FORK_REPO_PATH);
|
|
191
|
-
expect(branches).toEqual(['6.0', '* master']);
|
|
192
|
-
});
|
|
193
|
-
it('should cherry pick the correct commit', async () => {
|
|
194
|
-
const commit = await (0, helpers_1.getLatestCommit)({
|
|
195
|
-
branch: 'backport/6.0/pr-85',
|
|
196
|
-
commitCount: 1,
|
|
197
|
-
cwd: envConstants_1.REMOTE_ORIGIN_REPO_PATH,
|
|
198
|
-
});
|
|
199
|
-
expect(commit).toMatchInlineSnapshot(`
|
|
200
|
-
" romeo-and-juliet.txt | 2 +-
|
|
201
|
-
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
202
|
-
|
|
203
|
-
diff --git a/romeo-and-juliet.txt b/romeo-and-juliet.txt
|
|
204
|
-
index 87f1ac7..51e1e4b 100644
|
|
205
|
-
--- a/romeo-and-juliet.txt
|
|
206
|
-
+++ b/romeo-and-juliet.txt
|
|
207
|
-
@@ -158 +158 @@ Thereto prick'd on by a most emulate pride,
|
|
208
|
-
-Dared to the combat; in which our valiant Hamlet--
|
|
209
|
-
+Dared to the combat; in 🧙♀️ our valiant Hamlet--
|
|
210
|
-
"
|
|
211
|
-
`);
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
});
|
|
@@ -1,37 +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
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.mockConfigFiles = void 0;
|
|
23
|
-
const fs = __importStar(require("../services/fs-promisified"));
|
|
24
|
-
function mockConfigFiles({ projectConfig, globalConfig, }) {
|
|
25
|
-
jest
|
|
26
|
-
.spyOn(fs, 'readFile')
|
|
27
|
-
//@ts-expect-error
|
|
28
|
-
.mockImplementation(async (filepath) => {
|
|
29
|
-
if (filepath === '/path/to/project/config') {
|
|
30
|
-
return JSON.stringify(projectConfig);
|
|
31
|
-
}
|
|
32
|
-
if (filepath.endsWith('.backport/config.json')) {
|
|
33
|
-
return JSON.stringify(globalConfig);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
exports.mockConfigFiles = mockConfigFiles;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import nock from 'nock';
|
|
2
|
-
export declare function mockGqlRequest<T>({ name, statusCode, body, headers, apiBaseUrl, }: {
|
|
3
|
-
name: string;
|
|
4
|
-
statusCode: number;
|
|
5
|
-
body?: {
|
|
6
|
-
data: T;
|
|
7
|
-
} | {
|
|
8
|
-
errors: any[];
|
|
9
|
-
};
|
|
10
|
-
headers?: any;
|
|
11
|
-
apiBaseUrl?: string;
|
|
12
|
-
}): {
|
|
13
|
-
query: string;
|
|
14
|
-
variables: string;
|
|
15
|
-
}[];
|
|
16
|
-
export declare function listenForCallsToNockScope(scope: nock.Scope): unknown[];
|
package/dist/test/nockHelpers.js
DELETED
|
@@ -1,32 +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.listenForCallsToNockScope = exports.mockGqlRequest = void 0;
|
|
7
|
-
const url_1 = require("url");
|
|
8
|
-
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
9
|
-
const nock_1 = __importDefault(require("nock"));
|
|
10
|
-
function mockGqlRequest({ name, statusCode, body, headers, apiBaseUrl, }) {
|
|
11
|
-
const { origin, pathname } = new url_1.URL(
|
|
12
|
-
// default to localhost as host to avoid CORS issues
|
|
13
|
-
apiBaseUrl ?? 'http://localhost/graphql');
|
|
14
|
-
const scope = (0, nock_1.default)(origin)
|
|
15
|
-
.post(pathname, (body) => getGqlName(body.query) === name)
|
|
16
|
-
.reply(statusCode, body, headers);
|
|
17
|
-
return listenForCallsToNockScope(scope);
|
|
18
|
-
}
|
|
19
|
-
exports.mockGqlRequest = mockGqlRequest;
|
|
20
|
-
function getGqlName(query) {
|
|
21
|
-
const obj = (0, graphql_tag_1.default)(query);
|
|
22
|
-
// @ts-expect-error
|
|
23
|
-
return obj.definitions[0].name.value;
|
|
24
|
-
}
|
|
25
|
-
function listenForCallsToNockScope(scope) {
|
|
26
|
-
const calls = [];
|
|
27
|
-
scope.on('request', (req, interceptor, body) => {
|
|
28
|
-
calls.push(JSON.parse(body));
|
|
29
|
-
});
|
|
30
|
-
return calls;
|
|
31
|
-
}
|
|
32
|
-
exports.listenForCallsToNockScope = listenForCallsToNockScope;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getDevAccessToken(): Promise<string>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDevAccessToken = void 0;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
// get global config: either from .backport/config.json or via env variables
|
|
6
|
-
async function getDevAccessToken() {
|
|
7
|
-
const accessToken = process.env.accessToken;
|
|
8
|
-
// get accessToken from env vars
|
|
9
|
-
if (accessToken) {
|
|
10
|
-
return accessToken;
|
|
11
|
-
}
|
|
12
|
-
// get credentials from config file
|
|
13
|
-
const accessTokenFile = './src/test/private/accessToken.txt';
|
|
14
|
-
try {
|
|
15
|
-
const accessToken = await fs_1.promises.readFile(accessTokenFile, {
|
|
16
|
-
encoding: 'utf-8',
|
|
17
|
-
});
|
|
18
|
-
return accessToken.trim();
|
|
19
|
-
}
|
|
20
|
-
catch (e) {
|
|
21
|
-
throw new Error(`Missing accessToken in "${accessTokenFile}"`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.getDevAccessToken = getDevAccessToken;
|
|
File without changes
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* This file is included in `setupFiles` in jest.config.js
|
|
4
|
-
* It will be run once per test file
|
|
5
|
-
*/
|
|
6
|
-
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
7
|
-
jest.mock('find-up', () => {
|
|
8
|
-
return jest.fn(async () => '/path/to/project/config');
|
|
9
|
-
});
|
|
10
|
-
jest.mock('make-dir', () => {
|
|
11
|
-
return jest.fn(() => Promise.resolve('/some/path'));
|
|
12
|
-
});
|
|
13
|
-
jest.mock('del', () => {
|
|
14
|
-
return jest.fn(async (path) => `Attempted to delete ${path}`);
|
|
15
|
-
});
|
|
16
|
-
jest.mock('ora', () => {
|
|
17
|
-
const ora = {
|
|
18
|
-
start: () => ({
|
|
19
|
-
succeed: () => { },
|
|
20
|
-
stop: () => { },
|
|
21
|
-
fail: () => { },
|
|
22
|
-
stopAndPersist: () => { },
|
|
23
|
-
}),
|
|
24
|
-
};
|
|
25
|
-
return jest.fn(() => ora);
|
|
26
|
-
});
|
|
27
|
-
// silence logger
|
|
28
|
-
jest.mock('../../services/logger', () => {
|
|
29
|
-
const spy = jest.fn();
|
|
30
|
-
return {
|
|
31
|
-
initLogger: jest.fn(),
|
|
32
|
-
redactAccessToken: jest.fn((str) => str),
|
|
33
|
-
consoleLog: jest.fn(),
|
|
34
|
-
updateLogger: jest.fn(),
|
|
35
|
-
logger: {
|
|
36
|
-
spy: spy,
|
|
37
|
-
info: (msg, meta) => spy(`[INFO] ${msg}`, meta),
|
|
38
|
-
verbose: (msg, meta) => spy(`[VERBOSE] ${msg}`, meta),
|
|
39
|
-
warn: (msg, meta) => spy(`[WARN] ${msg}`, meta),
|
|
40
|
-
debug: (msg, meta) => spy(`[DEBUG] ${msg}`, meta),
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
});
|
package/dist/types/Commit.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { ValidConfigOptions } from '../options/options';
|
|
2
|
-
export interface Commit {
|
|
3
|
-
committedDate: string;
|
|
4
|
-
sourceBranch: string;
|
|
5
|
-
targetBranchesFromLabels: string[];
|
|
6
|
-
sha: string;
|
|
7
|
-
formattedMessage: string;
|
|
8
|
-
originalMessage: string;
|
|
9
|
-
pullNumber?: number;
|
|
10
|
-
existingTargetPullRequests: ExistingTargetPullRequests;
|
|
11
|
-
}
|
|
12
|
-
export interface PullRequestNode {
|
|
13
|
-
baseRefName: string;
|
|
14
|
-
number: number;
|
|
15
|
-
mergeCommit: {
|
|
16
|
-
committedDate: string;
|
|
17
|
-
oid: string;
|
|
18
|
-
message: string;
|
|
19
|
-
} | null;
|
|
20
|
-
labels: {
|
|
21
|
-
nodes: {
|
|
22
|
-
name: string;
|
|
23
|
-
}[];
|
|
24
|
-
};
|
|
25
|
-
repository: {
|
|
26
|
-
owner: {
|
|
27
|
-
login: string;
|
|
28
|
-
};
|
|
29
|
-
name: string;
|
|
30
|
-
};
|
|
31
|
-
timelineItems: {
|
|
32
|
-
edges: Array<TimelineEdge>;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
declare type TimelineEdge = TimelinePullRequestEdge | TimelineIssueEdge;
|
|
36
|
-
interface TimelinePullRequestEdge {
|
|
37
|
-
node: {
|
|
38
|
-
source: {
|
|
39
|
-
__typename: 'PullRequest';
|
|
40
|
-
title: string;
|
|
41
|
-
state: 'OPEN' | 'CLOSED' | 'MERGED';
|
|
42
|
-
baseRefName: string;
|
|
43
|
-
number: number;
|
|
44
|
-
commits: {
|
|
45
|
-
edges: CommitEdge[];
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
interface TimelineIssueEdge {
|
|
51
|
-
node: {
|
|
52
|
-
source: {
|
|
53
|
-
__typename: 'Issue';
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
interface CommitEdge {
|
|
58
|
-
node: {
|
|
59
|
-
commit: {
|
|
60
|
-
message: string;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
export declare type CommitNode = {
|
|
65
|
-
oid: string;
|
|
66
|
-
message: string;
|
|
67
|
-
committedDate: string;
|
|
68
|
-
associatedPullRequests: {
|
|
69
|
-
edges: {
|
|
70
|
-
node: PullRequestNode;
|
|
71
|
-
}[] | null;
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
export declare function getCommit(options: ValidConfigOptions, commitNode: CommitNode): Commit;
|
|
75
|
-
export declare const commitNodeFragment: {
|
|
76
|
-
name: string;
|
|
77
|
-
source: string;
|
|
78
|
-
};
|
|
79
|
-
export declare type ExistingTargetPullRequests = ReturnType<typeof getExistingTargetPullRequests>;
|
|
80
|
-
export declare function getExistingTargetPullRequests(sourcePullRequest?: PullRequestNode): {
|
|
81
|
-
number: number;
|
|
82
|
-
branch: string;
|
|
83
|
-
state: "OPEN" | "CLOSED" | "MERGED";
|
|
84
|
-
}[];
|
|
85
|
-
export {};
|
package/dist/types/Commit.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getExistingTargetPullRequests = exports.commitNodeFragment = exports.getCommit = void 0;
|
|
4
|
-
const commitFormatters_1 = require("../services/github/commitFormatters");
|
|
5
|
-
const getTargetBranchesFromLabels_1 = require("../services/github/v4/getTargetBranchesFromLabels");
|
|
6
|
-
const filterEmpty_1 = require("../utils/filterEmpty");
|
|
7
|
-
function getPullRequestLabels(pullRequestNode) {
|
|
8
|
-
return pullRequestNode?.labels.nodes.map((label) => label.name);
|
|
9
|
-
}
|
|
10
|
-
function getCommit(options, commitNode) {
|
|
11
|
-
const pullRequestNode = commitNode.associatedPullRequests.edges?.[0]?.node;
|
|
12
|
-
const commitMessage = commitNode.message;
|
|
13
|
-
const sha = commitNode.oid;
|
|
14
|
-
const pullNumber = pullRequestNode?.number ?? (0, commitFormatters_1.getPullNumberFromMessage)(commitMessage);
|
|
15
|
-
const existingTargetPullRequests = getExistingTargetPullRequests(pullRequestNode);
|
|
16
|
-
const targetBranchesFromLabels = pullRequestNode
|
|
17
|
-
? (0, getTargetBranchesFromLabels_1.getTargetBranchesFromLabels)({
|
|
18
|
-
sourceBranch: pullRequestNode.baseRefName,
|
|
19
|
-
existingTargetPullRequests,
|
|
20
|
-
branchLabelMapping: options.branchLabelMapping,
|
|
21
|
-
labels: getPullRequestLabels(pullRequestNode),
|
|
22
|
-
})
|
|
23
|
-
: [];
|
|
24
|
-
const formattedMessage = (0, commitFormatters_1.getFormattedCommitMessage)({
|
|
25
|
-
message: commitMessage,
|
|
26
|
-
pullNumber,
|
|
27
|
-
sha,
|
|
28
|
-
});
|
|
29
|
-
return {
|
|
30
|
-
committedDate: commitNode.committedDate,
|
|
31
|
-
sourceBranch: options.sourceBranch,
|
|
32
|
-
targetBranchesFromLabels,
|
|
33
|
-
sha: commitNode.oid,
|
|
34
|
-
formattedMessage,
|
|
35
|
-
originalMessage: commitMessage,
|
|
36
|
-
pullNumber,
|
|
37
|
-
existingTargetPullRequests,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
exports.getCommit = getCommit;
|
|
41
|
-
exports.commitNodeFragment = {
|
|
42
|
-
name: 'CommitNode',
|
|
43
|
-
source: /* GraphQL */ `
|
|
44
|
-
fragment CommitNode on Commit {
|
|
45
|
-
oid
|
|
46
|
-
message
|
|
47
|
-
associatedPullRequests(first: 1) {
|
|
48
|
-
edges {
|
|
49
|
-
node {
|
|
50
|
-
# Source PR
|
|
51
|
-
number
|
|
52
|
-
repository {
|
|
53
|
-
name
|
|
54
|
-
owner {
|
|
55
|
-
login
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
mergeCommit {
|
|
59
|
-
committedDate
|
|
60
|
-
oid
|
|
61
|
-
message
|
|
62
|
-
}
|
|
63
|
-
labels(first: 50) {
|
|
64
|
-
nodes {
|
|
65
|
-
name
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
baseRefName
|
|
69
|
-
timelineItems(last: 20, itemTypes: CROSS_REFERENCED_EVENT) {
|
|
70
|
-
edges {
|
|
71
|
-
node {
|
|
72
|
-
... on CrossReferencedEvent {
|
|
73
|
-
source {
|
|
74
|
-
__typename
|
|
75
|
-
|
|
76
|
-
# Target PRs
|
|
77
|
-
... on PullRequest {
|
|
78
|
-
title
|
|
79
|
-
state
|
|
80
|
-
baseRefName
|
|
81
|
-
number
|
|
82
|
-
commits(first: 20) {
|
|
83
|
-
edges {
|
|
84
|
-
node {
|
|
85
|
-
commit {
|
|
86
|
-
message
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
`,
|
|
102
|
-
};
|
|
103
|
-
function getExistingTargetPullRequests(sourcePullRequest) {
|
|
104
|
-
if (!sourcePullRequest || !sourcePullRequest.mergeCommit) {
|
|
105
|
-
return [];
|
|
106
|
-
}
|
|
107
|
-
const sourcePRMergeCommitMessage = (0, commitFormatters_1.getFirstCommitMessageLine)(sourcePullRequest.mergeCommit.message);
|
|
108
|
-
return sourcePullRequest.timelineItems.edges
|
|
109
|
-
.filter(filterEmpty_1.filterNil)
|
|
110
|
-
.filter(filterPullRequests)
|
|
111
|
-
.filter((item) => {
|
|
112
|
-
const { source } = item.node;
|
|
113
|
-
if (source.state !== 'MERGED' && source.state !== 'OPEN') {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
// at least one of the commits in the target pull request should match the merge commit from the source pull request
|
|
117
|
-
const commitMatch = source.commits.edges.some((commit) => {
|
|
118
|
-
const targetPRCommitMessage = (0, commitFormatters_1.getFirstCommitMessageLine)(commit.node.commit.message);
|
|
119
|
-
return targetPRCommitMessage === sourcePRMergeCommitMessage;
|
|
120
|
-
});
|
|
121
|
-
const prTitleMatch = source.title.includes(sourcePRMergeCommitMessage);
|
|
122
|
-
const prNumberMatch = source.title.includes(sourcePullRequest.number.toString());
|
|
123
|
-
return commitMatch || (prTitleMatch && prNumberMatch);
|
|
124
|
-
})
|
|
125
|
-
.map((item) => {
|
|
126
|
-
const { source } = item.node;
|
|
127
|
-
return {
|
|
128
|
-
number: source.number,
|
|
129
|
-
branch: source.baseRefName,
|
|
130
|
-
state: source.state,
|
|
131
|
-
};
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
exports.getExistingTargetPullRequests = getExistingTargetPullRequests;
|
|
135
|
-
// narrow TimelineEdge to TimelinePullRequestEdge
|
|
136
|
-
function filterPullRequests(item) {
|
|
137
|
-
const { source } = item.node;
|
|
138
|
-
return source.__typename === 'PullRequest';
|
|
139
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare type PromiseReturnType<Func> = Func extends (...args: any[]) => Promise<infer Value> ? Value : Func;
|