backport 6.2.1 → 6.3.0-beta-4
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 +13 -5
- package/dist/backportRun.d.ts +2 -2
- package/dist/backportRun.js +13 -8
- package/dist/{entrypoint.api.private.test.d.ts → entrypoint.cli.e2e.private.test.d.ts} +0 -0
- package/dist/entrypoint.cli.e2e.private.test.js +278 -0
- package/dist/{entrypoint.module.private.test.d.ts → entrypoint.cli.private.test.d.ts} +0 -0
- package/dist/{entrypoint.module.private.test.js → entrypoint.cli.private.test.js} +17 -8
- package/dist/entrypoint.module.js +1 -1
- package/dist/options/ConfigOptions.d.ts +5 -2
- package/dist/options/cliArgs.d.ts +1 -0
- package/dist/options/cliArgs.js +27 -6
- package/dist/options/cliArgs.test.js +28 -10
- package/dist/options/config/config.d.ts +4 -7
- package/dist/options/config/config.js +2 -7
- package/dist/options/config/config.test.js +5 -21
- package/dist/options/config/globalConfig.js +3 -3
- package/dist/options/config/globalConfig.test.js +10 -29
- package/dist/options/config/projectConfig.test.js +7 -26
- package/dist/options/config/readConfigFile.d.ts +4 -7
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +6 -34
- package/dist/options/options.js +37 -29
- package/dist/options/options.test.js +53 -22
- package/dist/runSequentially.d.ts +0 -1
- package/dist/runSequentially.js +1 -1
- package/dist/runSequentially.test.js +35 -12
- 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.test.js +2 -2
- package/dist/services/git.d.ts +22 -9
- package/dist/services/git.integration.test.js +123 -24
- package/dist/services/git.js +66 -54
- package/dist/services/git.test.js +35 -20
- package/dist/services/github/commitFormatters.d.ts +0 -1
- package/dist/services/github/commitFormatters.js +1 -8
- package/dist/services/github/v3/createPullRequest.js +8 -5
- package/dist/services/github/v3/createPullRequest.test.js +204 -39
- package/dist/services/github/v3/createStatusComment.js +26 -15
- package/dist/services/github/v3/createStatusComment.test.js +132 -72
- package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +2 -1
- package/dist/{options/getValidatedOptions.test.d.ts → services/github/v3/index.d.ts} +0 -0
- package/dist/services/github/v3/index.js +61 -0
- 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 +46 -28
- package/dist/services/github/v4/apiRequestV4.test.js +4 -4
- package/dist/services/github/v4/disablePullRequestAutoMerge.d.ts +0 -7
- package/dist/services/github/v4/enablePullRequestAutoMerge.d.ts +0 -7
- package/dist/services/github/v4/fetchAuthorId.private.test.js +2 -2
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +38 -20
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +19 -10
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +25 -16
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +6 -6
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +41 -19
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.d.ts +1 -8
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +33 -16
- package/dist/services/github/v4/fetchExistingPullRequest.d.ts +0 -4
- package/dist/services/github/v4/fetchExistingPullRequest.js +1 -2
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +2 -2
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.d.ts +0 -9
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +2 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +6 -8
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +49 -41
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +7 -1
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +15 -23
- package/dist/services/github/v4/getOptionsFromGithub/query.js +17 -25
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +56 -0
- package/dist/{options/parseRequiredOptions.test.d.ts → services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts} +0 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +71 -0
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +11 -11
- package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +4 -5
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -7
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +5 -5
- package/dist/services/logger.d.ts +9 -18
- package/dist/services/logger.js +20 -56
- package/dist/services/prompt.test.js +66 -19
- package/dist/services/prompts.js +12 -10
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +1 -1
- package/dist/services/sourceCommit/getMockSourceCommit.js +6 -6
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +18 -10
- package/dist/services/sourceCommit/parseSourceCommit.js +20 -14
- package/dist/services/sourceCommit/parseSourceCommit.test.js +18 -20
- package/dist/{runWithOptions.test.d.ts → test/backport-e2e.mutation.test.d.ts} +0 -0
- package/dist/test/{backport-e2e.private.test.js → backport-e2e.mutation.test.js} +134 -112
- package/dist/test/handleUnbackportedPullRequests.private.test.js +26 -12
- package/dist/test/mockConfigFiles.js +4 -20
- package/dist/test/mocks.d.ts +10 -0
- package/dist/test/mocks.js +23 -0
- package/dist/test/private/getDevAccessToken.d.ts +2 -1
- package/dist/test/private/getDevAccessToken.js +6 -18
- package/dist/test/sandbox.d.ts +5 -0
- package/dist/{react-components/0-loadOptions.js → test/sandbox.js} +18 -20
- package/dist/test/setupFiles/automatic-mocks.d.ts +1 -0
- package/dist/test/setupFiles/automatic-mocks.js +27 -11
- package/dist/ui/cherrypickAndCreateTargetPullRequest.d.ts +0 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +12 -13
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +47 -19
- package/dist/ui/getCommits.js +8 -14
- package/dist/ui/getCommitsWithoutBackports.js +6 -6
- package/dist/ui/getCommitsWithoutBackports.test.js +91 -39
- package/dist/ui/getTargetBranches.js +1 -1
- package/dist/ui/getTargetBranches.test.js +26 -8
- package/dist/ui/maybeSetupRepo.js +25 -5
- package/dist/ui/maybeSetupRepo.test.js +144 -18
- package/dist/utils/maybe.d.ts +1 -0
- package/dist/utils/maybe.js +7 -0
- package/dist/utils/packageVersion.d.ts +1 -0
- package/dist/{types/PromiseReturnType.js → utils/packageVersion.js} +2 -0
- package/package.json +24 -19
- package/yarn.lock +119 -147
- package/dist/entrypoint.api.d.ts +0 -22
- package/dist/entrypoint.api.js +0 -57
- package/dist/entrypoint.api.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/main.d.ts +0 -14
- package/dist/main.js +0 -68
- package/dist/options/config/getOptionsFromGit.d.ts +0 -4
- package/dist/options/config/getOptionsFromGit.js +0 -8
- package/dist/options/config/getProjectConfig.d.ts +0 -0
- package/dist/options/config/getProjectConfig.js +0 -1
- package/dist/options/getValidatedOptions.d.ts +0 -49
- package/dist/options/getValidatedOptions.js +0 -45
- package/dist/options/getValidatedOptions.test.js +0 -97
- package/dist/options/parseRequiredOptions.d.ts +0 -71
- package/dist/options/parseRequiredOptions.js +0 -68
- package/dist/options/parseRequiredOptions.test.js +0 -122
- package/dist/react-components/0-loadOptions.d.ts +0 -6
- package/dist/react-components/1-loadCommit.d.ts +0 -8
- package/dist/react-components/1-loadCommit.js +0 -88
- package/dist/react-components/1a-loadCommit.d.ts +0 -5
- package/dist/react-components/1a-loadCommit.js +0 -76
- package/dist/react-components/1b-commitChoices.d.ts +0 -5
- package/dist/react-components/1b-commitChoices.js +0 -98
- package/dist/react-components/2-commitChoices.d.ts +0 -8
- package/dist/react-components/2-commitChoices.js +0 -96
- package/dist/react-components/2-commitsPrompt.d.ts +0 -8
- package/dist/react-components/2-commitsPrompt.js +0 -96
- package/dist/react-components/2-targetBranchChoices.d.ts +0 -9
- package/dist/react-components/2-targetBranchChoices.js +0 -109
- package/dist/react-components/3-cherrypick.d.ts +0 -1
- package/dist/react-components/3-cherrypick.js +0 -2
- package/dist/react-components/App.d.ts +0 -2
- package/dist/react-components/App.js +0 -35
- package/dist/react-components/BackportStateContext.d.ts +0 -33
- package/dist/react-components/BackportStateContext.js +0 -42
- package/dist/react-components/CommitPrompt/2-commitsPrompt.d.ts +0 -8
- package/dist/react-components/CommitPrompt/2-commitsPrompt.js +0 -96
- package/dist/react-components/CommitPrompt/CommitPrompt.d.ts +0 -8
- package/dist/react-components/CommitPrompt/CommitPrompt.js +0 -96
- package/dist/react-components/CommitPrompt/getCommits.d.ts +0 -2
- package/dist/react-components/CommitPrompt/getCommits.js +0 -27
- package/dist/react-components/CommitPrompt.d.ts +0 -8
- package/dist/react-components/CommitPrompt.js +0 -96
- package/dist/react-components/CustomMultiSelect.d.ts +0 -13
- package/dist/react-components/CustomMultiSelect.js +0 -21
- package/dist/react-components/CustomMultiSelectItem.d.ts +0 -5
- package/dist/react-components/CustomMultiSelectItem.js +0 -12
- package/dist/react-components/CustomSelect.d.ts +0 -14
- package/dist/react-components/CustomSelect.js +0 -34
- package/dist/react-components/ErrorBoundary.d.ts +0 -15
- package/dist/react-components/ErrorBoundary.js +0 -53
- package/dist/react-components/MultiSelect.d.ts +0 -7
- package/dist/react-components/MultiSelect.js +0 -16
- package/dist/react-components/hooks/useAsync.d.ts +0 -12
- package/dist/react-components/hooks/useAsync.js +0 -73
- package/dist/runWithOptions.d.ts +0 -9
- package/dist/runWithOptions.js +0 -43
- package/dist/runWithOptions.test.js +0 -304
- package/dist/scripts/generate-gql.d.ts +0 -1
- package/dist/scripts/generate-gql.js +0 -15
- package/dist/services/backportRun/backportRun.ci.d.ts +0 -6
- package/dist/services/backportRun/backportRun.ci.js +0 -81
- package/dist/services/backportRun/backportRun.d.ts +0 -14
- package/dist/services/backportRun/backportRun.interactive.d.ts +0 -1
- package/dist/services/backportRun/backportRun.interactive.js +0 -4
- package/dist/services/backportRun/backportRun.js +0 -14
- package/dist/services/backportRun/backportState.d.ts +0 -4
- package/dist/services/backportRun/backportState.js +0 -28
- package/dist/services/backportRun/getCommits.d.ts +0 -2
- package/dist/services/backportRun/getCommits.js +0 -20
- package/dist/services/backportRun/runSequentially.d.ts +0 -20
- package/dist/services/backportRun/runSequentially.js +0 -41
- package/dist/services/backportRun/runSequentially.test.d.ts +0 -1
- package/dist/services/backportRun/runSequentially.test.js +0 -199
- package/dist/services/cherrypickAndCreateTargetPullRequest.d.ts +0 -12
- package/dist/services/cherrypickAndCreateTargetPullRequest.js +0 -206
- package/dist/services/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
- package/dist/services/cherrypickAndCreateTargetPullRequest.test.js +0 -403
- package/dist/services/fs-promisified.d.ts +0 -6
- package/dist/services/fs-promisified.js +0 -12
- package/dist/services/getCommits.d.ts +0 -2
- package/dist/services/getCommits.js +0 -38
- package/dist/services/getCommitsWithoutBackports.d.ts +0 -11
- package/dist/services/getCommitsWithoutBackports.js +0 -68
- package/dist/services/getCommitsWithoutBackports.test.d.ts +0 -1
- package/dist/services/getCommitsWithoutBackports.test.js +0 -259
- 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/getTargetBranches.d.ts +0 -5
- package/dist/services/getTargetBranches.js +0 -60
- package/dist/services/getTargetBranches.test.d.ts +0 -1
- package/dist/services/getTargetBranches.test.js +0 -180
- package/dist/services/github/v4/fetchCommitByPullNumber.d.ts +0 -5
- package/dist/services/github/v4/fetchCommitByPullNumber.js +0 -86
- package/dist/services/github/v4/fetchCommitByPullNumber.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitByPullNumber.private.test.js +0 -57
- package/dist/services/github/v4/fetchCommitBySha.d.ts +0 -5
- package/dist/services/github/v4/fetchCommitBySha.js +0 -95
- package/dist/services/github/v4/fetchCommitBySha.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitBySha.private.test.js +0 -50
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.d.ts +0 -28
- package/dist/services/github/v4/fetchCommits/fetchCommitsInDateRange.js +0 -52
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.d.ts +0 -3
- package/dist/services/github/v4/fetchCommits/fetchProjectConfig.js +0 -55
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.test.js +0 -252
- package/dist/services/github/v4/fetchCommitsByAuthor.d.ts +0 -28
- package/dist/services/github/v4/fetchCommitsByAuthor.js +0 -161
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitsByAuthor.private.test.js +0 -115
- package/dist/services/github/v4/fetchCommitsByAuthor.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommitsByAuthor.test.js +0 -272
- package/dist/services/github/v4/fetchDefaultBranch.d.ts +0 -9
- package/dist/services/github/v4/fetchDefaultBranch.js +0 -24
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +0 -4
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.js +0 -52
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +0 -32
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.d.ts +0 -4
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.js +0 -72
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/index.private.test.js +0 -34
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.d.ts +0 -40
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks/query.js +0 -72
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.d.ts +0 -17
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.js +0 -69
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchDefaultRepoBranchAndPerformStartupChecks.private.test.js +0 -32
- package/dist/services/github/v4/fetchMergedPullRequests.d.ts +0 -37
- package/dist/services/github/v4/fetchMergedPullRequests.js +0 -37
- package/dist/services/github/v4/fetchMergedPullRequests.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchMergedPullRequests.private.test.js +0 -59
- package/dist/services/github/v4/fetchMergedPullRequests.test.d.ts +0 -1
- package/dist/services/github/v4/fetchMergedPullRequests.test.js +0 -22
- package/dist/services/github/v4/fetchProjectConfig.d.ts +0 -8
- package/dist/services/github/v4/fetchProjectConfig.js +0 -56
- package/dist/services/github/v4/fetchProjectConfig.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchProjectConfig.private.test.js +0 -52
- package/dist/services/github/v4/fetchProjectConfig.test.d.ts +0 -1
- package/dist/services/github/v4/fetchProjectConfig.test.js +0 -37
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.d.ts +0 -9
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.js +0 -92
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.private.test.js +0 -66
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.d.ts +0 -1
- package/dist/services/github/v4/fetchPullRequestBySearchQuery.test.js +0 -242
- package/dist/services/github/v4/getExistingTargetPullRequests.d.ts +0 -7
- package/dist/services/github/v4/getExistingTargetPullRequests.js +0 -45
- package/dist/services/github/v4/getOptionsFromGithub/index.d.ts +0 -63
- package/dist/services/github/v4/getOptionsFromGithub/index.js +0 -139
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.d.ts +0 -1
- package/dist/services/github/v4/getOptionsFromGithub/index.private.test.js +0 -147
- package/dist/services/github/v4/getTargetBranchesFromLabels.d.ts +0 -5
- package/dist/services/github/v4/getTargetBranchesFromLabels.js +0 -20
- package/dist/services/github/v4/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/services/github/v4/getTargetBranchesFromLabels.test.js +0 -201
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/fetchPullRequestBySearchQueryMock.js +0 -843
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/getCommitsByAuthorMock.js +0 -73
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.d.ts +0 -12
- package/dist/services/github/v4/mocks/getPullRequestNodeMock.js +0 -44
- package/dist/services/maybeSetupRepo.d.ts +0 -2
- package/dist/services/maybeSetupRepo.js +0 -33
- package/dist/services/maybeSetupRepo.test.d.ts +0 -1
- package/dist/services/maybeSetupRepo.test.js +0 -78
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.d.ts +0 -5
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.js +0 -20
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/services/sourceCommit/getTargetBranchesFromLabels.test.js +0 -201
- package/dist/services/sourceCommit/sourceCommit.d.ts +0 -78
- package/dist/services/sourceCommit/sourceCommit.js +0 -86
- package/dist/services/sourceCommit/sourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit/sourceCommit.test.js +0 -287
- package/dist/services/sourceCommit.d.ts +0 -78
- package/dist/services/sourceCommit.js +0 -86
- package/dist/services/sourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit.test.js +0 -280
- package/dist/test/backport-e2e.private.test.d.ts +0 -1
- package/dist/test/inquirer.private.test.d.ts +0 -1
- package/dist/test/inquirer.private.test.js +0 -170
- 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/todo-delete.d.ts +0 -1
- package/dist/todo-delete.js +0 -17
- package/dist/types/Commit.d.ts +0 -85
- package/dist/types/Commit.js +0 -139
- package/dist/types/PromiseReturnType.d.ts +0 -1
- package/dist/types/commitNode.d.ts +0 -89
- package/dist/types/commitNode.js +0 -139
- package/dist/types/commitNode.test.d.ts +0 -1
- package/dist/types/commitNode.test.js +0 -255
- package/dist/types/commitWithAssociatedPullRequests.d.ts +0 -86
- package/dist/types/commitWithAssociatedPullRequests.js +0 -145
- package/dist/ui/cherrypickAndCreatePullRequest.test.d.ts +0 -1
- package/dist/ui/cherrypickAndCreatePullRequest.test.js +0 -617
- package/dist/ui/getTargetBranchesFromLabels.d.ts +0 -6
- package/dist/ui/getTargetBranchesFromLabels.js +0 -40
- package/dist/ui/getTargetBranchesFromLabels.test.d.ts +0 -1
- package/dist/ui/getTargetBranchesFromLabels.test.js +0 -288
- package/dist/utils/sequentially.d.ts +0 -1
- package/dist/utils/sequentially.js +0 -10
|
@@ -27,9 +27,9 @@ describe('createStatusComment', () => {
|
|
|
27
27
|
ci: true,
|
|
28
28
|
},
|
|
29
29
|
backportResponse: {
|
|
30
|
-
commits: [{
|
|
30
|
+
commits: [{ sourcePullRequest: { number: 100 } }],
|
|
31
31
|
status: 'failure',
|
|
32
|
-
|
|
32
|
+
error: new Error(`Error message containing very secret access token: ${accessToken}.`),
|
|
33
33
|
},
|
|
34
34
|
});
|
|
35
35
|
expect(postedCommentBody).toContain('Error message containing very secret access token: <REDACTED>');
|
|
@@ -47,25 +47,26 @@ describe('getCommentBody', () => {
|
|
|
47
47
|
pullNumber: 55,
|
|
48
48
|
backportResponse: {
|
|
49
49
|
status: 'failure',
|
|
50
|
-
|
|
50
|
+
error: new Error('A terrible error occured'),
|
|
51
51
|
},
|
|
52
52
|
});
|
|
53
53
|
it('posts a comment when running on ci', () => {
|
|
54
54
|
const params = getParams({ ci: true });
|
|
55
55
|
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
"## 💔 Backport failed
|
|
57
|
+
The pull request could not be backported due to the following error:
|
|
58
|
+
\`A terrible error occured\`
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
### Manual backport
|
|
61
|
+
To create the backport manually run:
|
|
62
|
+
\`\`\`
|
|
63
|
+
node scripts/backport --pr 55
|
|
64
|
+
\`\`\`
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
### Questions ?
|
|
67
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
68
|
+
<!--- Backport version: 1.2.3 -->"
|
|
69
|
+
`);
|
|
69
70
|
});
|
|
70
71
|
it('does not post a comment when running manually', () => {
|
|
71
72
|
const params = getParams({ ci: false });
|
|
@@ -102,34 +103,36 @@ describe('getCommentBody', () => {
|
|
|
102
103
|
it('posts a comment on ci', () => {
|
|
103
104
|
const params = getParams({ ci: true });
|
|
104
105
|
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
105
|
-
|
|
106
|
+
"## 💚 All backports created successfully
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
| Status | Branch | Result |
|
|
109
|
+
|:------:|:------:|:------|
|
|
110
|
+
|✅|7.x|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/55\\">](url-to-pr)|
|
|
111
|
+
|✅|7.1|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/66\\">](url-to-pr)|
|
|
111
112
|
|
|
112
|
-
|
|
113
|
+
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
113
114
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
### Questions ?
|
|
116
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
117
|
+
<!--- Backport version: 1.2.3 -->"
|
|
118
|
+
`);
|
|
117
119
|
});
|
|
118
120
|
it('posts a comment when running locally', () => {
|
|
119
121
|
const params = getParams({ ci: false });
|
|
120
122
|
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
121
|
-
|
|
123
|
+
"## 💚 All backports created successfully
|
|
122
124
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
| Status | Branch | Result |
|
|
126
|
+
|:------:|:------:|:------|
|
|
127
|
+
|✅|7.x|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/55\\">](url-to-pr)|
|
|
128
|
+
|✅|7.1|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/66\\">](url-to-pr)|
|
|
127
129
|
|
|
128
|
-
|
|
130
|
+
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
129
131
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
132
|
+
### Questions ?
|
|
133
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
134
|
+
<!--- Backport version: 1.2.3 -->"
|
|
135
|
+
`);
|
|
133
136
|
});
|
|
134
137
|
});
|
|
135
138
|
describe('when all backports fail', () => {
|
|
@@ -148,14 +151,12 @@ describe('getCommentBody', () => {
|
|
|
148
151
|
{
|
|
149
152
|
status: 'failure',
|
|
150
153
|
targetBranch: '7.x',
|
|
151
|
-
error: new Error('
|
|
152
|
-
errorMessage: 'My boom error!',
|
|
154
|
+
error: new Error('My boom error!'),
|
|
153
155
|
},
|
|
154
156
|
{
|
|
155
157
|
status: 'failure',
|
|
156
158
|
targetBranch: '7.1',
|
|
157
|
-
error: new Error('
|
|
158
|
-
errorMessage: 'My boom error!',
|
|
159
|
+
error: new Error('My boom error!'),
|
|
159
160
|
},
|
|
160
161
|
],
|
|
161
162
|
},
|
|
@@ -170,14 +171,15 @@ describe('getCommentBody', () => {
|
|
|
170
171
|
|❌|7.x|My boom error!|
|
|
171
172
|
|❌|7.1|My boom error!|
|
|
172
173
|
|
|
173
|
-
###
|
|
174
|
-
|
|
174
|
+
### Manual backport
|
|
175
|
+
To create the backport manually run:
|
|
175
176
|
\`\`\`
|
|
176
177
|
node scripts/backport --pr 55
|
|
177
178
|
\`\`\`
|
|
178
179
|
|
|
179
180
|
### Questions ?
|
|
180
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
181
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
182
|
+
<!--- Backport version: 1.2.3 -->"
|
|
181
183
|
`);
|
|
182
184
|
});
|
|
183
185
|
it('does not post a comment when running manaully', () => {
|
|
@@ -207,8 +209,7 @@ describe('getCommentBody', () => {
|
|
|
207
209
|
{
|
|
208
210
|
status: 'failure',
|
|
209
211
|
targetBranch: '7.1',
|
|
210
|
-
error: new Error('
|
|
211
|
-
errorMessage: 'My boom error!',
|
|
212
|
+
error: new Error('My boom error!'),
|
|
212
213
|
},
|
|
213
214
|
],
|
|
214
215
|
},
|
|
@@ -216,23 +217,24 @@ describe('getCommentBody', () => {
|
|
|
216
217
|
it('post a comment when running on CI', () => {
|
|
217
218
|
const params = getParams({ ci: true });
|
|
218
219
|
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
219
|
-
|
|
220
|
+
"## 💔 Some backports could not be created
|
|
220
221
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
222
|
+
| Status | Branch | Result |
|
|
223
|
+
|:------:|:------:|:------|
|
|
224
|
+
|✅|7.x|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/55\\">](url-to-pr-55)|
|
|
225
|
+
|❌|7.1|My boom error!|
|
|
225
226
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
227
|
+
### Manual backport
|
|
228
|
+
To create the backport manually run:
|
|
229
|
+
\`\`\`
|
|
230
|
+
node scripts/backport --pr 55
|
|
231
|
+
\`\`\`
|
|
232
|
+
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
232
233
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
### Questions ?
|
|
235
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
236
|
+
<!--- Backport version: 1.2.3 -->"
|
|
237
|
+
`);
|
|
236
238
|
});
|
|
237
239
|
it('does not post a comment when running manually because some backports failed', () => {
|
|
238
240
|
const params = getParams({ ci: false });
|
|
@@ -261,24 +263,45 @@ describe('getCommentBody', () => {
|
|
|
261
263
|
{
|
|
262
264
|
status: 'failure',
|
|
263
265
|
targetBranch: '7.1',
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
type: 'merge-conflict-due-to-missing-backports',
|
|
266
|
+
error: new HandledError_1.HandledError({
|
|
267
|
+
code: 'merge-conflict-exception',
|
|
267
268
|
commitsWithoutBackports: [
|
|
269
|
+
//@ts-expect-error
|
|
268
270
|
{
|
|
269
|
-
//@ts-expect-error
|
|
270
271
|
commit: {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
272
|
+
sourceBranch: 'master',
|
|
273
|
+
sourcePullRequest: {
|
|
274
|
+
number: 5,
|
|
275
|
+
url: 'url-to-pr-5',
|
|
276
|
+
mergeCommit: {
|
|
277
|
+
sha: '',
|
|
278
|
+
message: 'New Zealand commit message',
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
sourceCommit: {
|
|
282
|
+
committedDate: '',
|
|
283
|
+
sha: '',
|
|
284
|
+
message: 'New Zealand commit message',
|
|
285
|
+
},
|
|
286
|
+
expectedTargetPullRequests: [],
|
|
274
287
|
},
|
|
275
288
|
},
|
|
276
289
|
{
|
|
277
290
|
//@ts-expect-error
|
|
278
291
|
commit: {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
292
|
+
sourcePullRequest: {
|
|
293
|
+
number: 44,
|
|
294
|
+
url: 'url-to-pr-44',
|
|
295
|
+
mergeCommit: {
|
|
296
|
+
sha: '',
|
|
297
|
+
message: 'Australia commit',
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
sourceCommit: {
|
|
301
|
+
committedDate: '',
|
|
302
|
+
sha: '',
|
|
303
|
+
message: 'Australia commit',
|
|
304
|
+
},
|
|
282
305
|
},
|
|
283
306
|
},
|
|
284
307
|
],
|
|
@@ -287,9 +310,8 @@ describe('getCommentBody', () => {
|
|
|
287
310
|
{
|
|
288
311
|
status: 'failure',
|
|
289
312
|
targetBranch: '7.2',
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
type: 'merge-conflict-due-to-missing-backports',
|
|
313
|
+
error: new HandledError_1.HandledError({
|
|
314
|
+
code: 'merge-conflict-exception',
|
|
293
315
|
commitsWithoutBackports: [],
|
|
294
316
|
}),
|
|
295
317
|
},
|
|
@@ -307,20 +329,58 @@ describe('getCommentBody', () => {
|
|
|
307
329
|
|❌|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)|
|
|
308
330
|
|❌|7.2|**Backport failed because of merge conflicts**|
|
|
309
331
|
|
|
310
|
-
###
|
|
311
|
-
|
|
332
|
+
### Manual backport
|
|
333
|
+
To create the backport manually run:
|
|
312
334
|
\`\`\`
|
|
313
335
|
node scripts/backport --pr 55
|
|
314
336
|
\`\`\`
|
|
315
337
|
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
316
338
|
|
|
317
339
|
### Questions ?
|
|
318
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
340
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
341
|
+
<!--- Backport version: 1.2.3 -->"
|
|
319
342
|
`);
|
|
320
343
|
});
|
|
321
344
|
it('does not post a comment when running manually because some backports failed', () => {
|
|
322
345
|
const params = getParams({ ci: false });
|
|
323
|
-
expect((0, createStatusComment_1.getCommentBody)(params)).
|
|
346
|
+
expect((0, createStatusComment_1.getCommentBody)(params)).toBe(undefined);
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
describe('when all backports fail due to missing branches', () => {
|
|
350
|
+
const getParams = (opts) => ({
|
|
351
|
+
options: {
|
|
352
|
+
repoName: 'kibana',
|
|
353
|
+
repoOwner: 'elastic',
|
|
354
|
+
autoMerge: true,
|
|
355
|
+
backportBinary: 'node scripts/backport',
|
|
356
|
+
...opts,
|
|
357
|
+
},
|
|
358
|
+
pullNumber: 55,
|
|
359
|
+
backportResponse: {
|
|
360
|
+
status: 'failure',
|
|
361
|
+
error: new HandledError_1.HandledError({ code: 'no-branches-exception' }),
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
it('posts a comment when running on CI', () => {
|
|
365
|
+
const params = getParams({ ci: true });
|
|
366
|
+
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
367
|
+
"## ⚪ Backport skipped
|
|
368
|
+
The pull request was not backported as there were no branches to backport to. If this is a mistake, please apply the desired version labels or run the backport tool manually.
|
|
369
|
+
|
|
370
|
+
### Manual backport
|
|
371
|
+
To create the backport manually run:
|
|
372
|
+
\`\`\`
|
|
373
|
+
node scripts/backport --pr 55
|
|
374
|
+
\`\`\`
|
|
375
|
+
|
|
376
|
+
### Questions ?
|
|
377
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
378
|
+
<!--- Backport version: 1.2.3 -->"
|
|
379
|
+
`);
|
|
380
|
+
});
|
|
381
|
+
it('does not post a comment when running manually', () => {
|
|
382
|
+
const params = getParams({ ci: false });
|
|
383
|
+
expect((0, createStatusComment_1.getCommentBody)(params)).toBe(undefined);
|
|
324
384
|
});
|
|
325
385
|
});
|
|
326
386
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
declare type GithubV3Error = {
|
|
2
2
|
name: string;
|
|
3
3
|
status: number;
|
|
4
4
|
documentation_url: string;
|
|
@@ -11,3 +11,4 @@ export declare type GithubV3Error = {
|
|
|
11
11
|
}>;
|
|
12
12
|
};
|
|
13
13
|
export declare function getGithubV3ErrorMessage(e: GithubV3Error): string | undefined;
|
|
14
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
const core = __importStar(require("@actions/core"));
|
|
23
|
+
const exec_1 = require("@actions/exec");
|
|
24
|
+
const github_1 = require("@actions/github");
|
|
25
|
+
const backport_1 = require("backport");
|
|
26
|
+
async function init() {
|
|
27
|
+
const { payload, repo } = github_1.context;
|
|
28
|
+
if (!payload.pull_request) {
|
|
29
|
+
throw Error('Only pull_request events are supported.');
|
|
30
|
+
}
|
|
31
|
+
const pullRequest = payload.pull_request;
|
|
32
|
+
const prAuthor = pullRequest.user.login;
|
|
33
|
+
const accessToken = core.getInput('github_token', { required: true });
|
|
34
|
+
const commitUser = core.getInput('commit_user', { required: false });
|
|
35
|
+
const commitEmail = core.getInput('commit_email', { required: false });
|
|
36
|
+
const autoMerge = core.getInput('auto_merge', { required: false }) === 'true';
|
|
37
|
+
const autoMergeMethod = core.getInput('auto_merge_method', {
|
|
38
|
+
required: false,
|
|
39
|
+
});
|
|
40
|
+
const targetPRLabels = core
|
|
41
|
+
.getInput('target_pr_labels', { required: false })
|
|
42
|
+
.split(',')
|
|
43
|
+
.map((label) => label.trim());
|
|
44
|
+
await (0, exec_1.exec)(`git config --global user.name "${commitUser}"`);
|
|
45
|
+
await (0, exec_1.exec)(`git config --global user.email "${commitEmail}"`);
|
|
46
|
+
await (0, backport_1.backportRun)({
|
|
47
|
+
repoOwner: repo.owner,
|
|
48
|
+
repoName: repo.repo,
|
|
49
|
+
accessToken,
|
|
50
|
+
ci: true,
|
|
51
|
+
pullNumber: pullRequest.number,
|
|
52
|
+
targetPRLabels: targetPRLabels,
|
|
53
|
+
assignees: [prAuthor],
|
|
54
|
+
autoMerge: autoMerge,
|
|
55
|
+
autoMergeMethod: autoMergeMethod,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
init().catch((error) => {
|
|
59
|
+
console.error('An error occurred', error);
|
|
60
|
+
core.setFailed(error.message);
|
|
61
|
+
});
|
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
import { ValidConfigOptions } from '../../../options/options';
|
|
2
|
-
export interface PullRequestResponse {
|
|
3
|
-
repository: {
|
|
4
|
-
pullRequest: {
|
|
5
|
-
id: string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
2
|
export declare function fetchPullRequestId(options: ValidConfigOptions, pullNumber: number): Promise<string>;
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
interface GithubError {
|
|
3
|
+
type: string;
|
|
4
|
+
path: string[];
|
|
5
|
+
locations: {
|
|
6
|
+
line: number;
|
|
7
|
+
column: number;
|
|
8
|
+
}[];
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
3
11
|
export interface GithubV4Response<DataResponse> {
|
|
4
12
|
data: DataResponse;
|
|
5
|
-
errors?:
|
|
6
|
-
type: string;
|
|
7
|
-
path: string[];
|
|
8
|
-
locations: {
|
|
9
|
-
line: number;
|
|
10
|
-
column: number;
|
|
11
|
-
}[];
|
|
12
|
-
message: string;
|
|
13
|
-
}[];
|
|
13
|
+
errors?: GithubError[];
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
declare type Variables = Record<string, string | number | null>;
|
|
16
|
+
export declare function apiRequestV4<DataResponse>({ githubApiBaseUrlV4, accessToken, query, variables, }: {
|
|
16
17
|
githubApiBaseUrlV4?: string;
|
|
17
18
|
accessToken: string;
|
|
18
19
|
query: string;
|
|
19
|
-
variables?:
|
|
20
|
-
[key: string]: string | number | null;
|
|
21
|
-
};
|
|
22
|
-
handleError?: boolean;
|
|
20
|
+
variables?: Variables;
|
|
23
21
|
}): Promise<DataResponse>;
|
|
24
|
-
|
|
22
|
+
declare type AxiosGithubResponse<DataResponse> = AxiosResponse<GithubV4Response<DataResponse | null>, any>;
|
|
23
|
+
export declare class GithubV4Exception<DataResponse> extends Error {
|
|
24
|
+
message: string;
|
|
25
|
+
axiosResponse: AxiosGithubResponse<DataResponse>;
|
|
26
|
+
constructor(message: string, axiosResponse: AxiosGithubResponse<DataResponse>);
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -3,11 +3,12 @@ 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.GithubV4Exception = exports.apiRequestV4 = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
9
|
const HandledError_1 = require("../../HandledError");
|
|
9
10
|
const logger_1 = require("../../logger");
|
|
10
|
-
async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graphql', accessToken, query, variables,
|
|
11
|
+
async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graphql', accessToken, query, variables, }) {
|
|
11
12
|
try {
|
|
12
13
|
const response = await axios_1.default.post(githubApiBaseUrlV4, { query, variables }, {
|
|
13
14
|
headers: {
|
|
@@ -16,40 +17,57 @@ async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graph
|
|
|
16
17
|
},
|
|
17
18
|
});
|
|
18
19
|
if (response.data.errors) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
throw
|
|
20
|
+
const message = `${response.data.errors
|
|
21
|
+
.map((error) => error.message)
|
|
22
|
+
.join(',')} (Github API v4)`;
|
|
23
|
+
throw new GithubV4Exception(message, response);
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
addDebugLogs({
|
|
26
|
+
githubApiBaseUrlV4,
|
|
27
|
+
query,
|
|
28
|
+
variables,
|
|
29
|
+
axiosResponse: response,
|
|
30
|
+
didSucceed: false,
|
|
31
|
+
});
|
|
29
32
|
return response.data.data;
|
|
30
33
|
}
|
|
31
34
|
catch (e) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
if (axios_1.default.isAxiosError(e) && e.response) {
|
|
36
|
+
addDebugLogs({
|
|
37
|
+
githubApiBaseUrlV4,
|
|
38
|
+
query,
|
|
39
|
+
variables,
|
|
40
|
+
axiosResponse: e.response,
|
|
41
|
+
didSucceed: false,
|
|
42
|
+
});
|
|
43
|
+
throw new GithubV4Exception(`${e.message} (Unhandled Github API v4)`, e.response);
|
|
39
44
|
}
|
|
40
45
|
throw e;
|
|
41
46
|
}
|
|
42
47
|
}
|
|
43
48
|
exports.apiRequestV4 = apiRequestV4;
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
function addDebugLogs({ githubApiBaseUrlV4, query, variables, axiosResponse, didSucceed, }) {
|
|
50
|
+
const gqlQueryName = getGqlQueryName(query);
|
|
51
|
+
logger_1.logger.info(`POST ${githubApiBaseUrlV4} (name:${gqlQueryName}, status: ${axiosResponse.status})`);
|
|
52
|
+
const logMethod = didSucceed ? logger_1.logger.verbose : logger_1.logger.info;
|
|
53
|
+
logMethod(`Query name ${gqlQueryName}`);
|
|
54
|
+
logMethod(`Query: ${query}`);
|
|
55
|
+
logMethod('Variables:', variables);
|
|
56
|
+
logMethod('Response headers:', axiosResponse.headers);
|
|
57
|
+
logMethod('Response data:', axiosResponse.data);
|
|
58
|
+
}
|
|
59
|
+
class GithubV4Exception extends Error {
|
|
60
|
+
constructor(message, axiosResponse) {
|
|
61
|
+
super(message);
|
|
62
|
+
this.message = message;
|
|
63
|
+
this.axiosResponse = axiosResponse;
|
|
64
|
+
Error.captureStackTrace(this, HandledError_1.HandledError);
|
|
65
|
+
this.name = 'GithubV4Exception';
|
|
52
66
|
}
|
|
53
|
-
return new HandledError_1.HandledError(`Unexpected response from Github API (v4):\n${JSON.stringify(e.response.data, null, 2)}`);
|
|
54
67
|
}
|
|
55
|
-
exports.
|
|
68
|
+
exports.GithubV4Exception = GithubV4Exception;
|
|
69
|
+
function getGqlQueryName(query) {
|
|
70
|
+
const ast = (0, graphql_tag_1.default)(query);
|
|
71
|
+
//@ts-expect-error
|
|
72
|
+
return ast.definitions[0].name.value;
|
|
73
|
+
}
|
|
@@ -43,13 +43,13 @@ describe('apiRequestV4', () => {
|
|
|
43
43
|
beforeEach(() => {
|
|
44
44
|
(0, nockHelpers_1.mockGqlRequest)({
|
|
45
45
|
name: 'MyQuery',
|
|
46
|
-
statusCode:
|
|
46
|
+
statusCode: 200,
|
|
47
47
|
body: {
|
|
48
48
|
errors: [{ message: 'some error' }, { message: 'some other error' }],
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
-
it('should return
|
|
52
|
+
it('should return error containing the error messages', async () => {
|
|
53
53
|
return expect((0, apiRequestV4_1.apiRequestV4)({
|
|
54
54
|
accessToken: 'myAccessToken',
|
|
55
55
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
@@ -57,7 +57,7 @@ describe('apiRequestV4', () => {
|
|
|
57
57
|
variables: {
|
|
58
58
|
foo: 'bar',
|
|
59
59
|
},
|
|
60
|
-
})).rejects.toThrowError(new HandledError_1.HandledError(`some error,
|
|
60
|
+
})).rejects.toThrowError(new HandledError_1.HandledError(`some error,some other error (Github API v4)`));
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
63
|
describe('when request fails without error messages', () => {
|
|
@@ -76,7 +76,7 @@ describe('apiRequestV4', () => {
|
|
|
76
76
|
variables: {
|
|
77
77
|
foo: 'bar',
|
|
78
78
|
},
|
|
79
|
-
})).rejects.
|
|
79
|
+
})).rejects.toThrowError('Request failed with status code 500');
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
82
|
});
|
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
import { ValidConfigOptions } from '../../../options/options';
|
|
2
|
-
export interface PullRequestAutoMergeResponse {
|
|
3
|
-
disablePullRequestAutoMerge: {
|
|
4
|
-
pullRequest?: {
|
|
5
|
-
number: number;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
2
|
export declare function disablePullRequestAutoMerge(options: ValidConfigOptions, pullNumber: number): Promise<number | undefined>;
|
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
import { ValidConfigOptions } from '../../../options/options';
|
|
2
|
-
export interface PullRequestAutoMergeResponse {
|
|
3
|
-
enablePullRequestAutoMerge: {
|
|
4
|
-
pullRequest?: {
|
|
5
|
-
number: number;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
2
|
export declare function enablePullRequestAutoMerge(options: ValidConfigOptions, targetPullRequestNumber: number): Promise<number | undefined>;
|
|
@@ -4,8 +4,8 @@ const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
|
4
4
|
const fetchAuthorId_1 = require("./fetchAuthorId");
|
|
5
5
|
describe('fetchAuthorId', () => {
|
|
6
6
|
let devAccessToken;
|
|
7
|
-
beforeAll(
|
|
8
|
-
devAccessToken =
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
9
|
});
|
|
10
10
|
describe('author = null', () => {
|
|
11
11
|
it('returns null', async () => {
|