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,291 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const HandledError_1 = require("../../HandledError");
|
|
4
|
-
const createStatusComment_1 = require("./createStatusComment");
|
|
5
|
-
describe('getCommentBody', () => {
|
|
6
|
-
describe('when an unknown error occurs', () => {
|
|
7
|
-
const getParams = (opts) => ({
|
|
8
|
-
options: {
|
|
9
|
-
backportBinary: 'node scripts/backport',
|
|
10
|
-
...opts,
|
|
11
|
-
},
|
|
12
|
-
pullNumber: 55,
|
|
13
|
-
backportResponse: {
|
|
14
|
-
status: 'failure',
|
|
15
|
-
errorMessage: 'A terrible error occured',
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
it('posts a comment when running on ci', () => {
|
|
19
|
-
const params = getParams({ ci: true });
|
|
20
|
-
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
21
|
-
"## 💔 Backport failed
|
|
22
|
-
The pull request could not be backported due to the following error:
|
|
23
|
-
\`A terrible error occured\`
|
|
24
|
-
|
|
25
|
-
### How to fix
|
|
26
|
-
Re-run the backport manually:
|
|
27
|
-
\`\`\`
|
|
28
|
-
node scripts/backport --pr 55
|
|
29
|
-
\`\`\`
|
|
30
|
-
|
|
31
|
-
### Questions ?
|
|
32
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)"
|
|
33
|
-
`);
|
|
34
|
-
});
|
|
35
|
-
it('does not post a comment when running manually', () => {
|
|
36
|
-
const params = getParams({ ci: false });
|
|
37
|
-
expect((0, createStatusComment_1.getCommentBody)(params)).toBe(undefined);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
describe('when all backports succeed', () => {
|
|
41
|
-
const getParams = (opts) => ({
|
|
42
|
-
options: {
|
|
43
|
-
repoName: 'kibana',
|
|
44
|
-
repoOwner: 'elastic',
|
|
45
|
-
autoMerge: true,
|
|
46
|
-
...opts,
|
|
47
|
-
},
|
|
48
|
-
pullNumber: 55,
|
|
49
|
-
backportResponse: {
|
|
50
|
-
status: 'success',
|
|
51
|
-
results: [
|
|
52
|
-
{
|
|
53
|
-
status: 'success',
|
|
54
|
-
targetBranch: '7.x',
|
|
55
|
-
pullRequestNumber: 55,
|
|
56
|
-
pullRequestUrl: 'url-to-pr',
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
status: 'success',
|
|
60
|
-
targetBranch: '7.1',
|
|
61
|
-
pullRequestNumber: 66,
|
|
62
|
-
pullRequestUrl: 'url-to-pr',
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
it('posts a comment on ci', () => {
|
|
68
|
-
const params = getParams({ ci: true });
|
|
69
|
-
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
70
|
-
"## 💚 All backports created successfully
|
|
71
|
-
|
|
72
|
-
| Status | Branch | Result |
|
|
73
|
-
|:------:|:------:|:------|
|
|
74
|
-
|✅|7.x|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/55\\">](url-to-pr)|
|
|
75
|
-
|✅|7.1|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/66\\">](url-to-pr)|
|
|
76
|
-
|
|
77
|
-
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
78
|
-
|
|
79
|
-
### Questions ?
|
|
80
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)"
|
|
81
|
-
`);
|
|
82
|
-
});
|
|
83
|
-
it('posts a comment when running locally', () => {
|
|
84
|
-
const params = getParams({ ci: false });
|
|
85
|
-
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
86
|
-
"## 💚 All backports created successfully
|
|
87
|
-
|
|
88
|
-
| Status | Branch | Result |
|
|
89
|
-
|:------:|:------:|:------|
|
|
90
|
-
|✅|7.x|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/55\\">](url-to-pr)|
|
|
91
|
-
|✅|7.1|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/66\\">](url-to-pr)|
|
|
92
|
-
|
|
93
|
-
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
94
|
-
|
|
95
|
-
### Questions ?
|
|
96
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)"
|
|
97
|
-
`);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
describe('when all backports fail', () => {
|
|
101
|
-
const getParams = (opts) => ({
|
|
102
|
-
options: {
|
|
103
|
-
repoName: 'kibana',
|
|
104
|
-
repoOwner: 'elastic',
|
|
105
|
-
autoMerge: true,
|
|
106
|
-
backportBinary: 'node scripts/backport',
|
|
107
|
-
...opts,
|
|
108
|
-
},
|
|
109
|
-
pullNumber: 55,
|
|
110
|
-
backportResponse: {
|
|
111
|
-
status: 'success',
|
|
112
|
-
results: [
|
|
113
|
-
{
|
|
114
|
-
status: 'failure',
|
|
115
|
-
targetBranch: '7.x',
|
|
116
|
-
error: new Error('Boom!'),
|
|
117
|
-
errorMessage: 'My boom error!',
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
status: 'failure',
|
|
121
|
-
targetBranch: '7.1',
|
|
122
|
-
error: new Error('Boom!'),
|
|
123
|
-
errorMessage: 'My boom error!',
|
|
124
|
-
},
|
|
125
|
-
],
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
it('posts a comment on CI', () => {
|
|
129
|
-
const params = getParams({ ci: true });
|
|
130
|
-
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
131
|
-
"## 💔 All backports failed
|
|
132
|
-
|
|
133
|
-
| Status | Branch | Result |
|
|
134
|
-
|:------:|:------:|:------|
|
|
135
|
-
|❌|7.x|My boom error!|
|
|
136
|
-
|❌|7.1|My boom error!|
|
|
137
|
-
|
|
138
|
-
### How to fix
|
|
139
|
-
Re-run the backport manually:
|
|
140
|
-
\`\`\`
|
|
141
|
-
node scripts/backport --pr 55
|
|
142
|
-
\`\`\`
|
|
143
|
-
|
|
144
|
-
### Questions ?
|
|
145
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)"
|
|
146
|
-
`);
|
|
147
|
-
});
|
|
148
|
-
it('does not post a comment when running manaully', () => {
|
|
149
|
-
const params = getParams({ ci: false });
|
|
150
|
-
expect((0, createStatusComment_1.getCommentBody)(params)).toBe(undefined);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
describe('when some backports fail', () => {
|
|
154
|
-
const getParams = (opts) => ({
|
|
155
|
-
options: {
|
|
156
|
-
repoName: 'kibana',
|
|
157
|
-
repoOwner: 'elastic',
|
|
158
|
-
autoMerge: true,
|
|
159
|
-
backportBinary: 'node scripts/backport',
|
|
160
|
-
...opts,
|
|
161
|
-
},
|
|
162
|
-
pullNumber: 55,
|
|
163
|
-
backportResponse: {
|
|
164
|
-
status: 'success',
|
|
165
|
-
results: [
|
|
166
|
-
{
|
|
167
|
-
status: 'success',
|
|
168
|
-
targetBranch: '7.x',
|
|
169
|
-
pullRequestNumber: 55,
|
|
170
|
-
pullRequestUrl: 'url-to-pr-55',
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
status: 'failure',
|
|
174
|
-
targetBranch: '7.1',
|
|
175
|
-
error: new Error('Boom!'),
|
|
176
|
-
errorMessage: 'My boom error!',
|
|
177
|
-
},
|
|
178
|
-
],
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
it('post a comment when running on CI', () => {
|
|
182
|
-
const params = getParams({ ci: true });
|
|
183
|
-
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
184
|
-
"## 💔 Some backports could not be created
|
|
185
|
-
|
|
186
|
-
| Status | Branch | Result |
|
|
187
|
-
|:------:|:------:|:------|
|
|
188
|
-
|✅|7.x|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/55\\">](url-to-pr-55)|
|
|
189
|
-
|❌|7.1|My boom error!|
|
|
190
|
-
|
|
191
|
-
### How to fix
|
|
192
|
-
Re-run the backport manually:
|
|
193
|
-
\`\`\`
|
|
194
|
-
node scripts/backport --pr 55
|
|
195
|
-
\`\`\`
|
|
196
|
-
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
197
|
-
|
|
198
|
-
### Questions ?
|
|
199
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)"
|
|
200
|
-
`);
|
|
201
|
-
});
|
|
202
|
-
it('does not post a comment when running manually because some backports failed', () => {
|
|
203
|
-
const params = getParams({ ci: false });
|
|
204
|
-
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`undefined`);
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
describe('when some backports fail due to conflicts', () => {
|
|
208
|
-
const getParams = (opts) => ({
|
|
209
|
-
options: {
|
|
210
|
-
repoName: 'kibana',
|
|
211
|
-
repoOwner: 'elastic',
|
|
212
|
-
autoMerge: true,
|
|
213
|
-
backportBinary: 'node scripts/backport',
|
|
214
|
-
...opts,
|
|
215
|
-
},
|
|
216
|
-
pullNumber: 55,
|
|
217
|
-
backportResponse: {
|
|
218
|
-
status: 'success',
|
|
219
|
-
results: [
|
|
220
|
-
{
|
|
221
|
-
status: 'success',
|
|
222
|
-
targetBranch: '7.x',
|
|
223
|
-
pullRequestNumber: 55,
|
|
224
|
-
pullRequestUrl: 'url-to-pr-55',
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
status: 'failure',
|
|
228
|
-
targetBranch: '7.1',
|
|
229
|
-
errorMessage: 'My boom error!',
|
|
230
|
-
error: new HandledError_1.HandledError('Boom!', {
|
|
231
|
-
type: 'merge-conflict-due-to-missing-backports',
|
|
232
|
-
commitsWithoutBackports: [
|
|
233
|
-
{
|
|
234
|
-
//@ts-expect-error
|
|
235
|
-
commit: {
|
|
236
|
-
pullNumber: 5,
|
|
237
|
-
pullUrl: 'url-to-pr-5',
|
|
238
|
-
originalMessage: 'New Zealand commit message',
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
//@ts-expect-error
|
|
243
|
-
commit: {
|
|
244
|
-
pullNumber: 44,
|
|
245
|
-
pullUrl: 'url-to-pr-44',
|
|
246
|
-
originalMessage: 'Australia commit',
|
|
247
|
-
},
|
|
248
|
-
},
|
|
249
|
-
],
|
|
250
|
-
}),
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
status: 'failure',
|
|
254
|
-
targetBranch: '7.2',
|
|
255
|
-
errorMessage: 'My boom error!',
|
|
256
|
-
error: new HandledError_1.HandledError('Boom!', {
|
|
257
|
-
type: 'merge-conflict-due-to-missing-backports',
|
|
258
|
-
commitsWithoutBackports: [],
|
|
259
|
-
}),
|
|
260
|
-
},
|
|
261
|
-
],
|
|
262
|
-
},
|
|
263
|
-
});
|
|
264
|
-
it('posts a comment when running on CI', () => {
|
|
265
|
-
const params = getParams({ ci: true });
|
|
266
|
-
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
267
|
-
"## 💔 Some backports could not be created
|
|
268
|
-
|
|
269
|
-
| Status | Branch | Result |
|
|
270
|
-
|:------:|:------:|:------|
|
|
271
|
-
|✅|7.x|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/55\\">](url-to-pr-55)|
|
|
272
|
-
|❌|7.1|**Backport failed because of merge conflicts**<br><br>You might need to backport the following PRs to 7.1:<br> - [New Zealand commit message](url-to-pr-5)<br> - [Australia commit](url-to-pr-44)|
|
|
273
|
-
|❌|7.2|**Backport failed because of merge conflicts**|
|
|
274
|
-
|
|
275
|
-
### How to fix
|
|
276
|
-
Re-run the backport manually:
|
|
277
|
-
\`\`\`
|
|
278
|
-
node scripts/backport --pr 55
|
|
279
|
-
\`\`\`
|
|
280
|
-
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
281
|
-
|
|
282
|
-
### Questions ?
|
|
283
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)"
|
|
284
|
-
`);
|
|
285
|
-
});
|
|
286
|
-
it('does not post a comment when running manually because some backports failed', () => {
|
|
287
|
-
const params = getParams({ ci: false });
|
|
288
|
-
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`undefined`);
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,82 +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 nock_1 = __importDefault(require("nock"));
|
|
7
|
-
const nockHelpers_1 = require("../../../test/nockHelpers");
|
|
8
|
-
const HandledError_1 = require("../../HandledError");
|
|
9
|
-
const apiRequestV4_1 = require("./apiRequestV4");
|
|
10
|
-
describe('apiRequestV4', () => {
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
nock_1.default.cleanAll();
|
|
13
|
-
});
|
|
14
|
-
describe('when request succeeds', () => {
|
|
15
|
-
let res;
|
|
16
|
-
let commitsByAuthorCalls;
|
|
17
|
-
beforeEach(async () => {
|
|
18
|
-
commitsByAuthorCalls = (0, nockHelpers_1.mockGqlRequest)({
|
|
19
|
-
name: 'MyQuery',
|
|
20
|
-
statusCode: 200,
|
|
21
|
-
body: { data: { hello: 'world' } },
|
|
22
|
-
});
|
|
23
|
-
res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
24
|
-
accessToken: 'myAccessToken',
|
|
25
|
-
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
26
|
-
query: 'query MyQuery{ foo }',
|
|
27
|
-
variables: { foo: 'bar' },
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
it('should return correct response', async () => {
|
|
31
|
-
expect(res).toEqual({ hello: 'world' });
|
|
32
|
-
});
|
|
33
|
-
it('should call with correct args', async () => {
|
|
34
|
-
expect(commitsByAuthorCalls).toEqual([
|
|
35
|
-
{
|
|
36
|
-
query: 'query MyQuery{ foo }',
|
|
37
|
-
variables: { foo: 'bar' },
|
|
38
|
-
},
|
|
39
|
-
]);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
describe('when request fails with error messages', () => {
|
|
43
|
-
beforeEach(() => {
|
|
44
|
-
(0, nockHelpers_1.mockGqlRequest)({
|
|
45
|
-
name: 'MyQuery',
|
|
46
|
-
statusCode: 500,
|
|
47
|
-
body: {
|
|
48
|
-
errors: [{ message: 'some error' }, { message: 'some other error' }],
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
it('should return parsed github error', async () => {
|
|
53
|
-
return expect((0, apiRequestV4_1.apiRequestV4)({
|
|
54
|
-
accessToken: 'myAccessToken',
|
|
55
|
-
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
56
|
-
query: 'query MyQuery{ foo }',
|
|
57
|
-
variables: {
|
|
58
|
-
foo: 'bar',
|
|
59
|
-
},
|
|
60
|
-
})).rejects.toThrowError(new HandledError_1.HandledError(`some error, some other error (Unhandled Github v4 error)`));
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
describe('when request fails without error messages', () => {
|
|
64
|
-
beforeEach(() => {
|
|
65
|
-
(0, nockHelpers_1.mockGqlRequest)({
|
|
66
|
-
name: 'MyQuery',
|
|
67
|
-
statusCode: 500,
|
|
68
|
-
body: { data: { foo: 'bar' } },
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
it('should return parsed github error', async () => {
|
|
72
|
-
return expect((0, apiRequestV4_1.apiRequestV4)({
|
|
73
|
-
accessToken: 'myAccessToken',
|
|
74
|
-
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
75
|
-
query: 'query MyQuery{ foo }',
|
|
76
|
-
variables: {
|
|
77
|
-
foo: 'bar',
|
|
78
|
-
},
|
|
79
|
-
})).rejects.toThrowErrorMatchingSnapshot();
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,112 +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 crypto_1 = __importDefault(require("crypto"));
|
|
7
|
-
const rest_1 = require("@octokit/rest");
|
|
8
|
-
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
9
|
-
const createPullRequest_1 = require("../v3/createPullRequest");
|
|
10
|
-
const disablePullRequestAutoMerge_1 = require("./disablePullRequestAutoMerge");
|
|
11
|
-
const enablePullRequestAutoMerge_1 = require("./enablePullRequestAutoMerge");
|
|
12
|
-
const fetchPullRequestAutoMergeMethod_1 = require("./fetchPullRequestAutoMergeMethod");
|
|
13
|
-
// The test repo requires auto-merge being enabled in options, as well as all merge types enabled (merge, squash, rebase)
|
|
14
|
-
// The test pull requests should be open, and not currently able to be merged (e.g. because it requires an approval),
|
|
15
|
-
// otherwise it will be merged when auto-merge is turned on
|
|
16
|
-
const TEST_REPO_OWNER = 'backport-org';
|
|
17
|
-
const TEST_REPO_NAME = 'repo-with-auto-merge-enabled';
|
|
18
|
-
// commit to create new branch from
|
|
19
|
-
// https://github.com/backport-org/repo-with-auto-merge-enabled/commit/1a88d210f90a22e2a06253c5760909833dc820e9
|
|
20
|
-
const COMMIT_SHA = '1a88d210f90a22e2a06253c5760909833dc820e9';
|
|
21
|
-
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
22
|
-
async function closePr(octokit, pullNumber) {
|
|
23
|
-
await octokit.pulls.update({
|
|
24
|
-
owner: TEST_REPO_OWNER,
|
|
25
|
-
repo: TEST_REPO_NAME,
|
|
26
|
-
pull_number: pullNumber,
|
|
27
|
-
state: 'closed',
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
async function createPr(options, branchName) {
|
|
31
|
-
const prPayload = {
|
|
32
|
-
base: 'main',
|
|
33
|
-
head: branchName,
|
|
34
|
-
body: 'testing...',
|
|
35
|
-
owner: TEST_REPO_OWNER,
|
|
36
|
-
repo: TEST_REPO_NAME,
|
|
37
|
-
title: 'my pr title',
|
|
38
|
-
};
|
|
39
|
-
const { number } = await (0, createPullRequest_1.createPullRequest)({ options, prPayload });
|
|
40
|
-
return number;
|
|
41
|
-
}
|
|
42
|
-
async function deleteBranch(octokit, branchName) {
|
|
43
|
-
await octokit.git.deleteRef({
|
|
44
|
-
owner: TEST_REPO_OWNER,
|
|
45
|
-
repo: TEST_REPO_NAME,
|
|
46
|
-
ref: `heads/${branchName}`,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
async function createBranch(octokit, branchName, sha) {
|
|
50
|
-
await octokit.git.createRef({
|
|
51
|
-
owner: TEST_REPO_OWNER,
|
|
52
|
-
repo: TEST_REPO_NAME,
|
|
53
|
-
ref: `refs/heads/${branchName}`,
|
|
54
|
-
sha,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
// causes flaky test runs on CI because parallel builds are racing each other
|
|
58
|
-
// might also be an issue with Github's API being slow at updating after a mutation happens
|
|
59
|
-
// eslint-disable-next-line jest/no-disabled-tests
|
|
60
|
-
describe.skip('enablePullRequestAutoMerge', () => {
|
|
61
|
-
let pullNumber;
|
|
62
|
-
let branchName;
|
|
63
|
-
let octokit;
|
|
64
|
-
let options;
|
|
65
|
-
beforeAll(async () => {
|
|
66
|
-
const accessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
67
|
-
const randomString = crypto_1.default.randomBytes(4).toString('hex');
|
|
68
|
-
branchName = `test-${randomString}`;
|
|
69
|
-
options = {
|
|
70
|
-
accessToken,
|
|
71
|
-
repoOwner: TEST_REPO_OWNER,
|
|
72
|
-
repoName: TEST_REPO_NAME,
|
|
73
|
-
};
|
|
74
|
-
octokit = new rest_1.Octokit({ auth: accessToken });
|
|
75
|
-
await createBranch(octokit, branchName, COMMIT_SHA);
|
|
76
|
-
pullNumber = await createPr(options, branchName);
|
|
77
|
-
});
|
|
78
|
-
// cleanup
|
|
79
|
-
afterAll(async () => {
|
|
80
|
-
await closePr(octokit, pullNumber);
|
|
81
|
-
await deleteBranch(octokit, branchName);
|
|
82
|
-
});
|
|
83
|
-
// reset auto-merge state between runs
|
|
84
|
-
afterEach(async () => {
|
|
85
|
-
await (0, disablePullRequestAutoMerge_1.disablePullRequestAutoMerge)(options, pullNumber);
|
|
86
|
-
});
|
|
87
|
-
it('should initially have auto-merge disabled', async () => {
|
|
88
|
-
const autoMergeMethod = await (0, fetchPullRequestAutoMergeMethod_1.fetchPullRequestAutoMergeMethod)(options, pullNumber);
|
|
89
|
-
expect(autoMergeMethod).toBe(undefined);
|
|
90
|
-
});
|
|
91
|
-
it('should enable auto-merge via merge', async () => {
|
|
92
|
-
await (0, enablePullRequestAutoMerge_1.enablePullRequestAutoMerge)({ ...options, autoMergeMethod: 'merge' }, pullNumber);
|
|
93
|
-
// ensure Github API reflects the change before querying
|
|
94
|
-
await sleep(100);
|
|
95
|
-
const autoMergeMethod = await (0, fetchPullRequestAutoMergeMethod_1.fetchPullRequestAutoMergeMethod)(options, pullNumber);
|
|
96
|
-
expect(autoMergeMethod).toBe('MERGE');
|
|
97
|
-
});
|
|
98
|
-
it('should not enable auto-merge via rebase because it is disallowed', async () => {
|
|
99
|
-
await (0, enablePullRequestAutoMerge_1.enablePullRequestAutoMerge)({ ...options, autoMergeMethod: 'rebase' }, pullNumber);
|
|
100
|
-
// ensure Github API reflects the change before querying
|
|
101
|
-
await sleep(100);
|
|
102
|
-
const autoMergeMethod = await (0, fetchPullRequestAutoMergeMethod_1.fetchPullRequestAutoMergeMethod)(options, pullNumber);
|
|
103
|
-
expect(autoMergeMethod).toBe(undefined);
|
|
104
|
-
});
|
|
105
|
-
it('should enable auto-merge via squash', async () => {
|
|
106
|
-
await (0, enablePullRequestAutoMerge_1.enablePullRequestAutoMerge)({ ...options, autoMergeMethod: 'squash' }, pullNumber);
|
|
107
|
-
// ensure Github API reflects the change before querying
|
|
108
|
-
await sleep(100);
|
|
109
|
-
const autoMergeMethod = await (0, fetchPullRequestAutoMergeMethod_1.fetchPullRequestAutoMergeMethod)(options, pullNumber);
|
|
110
|
-
expect(autoMergeMethod).toBe('SQUASH');
|
|
111
|
-
});
|
|
112
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
4
|
-
const fetchAuthorId_1 = require("./fetchAuthorId");
|
|
5
|
-
describe('fetchAuthorId', () => {
|
|
6
|
-
let devAccessToken;
|
|
7
|
-
beforeAll(async () => {
|
|
8
|
-
devAccessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
|
-
});
|
|
10
|
-
describe('author = null', () => {
|
|
11
|
-
it('returns null', async () => {
|
|
12
|
-
const options = {
|
|
13
|
-
accessToken: devAccessToken,
|
|
14
|
-
author: null,
|
|
15
|
-
};
|
|
16
|
-
expect(await (0, fetchAuthorId_1.fetchAuthorId)(options)).toEqual(null);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
describe('author is "sqren"', () => {
|
|
20
|
-
it('returns author id', async () => {
|
|
21
|
-
const options = {
|
|
22
|
-
accessToken: devAccessToken,
|
|
23
|
-
author: 'sqren',
|
|
24
|
-
};
|
|
25
|
-
expect(await (0, fetchAuthorId_1.fetchAuthorId)(options)).toEqual('MDQ6VXNlcjIwOTk2Ng==');
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,86 +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.fetchCommitByPullNumber = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const ora_1 = __importDefault(require("ora"));
|
|
9
|
-
const HandledError_1 = require("../../HandledError");
|
|
10
|
-
const commitFormatters_1 = require("../commitFormatters");
|
|
11
|
-
const apiRequestV4_1 = require("./apiRequestV4");
|
|
12
|
-
const getExistingTargetPullRequests_1 = require("./getExistingTargetPullRequests");
|
|
13
|
-
const getTargetBranchesFromLabels_1 = require("./getTargetBranchesFromLabels");
|
|
14
|
-
async function fetchCommitByPullNumber(options) {
|
|
15
|
-
const { accessToken, githubApiBaseUrlV4, pullNumber, repoName, repoOwner } = options;
|
|
16
|
-
const query = /* GraphQL */ `
|
|
17
|
-
query CommitByPullNumber(
|
|
18
|
-
$repoOwner: String!
|
|
19
|
-
$repoName: String!
|
|
20
|
-
$pullNumber: Int!
|
|
21
|
-
) {
|
|
22
|
-
repository(owner: $repoOwner, name: $repoName) {
|
|
23
|
-
pullRequest(number: $pullNumber) {
|
|
24
|
-
...${getExistingTargetPullRequests_1.pullRequestFragment.name}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
${getExistingTargetPullRequests_1.pullRequestFragment.source}
|
|
30
|
-
`;
|
|
31
|
-
const spinner = (0, ora_1.default)(`Loading merge commit from pull request #${options.pullNumber}`).start();
|
|
32
|
-
let res;
|
|
33
|
-
try {
|
|
34
|
-
res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
35
|
-
githubApiBaseUrlV4,
|
|
36
|
-
accessToken,
|
|
37
|
-
query,
|
|
38
|
-
variables: {
|
|
39
|
-
repoOwner,
|
|
40
|
-
repoName,
|
|
41
|
-
pullNumber,
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
spinner.stop();
|
|
45
|
-
}
|
|
46
|
-
catch (e) {
|
|
47
|
-
spinner.fail();
|
|
48
|
-
throw e;
|
|
49
|
-
}
|
|
50
|
-
const pullRequestNode = res.repository.pullRequest;
|
|
51
|
-
if (pullRequestNode.mergeCommit === null) {
|
|
52
|
-
throw new HandledError_1.HandledError(`The PR #${pullNumber} is not merged`);
|
|
53
|
-
}
|
|
54
|
-
const committedDate = pullRequestNode.mergeCommit.committedDate;
|
|
55
|
-
const sourceBranch = pullRequestNode.baseRefName;
|
|
56
|
-
const sha = pullRequestNode.mergeCommit.oid;
|
|
57
|
-
const commitMessage = pullRequestNode.mergeCommit.message;
|
|
58
|
-
const formattedMessage = (0, commitFormatters_1.getFormattedCommitMessage)({
|
|
59
|
-
message: commitMessage,
|
|
60
|
-
sha,
|
|
61
|
-
pullNumber,
|
|
62
|
-
});
|
|
63
|
-
// add styles to make it look like a prompt question
|
|
64
|
-
spinner.stopAndPersist({
|
|
65
|
-
symbol: chalk_1.default.green('?'),
|
|
66
|
-
text: `${chalk_1.default.bold('Select pull request')} ${chalk_1.default.cyan(formattedMessage)}`,
|
|
67
|
-
});
|
|
68
|
-
const existingTargetPullRequests = (0, getExistingTargetPullRequests_1.getExistingTargetPullRequests)(pullRequestNode);
|
|
69
|
-
const targetBranchesFromLabels = (0, getTargetBranchesFromLabels_1.getTargetBranchesFromLabels)({
|
|
70
|
-
sourceBranch: pullRequestNode.baseRefName,
|
|
71
|
-
existingTargetPullRequests,
|
|
72
|
-
branchLabelMapping: options.branchLabelMapping,
|
|
73
|
-
labels: (0, getExistingTargetPullRequests_1.getPullRequestLabels)(pullRequestNode),
|
|
74
|
-
});
|
|
75
|
-
return {
|
|
76
|
-
committedDate,
|
|
77
|
-
sourceBranch,
|
|
78
|
-
targetBranchesFromLabels,
|
|
79
|
-
sha,
|
|
80
|
-
formattedMessage,
|
|
81
|
-
originalMessage: commitMessage,
|
|
82
|
-
pullNumber,
|
|
83
|
-
existingTargetPullRequests,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
exports.fetchCommitByPullNumber = fetchCommitByPullNumber;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
4
|
-
const fetchCommitByPullNumber_1 = require("./fetchCommitByPullNumber");
|
|
5
|
-
describe('fetchCommitByPullNumber', () => {
|
|
6
|
-
let devAccessToken;
|
|
7
|
-
beforeAll(async () => {
|
|
8
|
-
devAccessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
|
-
});
|
|
10
|
-
describe('when PR was merged', () => {
|
|
11
|
-
it('is returned', async () => {
|
|
12
|
-
const options = {
|
|
13
|
-
accessToken: devAccessToken,
|
|
14
|
-
githubApiBaseUrlV4: 'https://api.github.com/graphql',
|
|
15
|
-
pullNumber: 5,
|
|
16
|
-
repoName: 'backport-e2e',
|
|
17
|
-
repoOwner: 'backport-org',
|
|
18
|
-
};
|
|
19
|
-
expect(await (0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)(options)).toEqual({
|
|
20
|
-
formattedMessage: 'Add 🍏 emoji (#5)',
|
|
21
|
-
originalMessage: 'Add 🍏 emoji (#5)',
|
|
22
|
-
pullNumber: 5,
|
|
23
|
-
sha: 'ee8c492334cef1ca077a56addb79a26f79821d2f',
|
|
24
|
-
sourceBranch: 'master',
|
|
25
|
-
targetBranchesFromLabels: [],
|
|
26
|
-
existingTargetPullRequests: [
|
|
27
|
-
{ branch: '7.x', state: 'MERGED', number: 6 },
|
|
28
|
-
{ branch: '7.8', state: 'MERGED', number: 7 },
|
|
29
|
-
],
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
describe('when PR is still open', () => {
|
|
34
|
-
it('throws an error', async () => {
|
|
35
|
-
const options = {
|
|
36
|
-
accessToken: devAccessToken,
|
|
37
|
-
githubApiBaseUrlV4: 'https://api.github.com/graphql',
|
|
38
|
-
pullNumber: 11,
|
|
39
|
-
repoName: 'backport-e2e',
|
|
40
|
-
repoOwner: 'backport-org',
|
|
41
|
-
};
|
|
42
|
-
await expect((0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)(options)).rejects.toThrowError(`The PR #11 is not merged`);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
describe('when PR does not exist', () => {
|
|
46
|
-
it('throws an error', async () => {
|
|
47
|
-
const options = {
|
|
48
|
-
accessToken: devAccessToken,
|
|
49
|
-
githubApiBaseUrlV4: 'https://api.github.com/graphql',
|
|
50
|
-
pullNumber: 9999999999999,
|
|
51
|
-
repoName: 'backport-e2e',
|
|
52
|
-
repoOwner: 'backport-org',
|
|
53
|
-
};
|
|
54
|
-
await expect((0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)(options)).rejects.toThrowError(`Could not resolve to a PullRequest with the number of 9999999999999. (Unhandled Github v4 error)`);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|