backport 5.6.5 → 6.1.1
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 +166 -41
- package/dist/entrypoint.cli.js +3 -1
- package/dist/entrypoint.module.d.ts +18 -5
- package/dist/entrypoint.module.js +42 -12
- package/dist/entrypoint.module.private.test.d.ts +1 -0
- package/dist/entrypoint.module.private.test.js +34 -0
- package/dist/ink.d.ts +1 -0
- package/dist/ink.js +49 -0
- package/dist/main.d.ts +11 -6
- package/dist/main.js +40 -25
- package/dist/options/ConfigOptions.d.ts +28 -12
- package/dist/options/cliArgs.d.ts +36 -35
- package/dist/options/cliArgs.js +91 -52
- package/dist/options/cliArgs.test.js +41 -42
- package/dist/options/config/config.d.ts +34 -57
- package/dist/options/config/config.js +5 -39
- package/dist/options/config/config.test.js +11 -25
- package/dist/options/config/getOptionsFromGit.d.ts +3 -2
- package/dist/options/config/getOptionsFromGit.js +1 -3
- package/dist/options/config/globalConfig.d.ts +2 -49
- package/dist/options/config/globalConfig.js +9 -12
- package/dist/options/config/globalConfig.test.js +7 -5
- package/dist/options/config/projectConfig.d.ts +2 -49
- package/dist/options/config/projectConfig.js +2 -2
- package/dist/options/config/projectConfig.test.js +53 -16
- package/dist/options/config/readConfigFile.d.ts +43 -39
- package/dist/options/config/readConfigFile.js +30 -4
- package/dist/options/options.d.ts +57 -31
- package/dist/options/options.js +102 -10
- package/dist/options/options.test.js +263 -61
- package/dist/options/parseRequiredOptions.d.ts +19 -14
- package/dist/options/parseRequiredOptions.js +9 -15
- package/dist/options/parseRequiredOptions.test.js +30 -26
- package/dist/runSequentially.d.ts +20 -0
- package/dist/runSequentially.js +41 -0
- package/dist/runSequentially.test.d.ts +1 -0
- package/dist/runSequentially.test.js +196 -0
- package/dist/runWithOptions.js +7 -14
- package/dist/runWithOptions.test.js +140 -17
- package/dist/scripts/generate-gql.d.ts +1 -0
- package/dist/scripts/generate-gql.js +15 -0
- package/dist/scripts/postinstall.js +4 -4
- package/dist/scripts/postinstall.test.js +9 -2
- package/dist/scripts/runPostinstall.js +1 -1
- package/dist/services/HandledError.d.ts +11 -1
- package/dist/services/HandledError.js +2 -1
- package/dist/services/child-process-promisified.d.ts +1 -1
- package/dist/services/child-process-promisified.js +1 -1
- package/dist/services/env.js +5 -5
- package/dist/services/env.test.js +11 -4
- package/dist/services/fs-promisified.js +4 -4
- package/dist/services/getExpectedTarget.d.ts +9 -0
- package/dist/services/getExpectedTarget.js +77 -0
- package/dist/services/getExpectedTargetPullRequests.d.ts +9 -0
- package/dist/services/getExpectedTargetPullRequests.js +77 -0
- package/dist/services/git.d.ts +20 -6
- package/dist/services/git.integration.test.d.ts +1 -0
- package/dist/services/git.integration.test.js +168 -0
- package/dist/services/git.js +93 -67
- package/dist/services/git.test.js +68 -68
- package/dist/services/github/commitFormatters.d.ts +3 -7
- package/dist/services/github/commitFormatters.js +10 -19
- package/dist/services/github/commitFormatters.test.js +2 -24
- package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.js +3 -8
- package/dist/services/github/v3/addAssigneesToPullRequest.test.js +6 -8
- package/dist/services/github/v3/addLabelsToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addLabelsToPullRequest.js +2 -6
- package/dist/services/github/v3/addReviewersToPullRequest.d.ts +2 -0
- package/dist/services/github/v3/addReviewersToPullRequest.js +34 -0
- package/dist/services/github/v3/createPullRequest.d.ts +3 -2
- package/dist/services/github/v3/createPullRequest.js +31 -29
- package/dist/services/github/v3/createPullRequest.test.d.ts +1 -0
- package/dist/services/github/v3/createPullRequest.test.js +110 -0
- package/dist/services/github/v3/createStatusComment.d.ts +11 -0
- package/dist/services/github/v3/createStatusComment.js +97 -0
- package/dist/services/github/v3/createStatusComment.test.d.ts +1 -0
- package/dist/services/github/v3/createStatusComment.test.js +209 -0
- package/dist/services/github/v4/FetchPullRequestId.d.ts +9 -0
- package/dist/services/github/v4/FetchPullRequestId.js +32 -0
- package/dist/services/github/v4/apiRequestV4.d.ts +2 -2
- package/dist/services/github/v4/apiRequestV4.js +8 -10
- package/dist/services/github/v4/apiRequestV4.test.js +7 -7
- package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +1 -8
- package/dist/services/github/v4/disablePullRequestAutoMerge.js +6 -32
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +1 -8
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +31 -40
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +112 -0
- package/dist/services/github/v4/fetchAuthorId.d.ts +5 -2
- package/dist/services/github/v4/fetchAuthorId.js +6 -7
- package/dist/services/github/v4/fetchAuthorId.private.test.js +6 -9
- package/dist/services/github/v4/fetchCommitByPullNumber.js +11 -9
- package/dist/services/github/v4/fetchCommitByPullNumber.private.test.js +4 -4
- package/dist/services/github/v4/fetchCommitBySha.js +14 -12
- package/dist/services/github/v4/fetchCommitBySha.private.test.js +4 -4
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +12 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +46 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +70 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +12 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +36 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +55 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +27 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +88 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +128 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +125 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.d.ts +28 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.js +52 -0
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.d.ts +3 -0
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.js +55 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +10 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +49 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +77 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.js +252 -0
- package/dist/services/github/v4/fetchCommitsByAuthor.d.ts +2 -1
- package/dist/services/github/v4/fetchCommitsByAuthor.js +81 -70
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.js +78 -5
- package/dist/services/github/v4/fetchCommitsByAuthor.test.js +29 -21
- package/dist/services/github/v4/fetchDefaultBranch.js +1 -1
- package/dist/services/github/v4/fetchExistingPullRequest.js +2 -3
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +3 -5
- package/dist/services/github/v4/fetchMergedPullRequests.d.ts +18 -19
- package/dist/services/github/v4/fetchMergedPullRequests.js +22 -69
- package/dist/services/github/v4/fetchMergedPullRequests.private.test.js +8 -9
- package/dist/services/github/v4/fetchProjectConfig.d.ts +8 -0
- package/dist/services/github/v4/fetchProjectConfig.js +56 -0
- package/dist/services/github/v4/fetchProjectConfig.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchProjectConfig.private.test.js +52 -0
- package/dist/services/github/v4/fetchProjectConfig.test.d.ts +1 -0
- package/dist/services/github/v4/fetchProjectConfig.test.js +37 -0
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +11 -0
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +35 -0
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.js +12 -10
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.js +3 -3
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.js +2 -2
- package/dist/services/github/v4/getExistingTargetPullRequests.d.ts +4 -58
- package/dist/services/github/v4/getExistingTargetPullRequests.js +3 -58
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +66 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +130 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +130 -0
- package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +19 -9
- package/dist/services/github/v4/getOptionsFromGithub/index.js +59 -19
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +119 -32
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +16 -16
- package/dist/services/github/v4/getOptionsFromGithub/query.js +16 -15
- package/dist/services/github/v4/getTargetBranchesFromLabels.d.ts +0 -7
- package/dist/services/github/v4/getTargetBranchesFromLabels.js +1 -26
- package/dist/services/github/v4/getTargetBranchesFromLabels.test.js +69 -32
- package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +2 -2
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +39 -25
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.d.ts +1 -1
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.js +10 -0
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.d.ts +1 -1
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.js +2 -0
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.d.ts +1 -1
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.js +1 -0
- package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +1 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -15
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +7 -7
- package/dist/services/logger.d.ts +3 -3
- package/dist/services/logger.js +16 -15
- package/dist/services/prompt.test.d.ts +1 -0
- package/dist/services/prompt.test.js +87 -0
- package/dist/services/prompts.d.ts +10 -4
- package/dist/services/prompts.js +85 -22
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +9 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +92 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +413 -0
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +21 -0
- package/dist/services/sourceCommit/getMockSourceCommit.js +67 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.d.ts +5 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.js +20 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.d.ts +1 -0
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.js +201 -0
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +82 -0
- package/dist/services/sourceCommit/parseSourceCommit.js +96 -0
- package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +1 -0
- package/dist/services/sourceCommit/parseSourceCommit.test.js +229 -0
- package/dist/services/sourceCommit/sourceCommit.d.ts +78 -0
- package/dist/services/sourceCommit/sourceCommit.js +86 -0
- package/dist/services/sourceCommit/sourceCommit.test.d.ts +1 -0
- package/dist/services/sourceCommit/sourceCommit.test.js +287 -0
- package/dist/services/sourceCommit.d.ts +78 -0
- package/dist/services/sourceCommit.js +86 -0
- package/dist/services/sourceCommit.test.d.ts +1 -0
- package/dist/services/sourceCommit.test.js +280 -0
- package/dist/test/inquirer.private.test.js +64 -49
- package/dist/test/integration/createSpies.js +6 -6
- package/dist/test/integration/envConstants.js +5 -6
- package/dist/test/integration/helpers.js +1 -1
- package/dist/test/integration/integration.private.test.d.ts +1 -0
- package/dist/test/integration/integration.private.test.js +327 -0
- package/dist/test/integration/integration.test.js +28 -29
- package/dist/test/mockConfigFiles.d.ts +5 -0
- package/dist/test/mockConfigFiles.js +37 -0
- package/dist/test/nockHelpers.d.ts +1 -1
- package/dist/test/nockHelpers.js +7 -11
- package/dist/test/private/getDevAccessToken.js +1 -1
- package/dist/test/setupFiles/automatic-mocks.d.ts +0 -1
- package/dist/test/setupFiles/automatic-mocks.js +1 -51
- package/dist/types/Commit.d.ts +85 -0
- package/dist/types/Commit.js +139 -0
- package/dist/types/commitNode.d.ts +89 -0
- package/dist/types/commitNode.js +139 -0
- package/dist/types/commitNode.test.d.ts +1 -0
- package/dist/types/commitNode.test.js +255 -0
- package/dist/types/commitWithAssociatedPullRequests.d.ts +86 -0
- package/dist/types/commitWithAssociatedPullRequests.js +145 -0
- package/dist/ui/cherrypickAndCreatePullRequest.test.js +346 -76
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +11 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +138 -67
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +468 -0
- package/dist/ui/getCommits.d.ts +1 -1
- package/dist/ui/getCommits.js +55 -25
- package/dist/ui/getTargetBranches.d.ts +3 -2
- package/dist/ui/getTargetBranches.js +33 -18
- package/dist/ui/getTargetBranches.test.js +75 -99
- package/dist/ui/getTargetBranchesFromLabels.d.ts +6 -0
- package/dist/ui/getTargetBranchesFromLabels.js +40 -0
- package/dist/ui/getTargetBranchesFromLabels.test.d.ts +1 -0
- package/dist/ui/getTargetBranchesFromLabels.test.js +288 -0
- package/dist/ui/maybeSetupRepo.js +11 -10
- package/dist/ui/maybeSetupRepo.test.js +54 -4
- package/dist/utils/excludeUndefined.d.ts +6 -0
- package/dist/utils/excludeUndefined.js +7 -0
- package/dist/utils/excludeUndefined.test.d.ts +1 -0
- package/dist/utils/excludeUndefined.test.js +24 -0
- package/package.json +37 -51
- package/yarn.lock +2414 -2993
|
@@ -19,7 +19,7 @@ function createSpies({ commitCount }) {
|
|
|
19
19
|
mockExec();
|
|
20
20
|
// mock inquirer.prompt
|
|
21
21
|
mockInquirerPrompts(commitCount);
|
|
22
|
-
const getGithubConfigOptionsCalls = nockHelpers_1.mockGqlRequest({
|
|
22
|
+
const getGithubConfigOptionsCalls = (0, nockHelpers_1.mockGqlRequest)({
|
|
23
23
|
name: 'GithubConfigOptions',
|
|
24
24
|
statusCode: 200,
|
|
25
25
|
body: {
|
|
@@ -36,15 +36,15 @@ function createSpies({ commitCount }) {
|
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
38
|
});
|
|
39
|
-
const authorIdCalls = nockHelpers_1.mockGqlRequest({
|
|
39
|
+
const authorIdCalls = (0, nockHelpers_1.mockGqlRequest)({
|
|
40
40
|
name: 'AuthorId',
|
|
41
41
|
statusCode: 200,
|
|
42
42
|
body: { data: { user: { id: 'sqren_author_id' } } },
|
|
43
43
|
});
|
|
44
|
-
const commitsByAuthorCalls = nockHelpers_1.mockGqlRequest({
|
|
44
|
+
const commitsByAuthorCalls = (0, nockHelpers_1.mockGqlRequest)({
|
|
45
45
|
name: 'CommitsByAuthor',
|
|
46
46
|
statusCode: 200,
|
|
47
|
-
body: { data: commitsByAuthorMock_1.
|
|
47
|
+
body: { data: commitsByAuthorMock_1.commitsByAuthorMock },
|
|
48
48
|
});
|
|
49
49
|
const createPullRequestCalls = mockCreatePullRequest();
|
|
50
50
|
return {
|
|
@@ -78,8 +78,8 @@ function mockInquirerPrompts(commitCount) {
|
|
|
78
78
|
}));
|
|
79
79
|
}
|
|
80
80
|
function mockCreatePullRequest() {
|
|
81
|
-
const scope = nock_1.default('https://api.github.com')
|
|
81
|
+
const scope = (0, nock_1.default)('https://api.github.com')
|
|
82
82
|
.post('/repos/backport-org/backport-demo/pulls')
|
|
83
83
|
.reply(200, { number: 1337, html_url: 'myHtmlUrl' });
|
|
84
|
-
return nockHelpers_1.getNockCallsForScope(scope);
|
|
84
|
+
return (0, nockHelpers_1.getNockCallsForScope)(scope);
|
|
85
85
|
}
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.REMOTE_FORK_REPO_PATH = exports.REMOTE_ORIGIN_REPO_PATH = exports.HOMEDIR_PATH = exports.INTEGRATION_TEST_DATA_PATH = exports.INTEGRATION_TEST_DIR_PATH = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
-
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.REMOTE_FORK_REPO_PATH = path_1.resolve('./src/test/integration/mock-environment/github.com/sqren/backport-demo/.git');
|
|
5
|
+
exports.INTEGRATION_TEST_DIR_PATH = (0, path_1.resolve)('./src/test/integration');
|
|
6
|
+
exports.INTEGRATION_TEST_DATA_PATH = (0, path_1.resolve)('./src/test/integration/mock-environment');
|
|
7
|
+
exports.HOMEDIR_PATH = (0, path_1.resolve)('./src/test/integration/mock-environment/homedir');
|
|
8
|
+
exports.REMOTE_ORIGIN_REPO_PATH = (0, path_1.resolve)('./src/test/integration/mock-environment/github.com/backport-org/backport-demo/.git');
|
|
9
|
+
exports.REMOTE_FORK_REPO_PATH = (0, path_1.resolve)('./src/test/integration/mock-environment/github.com/sqren/backport-demo/.git');
|
|
@@ -6,7 +6,7 @@ const util_1 = require("util");
|
|
|
6
6
|
const del = require("del");
|
|
7
7
|
const envConstants_1 = require("./envConstants");
|
|
8
8
|
const unmockedExec = childProcess.exec;
|
|
9
|
-
const execPromisified = util_1.promisify(unmockedExec);
|
|
9
|
+
const execPromisified = (0, util_1.promisify)(unmockedExec);
|
|
10
10
|
async function getBranches(cwd) {
|
|
11
11
|
const { stdout } = await execPromisified('git --no-pager branch', { cwd });
|
|
12
12
|
return stdout
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,327 @@
|
|
|
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
|
+
/* eslint-disable jest/no-commented-out-tests */
|
|
7
|
+
const os_1 = __importDefault(require("os"));
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const rest_1 = require("@octokit/rest");
|
|
10
|
+
const del = require("del");
|
|
11
|
+
const nock_1 = __importDefault(require("nock"));
|
|
12
|
+
const options_1 = require("../../options/options");
|
|
13
|
+
const runSequentially_1 = require("../../runSequentially");
|
|
14
|
+
const getCommits_1 = require("../../ui/getCommits");
|
|
15
|
+
const mockConfigFiles_1 = require("../mockConfigFiles");
|
|
16
|
+
const nockHelpers_1 = require("../nockHelpers");
|
|
17
|
+
const getDevAccessToken_1 = require("../private/getDevAccessToken");
|
|
18
|
+
jest.unmock('make-dir');
|
|
19
|
+
jest.unmock('del');
|
|
20
|
+
jest.setTimeout(10000);
|
|
21
|
+
const INTEGRATION_TEST_DATA_PATH = (0, path_1.resolve)('./src/test/integration/mock-environment');
|
|
22
|
+
const HOMEDIR_PATH = (0, path_1.resolve)('./src/test/integration/mock-environment/homedir');
|
|
23
|
+
const REPO_OWNER = 'backport-org';
|
|
24
|
+
const REPO_NAME = 'integration-test';
|
|
25
|
+
const BRANCH_NAME = 'backport/7.x/commit-5bf29b7d';
|
|
26
|
+
const AUHTOR = 'sqren';
|
|
27
|
+
describe('integration', () => {
|
|
28
|
+
afterAll(() => {
|
|
29
|
+
nock_1.default.cleanAll();
|
|
30
|
+
});
|
|
31
|
+
beforeAll(() => {
|
|
32
|
+
// set alternative homedir
|
|
33
|
+
jest.spyOn(os_1.default, 'homedir').mockReturnValue(HOMEDIR_PATH);
|
|
34
|
+
(0, mockConfigFiles_1.mockConfigFiles)({
|
|
35
|
+
globalConfig: {},
|
|
36
|
+
projectConfig: {},
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
describe('when a single commit is backported', () => {
|
|
40
|
+
let res;
|
|
41
|
+
let accessToken;
|
|
42
|
+
let createPullRequestsMockCalls;
|
|
43
|
+
beforeAll(async () => {
|
|
44
|
+
accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
45
|
+
await resetState(accessToken);
|
|
46
|
+
createPullRequestsMockCalls = mockCreatePullRequest({
|
|
47
|
+
number: 1337,
|
|
48
|
+
html_url: 'myHtmlUrl',
|
|
49
|
+
});
|
|
50
|
+
const options = await (0, options_1.getOptions)([], {
|
|
51
|
+
githubApiBaseUrlV3: 'https://api.foo.com',
|
|
52
|
+
ci: true,
|
|
53
|
+
sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
54
|
+
author: AUHTOR,
|
|
55
|
+
accessToken,
|
|
56
|
+
repoOwner: 'backport-org',
|
|
57
|
+
repoName: 'integration-test',
|
|
58
|
+
});
|
|
59
|
+
const commits = await (0, getCommits_1.getCommits)(options);
|
|
60
|
+
const targetBranches = ['7.x'];
|
|
61
|
+
res = await (0, runSequentially_1.runSequentially)({ options, commits, targetBranches });
|
|
62
|
+
});
|
|
63
|
+
it('returns pull request', () => {
|
|
64
|
+
expect(res).toEqual([
|
|
65
|
+
{
|
|
66
|
+
didUpdate: false,
|
|
67
|
+
pullRequestUrl: 'myHtmlUrl',
|
|
68
|
+
pullRequestNumber: 1337,
|
|
69
|
+
status: 'success',
|
|
70
|
+
targetBranch: '7.x',
|
|
71
|
+
},
|
|
72
|
+
]);
|
|
73
|
+
});
|
|
74
|
+
it('sends the correct http body when creating pull request', () => {
|
|
75
|
+
expect(createPullRequestsMockCalls).toMatchInlineSnapshot(`
|
|
76
|
+
Array [
|
|
77
|
+
Object {
|
|
78
|
+
"base": "7.x",
|
|
79
|
+
"body": "# Backport
|
|
80
|
+
|
|
81
|
+
This is an automatic backport to 7.x of:
|
|
82
|
+
- Add ❤️ emoji (5bf29b7d)
|
|
83
|
+
|
|
84
|
+
### Questions ?
|
|
85
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
86
|
+
",
|
|
87
|
+
"head": "sqren:backport/7.x/commit-5bf29b7d",
|
|
88
|
+
"title": "[7.x] Add ❤️ emoji",
|
|
89
|
+
},
|
|
90
|
+
]
|
|
91
|
+
`);
|
|
92
|
+
});
|
|
93
|
+
it('should not create new branches in origin (backport-org/integration-test)', async () => {
|
|
94
|
+
const branches = await getBranches({
|
|
95
|
+
accessToken,
|
|
96
|
+
repoOwner: REPO_OWNER,
|
|
97
|
+
repoName: REPO_NAME,
|
|
98
|
+
});
|
|
99
|
+
expect(branches.map((b) => b.name)).toEqual(['7.x', 'master']);
|
|
100
|
+
});
|
|
101
|
+
it('should create branch in the fork (sqren/integration-test)', async () => {
|
|
102
|
+
const branches = await getBranches({
|
|
103
|
+
accessToken,
|
|
104
|
+
repoOwner: AUHTOR,
|
|
105
|
+
repoName: REPO_NAME,
|
|
106
|
+
});
|
|
107
|
+
expect(branches.map((b) => b.name)).toEqual([
|
|
108
|
+
'7.x',
|
|
109
|
+
BRANCH_NAME,
|
|
110
|
+
'master',
|
|
111
|
+
]);
|
|
112
|
+
});
|
|
113
|
+
it('should have cherry picked the correct commit', async () => {
|
|
114
|
+
const branches = await getBranches({
|
|
115
|
+
accessToken,
|
|
116
|
+
repoOwner: AUHTOR,
|
|
117
|
+
repoName: REPO_NAME,
|
|
118
|
+
});
|
|
119
|
+
const sha = branches.find((branch) => branch.name === '7.x')?.commit.sha;
|
|
120
|
+
expect(sha).toEqual('b68e4fcaaf4427fe1e902c718b3bb3f07b560fb5');
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
// describe.skip('when two commits are backported', () => {
|
|
124
|
+
// let createPullRequestsMockCalls: unknown[];
|
|
125
|
+
// let res: Awaited<ReturnType<typeof runSequentially>>;
|
|
126
|
+
// let accessToken: string;
|
|
127
|
+
// beforeAll(async () => {
|
|
128
|
+
// accessToken = await getDevAccessToken();
|
|
129
|
+
// await resetState(accessToken);
|
|
130
|
+
// createPullRequestsMockCalls = mockCreatePullRequest({
|
|
131
|
+
// number: 1337,
|
|
132
|
+
// html_url: 'myHtmlUrl',
|
|
133
|
+
// });
|
|
134
|
+
// const options = {
|
|
135
|
+
// githubApiBaseUrlV3: 'https://api.foo.com',
|
|
136
|
+
// ci: true,
|
|
137
|
+
// sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
138
|
+
// author: AUHTOR,
|
|
139
|
+
// accessToken,
|
|
140
|
+
// repoOwner: 'backport-org',
|
|
141
|
+
// reponame: 'integration-test',
|
|
142
|
+
// } as ValidConfigOptions;
|
|
143
|
+
// const commits = await getCommits(options);
|
|
144
|
+
// const targetBranches: string[] = ['7.x'];
|
|
145
|
+
// res = await runSequentially({ options, commits, targetBranches });
|
|
146
|
+
// });
|
|
147
|
+
// it('sends the correct http body when creating pull request', () => {
|
|
148
|
+
// expect(createPullRequestsMockCalls).toMatchInlineSnapshot();
|
|
149
|
+
// });
|
|
150
|
+
// it('returns pull request', () => {
|
|
151
|
+
// expect(res).toEqual([
|
|
152
|
+
// { pullRequestUrl: 'myHtmlUrl', success: true, targetBranch: '6.0' },
|
|
153
|
+
// ]);
|
|
154
|
+
// });
|
|
155
|
+
// it('should not create new branches in origin (backport-org/integration-test)', async () => {
|
|
156
|
+
// const branches = await getBranches({
|
|
157
|
+
// accessToken,
|
|
158
|
+
// repoOwner: REPO_OWNER,
|
|
159
|
+
// repoName: REPO_NAME,
|
|
160
|
+
// });
|
|
161
|
+
// expect(branches.map((b) => b.name)).toEqual(['7.x', '* master']);
|
|
162
|
+
// });
|
|
163
|
+
// it('should create branch in the fork (sqren/integration-test)', async () => {
|
|
164
|
+
// const branches = await getBranches({
|
|
165
|
+
// accessToken,
|
|
166
|
+
// repoOwner: AUHTOR,
|
|
167
|
+
// repoName: REPO_NAME,
|
|
168
|
+
// });
|
|
169
|
+
// expect(branches.map((b) => b.name)).toEqual([
|
|
170
|
+
// '7.x',
|
|
171
|
+
// 'backport/6.0/pr-85_commit-2e63475c',
|
|
172
|
+
// 'master',
|
|
173
|
+
// ]);
|
|
174
|
+
// });
|
|
175
|
+
// it('should have cherry picked the correct commit', async () => {
|
|
176
|
+
// const branches = await getBranches({
|
|
177
|
+
// accessToken,
|
|
178
|
+
// repoOwner: AUHTOR,
|
|
179
|
+
// repoName: REPO_NAME,
|
|
180
|
+
// });
|
|
181
|
+
// const sha = branches.find((branch) => branch.name === '7.x')?.commit.sha;
|
|
182
|
+
// expect(sha).toEqual('foo');
|
|
183
|
+
// });
|
|
184
|
+
// });
|
|
185
|
+
describe('when disabling fork mode', () => {
|
|
186
|
+
let res;
|
|
187
|
+
let accessToken;
|
|
188
|
+
let createPullRequestsMockCalls;
|
|
189
|
+
beforeAll(async () => {
|
|
190
|
+
accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
191
|
+
await resetState(accessToken);
|
|
192
|
+
createPullRequestsMockCalls = mockCreatePullRequest({
|
|
193
|
+
number: 1337,
|
|
194
|
+
html_url: 'myHtmlUrl',
|
|
195
|
+
});
|
|
196
|
+
const options = await (0, options_1.getOptions)([], {
|
|
197
|
+
author: AUHTOR,
|
|
198
|
+
githubApiBaseUrlV3: 'https://api.foo.com',
|
|
199
|
+
ci: true,
|
|
200
|
+
sha: '5bf29b7d847ea3dbde9280448f0f62ad0f22d3ad',
|
|
201
|
+
accessToken,
|
|
202
|
+
repoOwner: 'backport-org',
|
|
203
|
+
repoName: 'integration-test',
|
|
204
|
+
fork: false,
|
|
205
|
+
});
|
|
206
|
+
const commits = await (0, getCommits_1.getCommits)(options);
|
|
207
|
+
const targetBranches = ['7.x'];
|
|
208
|
+
res = await (0, runSequentially_1.runSequentially)({ options, commits, targetBranches });
|
|
209
|
+
});
|
|
210
|
+
it('sends the correct http body when creating pull request', () => {
|
|
211
|
+
expect(createPullRequestsMockCalls).toMatchInlineSnapshot(`
|
|
212
|
+
Array [
|
|
213
|
+
Object {
|
|
214
|
+
"base": "7.x",
|
|
215
|
+
"body": "# Backport
|
|
216
|
+
|
|
217
|
+
This is an automatic backport to 7.x of:
|
|
218
|
+
- Add ❤️ emoji (5bf29b7d)
|
|
219
|
+
|
|
220
|
+
### Questions ?
|
|
221
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
222
|
+
",
|
|
223
|
+
"head": "backport-org:backport/7.x/commit-5bf29b7d",
|
|
224
|
+
"title": "[7.x] Add ❤️ emoji",
|
|
225
|
+
},
|
|
226
|
+
]
|
|
227
|
+
`);
|
|
228
|
+
});
|
|
229
|
+
it('returns pull request', () => {
|
|
230
|
+
expect(res).toEqual([
|
|
231
|
+
{
|
|
232
|
+
didUpdate: false,
|
|
233
|
+
pullRequestNumber: 1337,
|
|
234
|
+
pullRequestUrl: 'myHtmlUrl',
|
|
235
|
+
status: 'success',
|
|
236
|
+
targetBranch: '7.x',
|
|
237
|
+
},
|
|
238
|
+
]);
|
|
239
|
+
});
|
|
240
|
+
it('should create new branches in origin (backport-org/integration-test)', async () => {
|
|
241
|
+
const branches = await getBranches({
|
|
242
|
+
accessToken,
|
|
243
|
+
repoOwner: REPO_OWNER,
|
|
244
|
+
repoName: REPO_NAME,
|
|
245
|
+
});
|
|
246
|
+
expect(branches.map((b) => b.name)).toEqual([
|
|
247
|
+
'7.x',
|
|
248
|
+
BRANCH_NAME,
|
|
249
|
+
'master',
|
|
250
|
+
]);
|
|
251
|
+
});
|
|
252
|
+
it('should NOT create branch in the fork (sqren/integration-test)', async () => {
|
|
253
|
+
const branches = await getBranches({
|
|
254
|
+
accessToken,
|
|
255
|
+
repoOwner: AUHTOR,
|
|
256
|
+
repoName: REPO_NAME,
|
|
257
|
+
});
|
|
258
|
+
expect(branches.map((b) => b.name)).toEqual(['7.x', 'master']);
|
|
259
|
+
});
|
|
260
|
+
it('should cherry pick the correct commit', async () => {
|
|
261
|
+
const branches = await getBranches({
|
|
262
|
+
accessToken,
|
|
263
|
+
repoOwner: REPO_OWNER,
|
|
264
|
+
repoName: REPO_NAME,
|
|
265
|
+
});
|
|
266
|
+
const sha = branches.find((branch) => branch.name === '7.x')?.commit.sha;
|
|
267
|
+
expect(sha).toEqual('b68e4fcaaf4427fe1e902c718b3bb3f07b560fb5');
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
function mockCreatePullRequest(response) {
|
|
272
|
+
const scope = (0, nock_1.default)('https://api.foo.com', { allowUnmocked: true })
|
|
273
|
+
.post('/repos/backport-org/integration-test/pulls')
|
|
274
|
+
.reply(200, response);
|
|
275
|
+
return (0, nockHelpers_1.listenForCallsToNockScope)(scope);
|
|
276
|
+
}
|
|
277
|
+
async function getBranches({ accessToken, repoOwner, repoName, }) {
|
|
278
|
+
// console.log(`fetch branches for ${repoOwner}`);
|
|
279
|
+
const octokit = new rest_1.Octokit({
|
|
280
|
+
auth: accessToken,
|
|
281
|
+
});
|
|
282
|
+
const res = await octokit.repos.listBranches({
|
|
283
|
+
owner: repoOwner,
|
|
284
|
+
repo: repoName,
|
|
285
|
+
});
|
|
286
|
+
return res.data;
|
|
287
|
+
}
|
|
288
|
+
async function deleteBranch({ accessToken, repoOwner, repoName, branchName, }) {
|
|
289
|
+
try {
|
|
290
|
+
const octokit = new rest_1.Octokit({
|
|
291
|
+
auth: accessToken,
|
|
292
|
+
});
|
|
293
|
+
// console.log({ accessToken });
|
|
294
|
+
const opts = {
|
|
295
|
+
owner: repoOwner,
|
|
296
|
+
repo: repoName,
|
|
297
|
+
ref: `heads/${branchName}`,
|
|
298
|
+
};
|
|
299
|
+
const res = await octokit.git.deleteRef(opts);
|
|
300
|
+
// console.log(`Deleted ${repoOwner}:heads/${branchName}`);
|
|
301
|
+
return res.data;
|
|
302
|
+
}
|
|
303
|
+
catch (e) {
|
|
304
|
+
// console.log(
|
|
305
|
+
// `Could not delete ${repoOwner}:heads/${branchName} (${e.message})`
|
|
306
|
+
// );
|
|
307
|
+
if (e.message === 'Reference does not exist') {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
throw e;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
async function resetState(accessToken) {
|
|
314
|
+
await deleteBranch({
|
|
315
|
+
accessToken,
|
|
316
|
+
repoOwner: REPO_OWNER,
|
|
317
|
+
repoName: REPO_NAME,
|
|
318
|
+
branchName: BRANCH_NAME,
|
|
319
|
+
});
|
|
320
|
+
await deleteBranch({
|
|
321
|
+
accessToken,
|
|
322
|
+
repoOwner: AUHTOR,
|
|
323
|
+
repoName: REPO_NAME,
|
|
324
|
+
branchName: BRANCH_NAME,
|
|
325
|
+
});
|
|
326
|
+
await del(INTEGRATION_TEST_DATA_PATH);
|
|
327
|
+
}
|
|
@@ -12,7 +12,6 @@ const envConstants_1 = require("./envConstants");
|
|
|
12
12
|
const helpers_1 = require("./helpers");
|
|
13
13
|
jest.unmock('make-dir');
|
|
14
14
|
jest.unmock('del');
|
|
15
|
-
jest.unmock('../../services/child-process-promisified');
|
|
16
15
|
describe('integration', () => {
|
|
17
16
|
afterAll(() => {
|
|
18
17
|
nock_1.default.cleanAll();
|
|
@@ -20,15 +19,15 @@ describe('integration', () => {
|
|
|
20
19
|
describe('when a single commit is backported', () => {
|
|
21
20
|
let res;
|
|
22
21
|
let spies;
|
|
23
|
-
beforeEach(lodash_1.once(async () => {
|
|
22
|
+
beforeEach((0, lodash_1.once)(async () => {
|
|
24
23
|
jest.clearAllMocks();
|
|
25
|
-
spies = createSpies_1.createSpies({ commitCount: 1 });
|
|
26
|
-
await helpers_1.deleteAndSetupEnvironment();
|
|
27
|
-
const options = await options_1.getOptions([], {
|
|
24
|
+
spies = (0, createSpies_1.createSpies)({ commitCount: 1 });
|
|
25
|
+
await (0, helpers_1.deleteAndSetupEnvironment)();
|
|
26
|
+
const options = await (0, options_1.getOptions)([], {
|
|
28
27
|
// use localhost to avoid CORS issues
|
|
29
28
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
30
29
|
});
|
|
31
|
-
res = await runWithOptions_1.runWithOptions(options);
|
|
30
|
+
res = await (0, runWithOptions_1.runWithOptions)(options);
|
|
32
31
|
}));
|
|
33
32
|
it('returns pull request', () => {
|
|
34
33
|
expect(res).toEqual([
|
|
@@ -39,7 +38,7 @@ describe('integration', () => {
|
|
|
39
38
|
expect(spies.createPullRequestCalls).toEqual([
|
|
40
39
|
{
|
|
41
40
|
base: '6.0',
|
|
42
|
-
body: 'Backports the following commits to 6.0:\n -
|
|
41
|
+
body: 'Backports the following commits to 6.0:\n - #85',
|
|
43
42
|
head: 'sqren:backport/6.0/pr-85',
|
|
44
43
|
title: '[6.0] Add witch (#85)',
|
|
45
44
|
},
|
|
@@ -51,15 +50,15 @@ describe('integration', () => {
|
|
|
51
50
|
expect(spies.commitsByAuthorCalls).toMatchSnapshot();
|
|
52
51
|
});
|
|
53
52
|
it('should not create new branches in origin (backport-org/backport-demo)', async () => {
|
|
54
|
-
const branches = await helpers_1.getBranches(envConstants_1.REMOTE_ORIGIN_REPO_PATH);
|
|
53
|
+
const branches = await (0, helpers_1.getBranches)(envConstants_1.REMOTE_ORIGIN_REPO_PATH);
|
|
55
54
|
expect(branches).toEqual(['6.0', '* master']);
|
|
56
55
|
});
|
|
57
56
|
it('should create branch in the fork (sqren/backport-demo)', async () => {
|
|
58
|
-
const branches = await helpers_1.getBranches(envConstants_1.REMOTE_FORK_REPO_PATH);
|
|
57
|
+
const branches = await (0, helpers_1.getBranches)(envConstants_1.REMOTE_FORK_REPO_PATH);
|
|
59
58
|
expect(branches).toEqual(['6.0', 'backport/6.0/pr-85', '* master']);
|
|
60
59
|
});
|
|
61
60
|
it('should have cherry picked the correct commit', async () => {
|
|
62
|
-
const commit = await helpers_1.getLatestCommit({
|
|
61
|
+
const commit = await (0, helpers_1.getLatestCommit)({
|
|
63
62
|
branch: 'backport/6.0/pr-85',
|
|
64
63
|
commitCount: 1,
|
|
65
64
|
cwd: envConstants_1.REMOTE_FORK_REPO_PATH,
|
|
@@ -82,23 +81,23 @@ describe('integration', () => {
|
|
|
82
81
|
describe('when two commits are backported', () => {
|
|
83
82
|
let spies;
|
|
84
83
|
let res;
|
|
85
|
-
beforeEach(lodash_1.once(async () => {
|
|
84
|
+
beforeEach((0, lodash_1.once)(async () => {
|
|
86
85
|
jest.clearAllMocks();
|
|
87
|
-
spies = createSpies_1.createSpies({ commitCount: 2 });
|
|
88
|
-
await helpers_1.deleteAndSetupEnvironment();
|
|
89
|
-
const options = await options_1.getOptions([], {
|
|
86
|
+
spies = (0, createSpies_1.createSpies)({ commitCount: 2 });
|
|
87
|
+
await (0, helpers_1.deleteAndSetupEnvironment)();
|
|
88
|
+
const options = await (0, options_1.getOptions)([], {
|
|
90
89
|
// use localhost to avoid CORS issues
|
|
91
90
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
92
91
|
});
|
|
93
|
-
res = await runWithOptions_1.runWithOptions(options);
|
|
92
|
+
res = await (0, runWithOptions_1.runWithOptions)(options);
|
|
94
93
|
}));
|
|
95
94
|
it('sends the correct http body when creating pull request', () => {
|
|
96
95
|
expect(spies.createPullRequestCalls).toEqual([
|
|
97
96
|
{
|
|
98
|
-
title: '[6.0] Add witch (#85) | Add 👻
|
|
97
|
+
title: '[6.0] Add witch (#85) | Add 👻',
|
|
99
98
|
head: 'sqren:backport/6.0/pr-85_commit-2e63475c',
|
|
100
99
|
base: '6.0',
|
|
101
|
-
body: 'Backports the following commits to 6.0:\n -
|
|
100
|
+
body: 'Backports the following commits to 6.0:\n - #85\n - Add 👻 (2e63475c)',
|
|
102
101
|
},
|
|
103
102
|
]);
|
|
104
103
|
});
|
|
@@ -113,11 +112,11 @@ describe('integration', () => {
|
|
|
113
112
|
expect(spies.commitsByAuthorCalls).toMatchSnapshot();
|
|
114
113
|
});
|
|
115
114
|
it('should not create new branches in origin (backport-org/backport-demo)', async () => {
|
|
116
|
-
const branches = await helpers_1.getBranches(envConstants_1.REMOTE_ORIGIN_REPO_PATH);
|
|
115
|
+
const branches = await (0, helpers_1.getBranches)(envConstants_1.REMOTE_ORIGIN_REPO_PATH);
|
|
117
116
|
expect(branches).toEqual(['6.0', '* master']);
|
|
118
117
|
});
|
|
119
118
|
it('should create branch in the fork (sqren/backport-demo)', async () => {
|
|
120
|
-
const branches = await helpers_1.getBranches(envConstants_1.REMOTE_FORK_REPO_PATH);
|
|
119
|
+
const branches = await (0, helpers_1.getBranches)(envConstants_1.REMOTE_FORK_REPO_PATH);
|
|
121
120
|
expect(branches).toEqual([
|
|
122
121
|
'6.0',
|
|
123
122
|
'backport/6.0/pr-85_commit-2e63475c',
|
|
@@ -125,7 +124,7 @@ describe('integration', () => {
|
|
|
125
124
|
]);
|
|
126
125
|
});
|
|
127
126
|
it('should have cherry picked the correct commit', async () => {
|
|
128
|
-
const commit = await helpers_1.getLatestCommit({
|
|
127
|
+
const commit = await (0, helpers_1.getLatestCommit)({
|
|
129
128
|
branch: 'backport/6.0/pr-85_commit-2e63475c',
|
|
130
129
|
commitCount: 2,
|
|
131
130
|
cwd: envConstants_1.REMOTE_FORK_REPO_PATH,
|
|
@@ -158,21 +157,21 @@ describe('integration', () => {
|
|
|
158
157
|
describe('when disabling fork mode', () => {
|
|
159
158
|
let res;
|
|
160
159
|
let spies;
|
|
161
|
-
beforeEach(lodash_1.once(async () => {
|
|
160
|
+
beforeEach((0, lodash_1.once)(async () => {
|
|
162
161
|
jest.clearAllMocks();
|
|
163
|
-
spies = createSpies_1.createSpies({ commitCount: 1 });
|
|
164
|
-
await helpers_1.deleteAndSetupEnvironment();
|
|
165
|
-
const options = await options_1.getOptions(['--fork=false'], {
|
|
162
|
+
spies = (0, createSpies_1.createSpies)({ commitCount: 1 });
|
|
163
|
+
await (0, helpers_1.deleteAndSetupEnvironment)();
|
|
164
|
+
const options = await (0, options_1.getOptions)(['--fork=false'], {
|
|
166
165
|
// use localhost to avoid CORS issues
|
|
167
166
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
168
167
|
});
|
|
169
|
-
res = await runWithOptions_1.runWithOptions(options);
|
|
168
|
+
res = await (0, runWithOptions_1.runWithOptions)(options);
|
|
170
169
|
}));
|
|
171
170
|
it('sends the correct http body when creating pull request', () => {
|
|
172
171
|
expect(spies.createPullRequestCalls).toEqual([
|
|
173
172
|
{
|
|
174
173
|
base: '6.0',
|
|
175
|
-
body: 'Backports the following commits to 6.0:\n -
|
|
174
|
+
body: 'Backports the following commits to 6.0:\n - #85',
|
|
176
175
|
head: 'backport-org:backport/6.0/pr-85',
|
|
177
176
|
title: '[6.0] Add witch (#85)',
|
|
178
177
|
},
|
|
@@ -184,15 +183,15 @@ describe('integration', () => {
|
|
|
184
183
|
]);
|
|
185
184
|
});
|
|
186
185
|
it('should create new branches in origin (backport-org/backport-demo)', async () => {
|
|
187
|
-
const branches = await helpers_1.getBranches(envConstants_1.REMOTE_ORIGIN_REPO_PATH);
|
|
186
|
+
const branches = await (0, helpers_1.getBranches)(envConstants_1.REMOTE_ORIGIN_REPO_PATH);
|
|
188
187
|
expect(branches).toEqual(['6.0', 'backport/6.0/pr-85', '* master']);
|
|
189
188
|
});
|
|
190
189
|
it('should NOT create branch in the fork (sqren/backport-demo)', async () => {
|
|
191
|
-
const branches = await helpers_1.getBranches(envConstants_1.REMOTE_FORK_REPO_PATH);
|
|
190
|
+
const branches = await (0, helpers_1.getBranches)(envConstants_1.REMOTE_FORK_REPO_PATH);
|
|
192
191
|
expect(branches).toEqual(['6.0', '* master']);
|
|
193
192
|
});
|
|
194
193
|
it('should cherry pick the correct commit', async () => {
|
|
195
|
-
const commit = await helpers_1.getLatestCommit({
|
|
194
|
+
const commit = await (0, helpers_1.getLatestCommit)({
|
|
196
195
|
branch: 'backport/6.0/pr-85',
|
|
197
196
|
commitCount: 1,
|
|
198
197
|
cwd: envConstants_1.REMOTE_ORIGIN_REPO_PATH,
|
|
@@ -0,0 +1,37 @@
|
|
|
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;
|
|
@@ -13,4 +13,4 @@ export declare function mockGqlRequest<T>({ name, statusCode, body, headers, api
|
|
|
13
13
|
query: string;
|
|
14
14
|
variables: string;
|
|
15
15
|
}[];
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function listenForCallsToNockScope(scope: nock.Scope): unknown[];
|
package/dist/test/nockHelpers.js
CHANGED
|
@@ -3,36 +3,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.listenForCallsToNockScope = exports.mockGqlRequest = void 0;
|
|
7
7
|
const url_1 = require("url");
|
|
8
8
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
9
9
|
const nock_1 = __importDefault(require("nock"));
|
|
10
10
|
function mockGqlRequest({ name, statusCode, body, headers, apiBaseUrl, }) {
|
|
11
11
|
const { origin, pathname } = new url_1.URL(
|
|
12
12
|
// default to localhost as host to avoid CORS issues
|
|
13
|
-
apiBaseUrl
|
|
14
|
-
|
|
15
|
-
apiBaseUrl !== void 0 ?
|
|
16
|
-
// default to localhost as host to avoid CORS issues
|
|
17
|
-
apiBaseUrl : 'http://localhost/graphql');
|
|
18
|
-
const scope = nock_1.default(origin)
|
|
13
|
+
apiBaseUrl ?? 'http://localhost/graphql');
|
|
14
|
+
const scope = (0, nock_1.default)(origin)
|
|
19
15
|
.post(pathname, (body) => getGqlName(body.query) === name)
|
|
20
16
|
.reply(statusCode, body, headers);
|
|
21
|
-
return
|
|
17
|
+
return listenForCallsToNockScope(scope);
|
|
22
18
|
}
|
|
23
19
|
exports.mockGqlRequest = mockGqlRequest;
|
|
24
20
|
function getGqlName(query) {
|
|
25
|
-
const obj = graphql_tag_1.default `
|
|
21
|
+
const obj = (0, graphql_tag_1.default) `
|
|
26
22
|
${query}
|
|
27
23
|
`;
|
|
28
24
|
// @ts-expect-error
|
|
29
25
|
return obj.definitions[0].name.value;
|
|
30
26
|
}
|
|
31
|
-
function
|
|
27
|
+
function listenForCallsToNockScope(scope) {
|
|
32
28
|
const calls = [];
|
|
33
29
|
scope.on('request', (req, interceptor, body) => {
|
|
34
30
|
calls.push(JSON.parse(body));
|
|
35
31
|
});
|
|
36
32
|
return calls;
|
|
37
33
|
}
|
|
38
|
-
exports.
|
|
34
|
+
exports.listenForCallsToNockScope = listenForCallsToNockScope;
|
|
@@ -18,7 +18,7 @@ async function getDevAccessToken() {
|
|
|
18
18
|
return accessToken.trim();
|
|
19
19
|
}
|
|
20
20
|
catch (e) {
|
|
21
|
-
throw new Error(`Missing
|
|
21
|
+
throw new Error(`Missing accessToken in "${accessTokenFile}"`);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
exports.getDevAccessToken = getDevAccessToken;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|