backport 6.2.0 → 6.3.0-beta-3
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 +15 -6
- 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 +277 -0
- package/dist/entrypoint.cli.js +3 -5
- 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.d.ts +2 -2
- package/dist/entrypoint.module.js +4 -4
- package/dist/options/ConfigOptions.d.ts +7 -3
- package/dist/options/cliArgs.d.ts +16 -14
- package/dist/options/cliArgs.js +31 -5
- package/dist/options/cliArgs.test.js +28 -10
- package/dist/options/config/config.d.ts +11 -11
- package/dist/options/config/config.js +7 -6
- package/dist/options/config/config.test.js +11 -1
- package/dist/options/config/globalConfig.d.ts +1 -1
- package/dist/options/config/globalConfig.js +15 -9
- package/dist/options/config/globalConfig.test.js +17 -30
- package/dist/options/config/projectConfig.d.ts +3 -1
- package/dist/options/config/projectConfig.js +5 -2
- package/dist/options/config/projectConfig.test.js +41 -31
- package/dist/options/config/readConfigFile.d.ts +21 -23
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +19 -46
- package/dist/options/options.js +40 -32
- package/dist/options/options.test.js +83 -50
- package/dist/runSequentially.d.ts +0 -1
- package/dist/runSequentially.js +1 -1
- package/dist/runSequentially.test.js +37 -18
- 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 +3 -1
- package/dist/services/env.js +4 -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 +16 -10
- package/dist/services/github/v3/createPullRequest.test.js +248 -33
- package/dist/services/github/v3/createStatusComment.d.ts +1 -1
- 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/fetchCommits/allFetchers.private.test.js +37 -19
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +17 -8
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +23 -14
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +4 -4
- 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 +31 -14
- 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/getOptionsFromGithub/getOptionsFromGithub.d.ts +7 -9
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +48 -40
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +6 -0
- 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 +11 -17
- package/dist/services/logger.js +29 -66
- 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} +136 -116
- 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.js +5 -4
- 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 +50 -27
- 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 +26 -21
- package/yarn.lock +165 -237
- 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 -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/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
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const prompts = __importStar(require("../services/prompts"));
|
|
23
|
-
const getTargetBranches_1 = require("./getTargetBranches");
|
|
24
|
-
describe('getTargetBranches', () => {
|
|
25
|
-
let promptSpy;
|
|
26
|
-
beforeEach(() => {
|
|
27
|
-
jest.clearAllMocks();
|
|
28
|
-
promptSpy = jest
|
|
29
|
-
.spyOn(prompts, 'promptForTargetBranches')
|
|
30
|
-
.mockResolvedValueOnce(['branchA']);
|
|
31
|
-
});
|
|
32
|
-
describe('when `options.targetBranches` is empty', () => {
|
|
33
|
-
let branches;
|
|
34
|
-
beforeEach(async () => {
|
|
35
|
-
const options = {
|
|
36
|
-
targetBranches: [],
|
|
37
|
-
targetBranchChoices: [{ name: 'branchA' }, { name: 'branchB' }],
|
|
38
|
-
multipleBranches: false,
|
|
39
|
-
};
|
|
40
|
-
const commits = [
|
|
41
|
-
{
|
|
42
|
-
committedDate: 'aaa',
|
|
43
|
-
originalMessage: 'hey',
|
|
44
|
-
sha: 'abcd',
|
|
45
|
-
sourceBranch: '7.x',
|
|
46
|
-
pullNumber: 1337,
|
|
47
|
-
expectedTargetPullRequests: [],
|
|
48
|
-
},
|
|
49
|
-
];
|
|
50
|
-
branches = await (0, getTargetBranches_1.getTargetBranches)(options, commits);
|
|
51
|
-
});
|
|
52
|
-
it('should return branches from prompt', () => {
|
|
53
|
-
expect(branches).toEqual(['branchA']);
|
|
54
|
-
});
|
|
55
|
-
it('should call prompt with correct args', () => {
|
|
56
|
-
expect(promptSpy).toHaveBeenLastCalledWith({
|
|
57
|
-
targetBranchChoices: [{ name: 'branchA' }, { name: 'branchB' }],
|
|
58
|
-
isMultipleChoice: false,
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
describe('when `options.targetBranches` is not empty', () => {
|
|
63
|
-
let branches;
|
|
64
|
-
beforeEach(() => {
|
|
65
|
-
branches = (0, getTargetBranches_1.getTargetBranches)({
|
|
66
|
-
targetBranches: ['branchA', 'branchB'],
|
|
67
|
-
targetBranchChoices: [],
|
|
68
|
-
multipleBranches: false,
|
|
69
|
-
}, []);
|
|
70
|
-
});
|
|
71
|
-
it('should return branches from `options.branches`', () => {
|
|
72
|
-
expect(branches).toEqual(['branchA', 'branchB']);
|
|
73
|
-
});
|
|
74
|
-
it('should not call prompt', () => {
|
|
75
|
-
expect(promptSpy).not.toHaveBeenCalled();
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
describe('when ci=true', () => {
|
|
79
|
-
it('should throw when there are no missing backports', () => {
|
|
80
|
-
const commits = [];
|
|
81
|
-
expect(() => {
|
|
82
|
-
return (0, getTargetBranches_1.getTargetBranches)({
|
|
83
|
-
expectedTargetPullRequests: [],
|
|
84
|
-
ci: true,
|
|
85
|
-
}, commits);
|
|
86
|
-
}).toThrow('There are no branches to backport to. Aborting.');
|
|
87
|
-
});
|
|
88
|
-
it('should return missing backports', () => {
|
|
89
|
-
const commits = [
|
|
90
|
-
{
|
|
91
|
-
expectedTargetPullRequests: [
|
|
92
|
-
{ branch: '7.2', state: 'MERGED' },
|
|
93
|
-
{ branch: '7.1', state: 'OPEN' },
|
|
94
|
-
{ branch: '7.x', state: 'MISSING' },
|
|
95
|
-
],
|
|
96
|
-
},
|
|
97
|
-
];
|
|
98
|
-
const targetBranches = (0, getTargetBranches_1.getTargetBranches)({ ci: true }, commits);
|
|
99
|
-
expect(targetBranches).toEqual(['7.x']);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
describe('when `expectedTargetPullRequests` is missing a backport to 7.x', () => {
|
|
103
|
-
let targetBranchChoices;
|
|
104
|
-
beforeEach(async () => {
|
|
105
|
-
const options = {
|
|
106
|
-
targetBranches: [],
|
|
107
|
-
multipleBranches: true,
|
|
108
|
-
targetBranchChoices: [
|
|
109
|
-
{ name: 'master' },
|
|
110
|
-
{ name: '7.x' },
|
|
111
|
-
{ name: '7.7' },
|
|
112
|
-
{ name: '7.6' },
|
|
113
|
-
{ name: '7.5' },
|
|
114
|
-
],
|
|
115
|
-
branchLabelMapping: {},
|
|
116
|
-
sourceBranch: 'master',
|
|
117
|
-
};
|
|
118
|
-
const commits = [
|
|
119
|
-
{
|
|
120
|
-
committedDate: 'bbb',
|
|
121
|
-
sourceBranch: 'master',
|
|
122
|
-
sha: 'my-sha',
|
|
123
|
-
originalMessage: '[backport] Bump to 5.1.3 (#62286)',
|
|
124
|
-
pullNumber: 62286,
|
|
125
|
-
expectedTargetPullRequests: [{ branch: '7.x', state: 'MISSING' }],
|
|
126
|
-
},
|
|
127
|
-
];
|
|
128
|
-
await (0, getTargetBranches_1.getTargetBranches)(options, commits);
|
|
129
|
-
targetBranchChoices = promptSpy.mock.calls[0][0].targetBranchChoices;
|
|
130
|
-
});
|
|
131
|
-
it('should list the correct branches', async () => {
|
|
132
|
-
expect(targetBranchChoices).toEqual([
|
|
133
|
-
{ checked: true, name: '7.x' },
|
|
134
|
-
{ checked: false, name: '7.7' },
|
|
135
|
-
{ checked: false, name: '7.6' },
|
|
136
|
-
{ checked: false, name: '7.5' },
|
|
137
|
-
]);
|
|
138
|
-
});
|
|
139
|
-
it('should not list the sourceBranch (master)', async () => {
|
|
140
|
-
expect(targetBranchChoices).not.toContainEqual(expect.objectContaining({ name: 'master' }));
|
|
141
|
-
});
|
|
142
|
-
it('should select 7.x', async () => {
|
|
143
|
-
expect(targetBranchChoices).toContainEqual({
|
|
144
|
-
name: '7.x',
|
|
145
|
-
checked: true,
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
describe('getTargetBranchChoices', () => {
|
|
151
|
-
const options = {
|
|
152
|
-
ci: false,
|
|
153
|
-
targetBranchChoices: [
|
|
154
|
-
{ name: 'master', checked: true },
|
|
155
|
-
{ name: '7.x', checked: true },
|
|
156
|
-
{ name: '7.8', checked: false },
|
|
157
|
-
{ name: '7.7', checked: false },
|
|
158
|
-
],
|
|
159
|
-
branchLabelMapping: {},
|
|
160
|
-
};
|
|
161
|
-
const sourceBranch = 'master';
|
|
162
|
-
it('should not check any branches if no labels match', () => {
|
|
163
|
-
const targetBranchesFromLabels = [];
|
|
164
|
-
const branches = (0, getTargetBranches_1.getTargetBranchChoices)(options, targetBranchesFromLabels, sourceBranch);
|
|
165
|
-
expect(branches).toEqual([
|
|
166
|
-
{ checked: false, name: '7.x' },
|
|
167
|
-
{ checked: false, name: '7.8' },
|
|
168
|
-
{ checked: false, name: '7.7' },
|
|
169
|
-
]);
|
|
170
|
-
});
|
|
171
|
-
it('should pre-select branches based on labels', () => {
|
|
172
|
-
const targetBranchesFromLabels = ['7.7'];
|
|
173
|
-
const branches = (0, getTargetBranches_1.getTargetBranchChoices)(options, targetBranchesFromLabels, sourceBranch);
|
|
174
|
-
expect(branches).toEqual([
|
|
175
|
-
{ checked: false, name: '7.x' },
|
|
176
|
-
{ checked: false, name: '7.8' },
|
|
177
|
-
{ checked: true, name: '7.7' },
|
|
178
|
-
]);
|
|
179
|
-
});
|
|
180
|
-
});
|
|
@@ -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
|
-
});
|
|
@@ -1,95 +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.fetchCommitBySha = 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 fetchCommitBySha(options) {
|
|
15
|
-
const { accessToken, githubApiBaseUrlV4, repoName, repoOwner } = options;
|
|
16
|
-
const query = /* GraphQL */ `
|
|
17
|
-
query CommitsBySha($repoOwner: String!, $repoName: String!, $oid: String!) {
|
|
18
|
-
repository(owner: $repoOwner, name: $repoName) {
|
|
19
|
-
object(expression: $oid) {
|
|
20
|
-
... on Commit {
|
|
21
|
-
committedDate
|
|
22
|
-
message
|
|
23
|
-
oid
|
|
24
|
-
associatedPullRequests(first: 1) {
|
|
25
|
-
edges {
|
|
26
|
-
node {
|
|
27
|
-
...${getExistingTargetPullRequests_1.pullRequestFragment.name}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
${getExistingTargetPullRequests_1.pullRequestFragment.source}
|
|
37
|
-
`;
|
|
38
|
-
const spinner = (0, ora_1.default)(`Loading commit "${(0, commitFormatters_1.getShortSha)(options.sha)}"`).start();
|
|
39
|
-
let res;
|
|
40
|
-
try {
|
|
41
|
-
res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
42
|
-
githubApiBaseUrlV4,
|
|
43
|
-
accessToken,
|
|
44
|
-
query,
|
|
45
|
-
variables: {
|
|
46
|
-
repoOwner,
|
|
47
|
-
repoName,
|
|
48
|
-
oid: options.sha,
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
spinner.stop();
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
spinner.fail();
|
|
55
|
-
throw e;
|
|
56
|
-
}
|
|
57
|
-
if (!res.repository.object) {
|
|
58
|
-
throw new HandledError_1.HandledError(`No commit found on branch "${options.sourceBranch}" with sha "${options.sha}"`);
|
|
59
|
-
}
|
|
60
|
-
const committedDate = res.repository.object.committedDate;
|
|
61
|
-
const sha = res.repository.object.oid;
|
|
62
|
-
const commitMessage = res.repository.object.message;
|
|
63
|
-
const pullRequestNode = res.repository.object.associatedPullRequests.edges?.[0]?.node;
|
|
64
|
-
const pullNumber = pullRequestNode?.number || (0, commitFormatters_1.getPullNumberFromMessage)(commitMessage);
|
|
65
|
-
const sourceBranch = pullRequestNode?.baseRefName || options.sourceBranch;
|
|
66
|
-
const formattedMessage = (0, commitFormatters_1.getFormattedCommitMessage)({
|
|
67
|
-
message: commitMessage,
|
|
68
|
-
pullNumber,
|
|
69
|
-
sha,
|
|
70
|
-
});
|
|
71
|
-
spinner.stopAndPersist({
|
|
72
|
-
symbol: chalk_1.default.green('?'),
|
|
73
|
-
text: `${chalk_1.default.bold('Select commit')} ${chalk_1.default.cyan(formattedMessage)}`,
|
|
74
|
-
});
|
|
75
|
-
const existingTargetPullRequests = (0, getExistingTargetPullRequests_1.getExistingTargetPullRequests)(pullRequestNode);
|
|
76
|
-
const targetBranchesFromLabels = pullRequestNode
|
|
77
|
-
? (0, getTargetBranchesFromLabels_1.getTargetBranchesFromLabels)({
|
|
78
|
-
sourceBranch: pullRequestNode.baseRefName,
|
|
79
|
-
existingTargetPullRequests,
|
|
80
|
-
branchLabelMapping: options.branchLabelMapping,
|
|
81
|
-
labels: (0, getExistingTargetPullRequests_1.getPullRequestLabels)(pullRequestNode),
|
|
82
|
-
})
|
|
83
|
-
: [];
|
|
84
|
-
return {
|
|
85
|
-
committedDate,
|
|
86
|
-
sourceBranch,
|
|
87
|
-
targetBranchesFromLabels,
|
|
88
|
-
sha,
|
|
89
|
-
formattedMessage,
|
|
90
|
-
originalMessage: commitMessage,
|
|
91
|
-
pullNumber,
|
|
92
|
-
existingTargetPullRequests,
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
exports.fetchCommitBySha = fetchCommitBySha;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
4
|
-
const fetchCommitBySha_1 = require("./fetchCommitBySha");
|
|
5
|
-
describe('fetchCommitBySha', () => {
|
|
6
|
-
let devAccessToken;
|
|
7
|
-
beforeEach(async () => {
|
|
8
|
-
devAccessToken = await (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
|
-
});
|
|
10
|
-
it('should return single commit with pull request', async () => {
|
|
11
|
-
await expect(await (0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
12
|
-
repoOwner: 'elastic',
|
|
13
|
-
repoName: 'kibana',
|
|
14
|
-
accessToken: devAccessToken,
|
|
15
|
-
sha: 'cb6fbc0',
|
|
16
|
-
githubApiBaseUrlV4: 'https://api.github.com/graphql',
|
|
17
|
-
sourceBranch: 'master',
|
|
18
|
-
})).toEqual({
|
|
19
|
-
formattedMessage: '[APM] Add API tests (#70740)',
|
|
20
|
-
originalMessage: '[APM] Add API tests (#70740)',
|
|
21
|
-
pullNumber: 70740,
|
|
22
|
-
sha: 'cb6fbc0e1b406675724181a3e9f59459b5f8f892',
|
|
23
|
-
sourceBranch: 'master',
|
|
24
|
-
targetBranchesFromLabels: [],
|
|
25
|
-
existingTargetPullRequests: [
|
|
26
|
-
{ branch: '7.x', state: 'MERGED', number: 71014 },
|
|
27
|
-
],
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
it('throws if sha does not exist', async () => {
|
|
31
|
-
await expect((0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
32
|
-
repoOwner: 'elastic',
|
|
33
|
-
repoName: 'kibana',
|
|
34
|
-
accessToken: devAccessToken,
|
|
35
|
-
sha: 'fc22f59',
|
|
36
|
-
githubApiBaseUrlV4: 'https://api.github.com/graphql',
|
|
37
|
-
sourceBranch: 'main',
|
|
38
|
-
})).rejects.toThrowError('No commit found on branch "main" with sha "fc22f59"');
|
|
39
|
-
});
|
|
40
|
-
it('throws if sha is invalid', async () => {
|
|
41
|
-
await expect((0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
42
|
-
repoOwner: 'elastic',
|
|
43
|
-
repoName: 'kibana',
|
|
44
|
-
accessToken: devAccessToken,
|
|
45
|
-
sha: 'myCommitSha',
|
|
46
|
-
githubApiBaseUrlV4: 'https://api.github.com/graphql',
|
|
47
|
-
sourceBranch: 'main',
|
|
48
|
-
})).rejects.toThrowError('No commit found on branch "main" with sha "myCommitSha"');
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ValidConfigOptions } from '../../../../options/options';
|
|
2
|
-
import { Commit, CommitNode } from '../../../../types/commitNode';
|
|
3
|
-
export declare function fetchCommitsInDateRange({ accessToken, branchLabelMapping, commitsCount, dateRange, githubApiBaseUrlV4, repoName, repoOwner, sourceBranch, }: {
|
|
4
|
-
accessToken: string;
|
|
5
|
-
branchLabelMapping: ValidConfigOptions['branchLabelMapping'];
|
|
6
|
-
commitsCount: number;
|
|
7
|
-
dateRange: {
|
|
8
|
-
since: string;
|
|
9
|
-
until: string;
|
|
10
|
-
};
|
|
11
|
-
githubApiBaseUrlV4: string;
|
|
12
|
-
repoName: string;
|
|
13
|
-
repoOwner: string;
|
|
14
|
-
sourceBranch: string;
|
|
15
|
-
}): Promise<Commit[] | undefined>;
|
|
16
|
-
export interface CommitsSinceDateResponse {
|
|
17
|
-
repository: {
|
|
18
|
-
ref: {
|
|
19
|
-
target: {
|
|
20
|
-
history: {
|
|
21
|
-
edges: Array<{
|
|
22
|
-
node: CommitNode;
|
|
23
|
-
}>;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
} | null;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchCommitsInDateRange = void 0;
|
|
4
|
-
const commitNode_1 = require("../../../../types/commitNode");
|
|
5
|
-
const apiRequestV4_1 = require("../apiRequestV4");
|
|
6
|
-
async function fetchCommitsInDateRange({ accessToken, branchLabelMapping, commitsCount, dateRange, githubApiBaseUrlV4, repoName, repoOwner, sourceBranch, }) {
|
|
7
|
-
const query = /* GraphQL */ `
|
|
8
|
-
query CommitsSinceDate($repoOwner: String!, $repoName: String!, $commitsCount: Int!, $sourceBranch: String!, $since: GitTimestamp!, $until: GitTimestamp!) {
|
|
9
|
-
repository(owner: $repoOwner, name: $repoName) {
|
|
10
|
-
id
|
|
11
|
-
ref(qualifiedName: $sourceBranch) {
|
|
12
|
-
target {
|
|
13
|
-
... on Commit {
|
|
14
|
-
history(first: $commitsCount, since: $since, until: $until) {
|
|
15
|
-
totalCount
|
|
16
|
-
edges {
|
|
17
|
-
node {
|
|
18
|
-
...${commitNode_1.commitNodeFragment.name}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
${commitNode_1.commitNodeFragment.source}
|
|
29
|
-
`;
|
|
30
|
-
const res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
31
|
-
githubApiBaseUrlV4,
|
|
32
|
-
accessToken,
|
|
33
|
-
query,
|
|
34
|
-
variables: {
|
|
35
|
-
repoOwner,
|
|
36
|
-
repoName,
|
|
37
|
-
commitsCount,
|
|
38
|
-
sourceBranch,
|
|
39
|
-
since: dateRange.since,
|
|
40
|
-
until: dateRange.until,
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
return res.repository.ref?.target.history.edges
|
|
44
|
-
.filter((commitEdge) => {
|
|
45
|
-
return commitEdge.node.associatedPullRequests.edges?.[0].node != null;
|
|
46
|
-
})
|
|
47
|
-
.map((commitEdge) => {
|
|
48
|
-
const commitNode = commitEdge.node;
|
|
49
|
-
return (0, commitNode_1.getCommit)({ sourceBranch, branchLabelMapping, commitNode });
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
exports.fetchCommitsInDateRange = fetchCommitsInDateRange;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchProjectConfig = void 0;
|
|
4
|
-
const apiRequestV4_1 = require("../apiRequestV4");
|
|
5
|
-
async function fetchProjectConfig(options) {
|
|
6
|
-
const { accessToken, githubApiBaseUrlV4, repoName, repoOwner, sourceBranch } = options;
|
|
7
|
-
const query = /* GraphQL */ `
|
|
8
|
-
query ProjectConfig(
|
|
9
|
-
$repoOwner: String!
|
|
10
|
-
$repoName: String!
|
|
11
|
-
$sourceBranch: String!
|
|
12
|
-
) {
|
|
13
|
-
repository(owner: $repoOwner, name: $repoName) {
|
|
14
|
-
ref(qualifiedName: $sourceBranch) {
|
|
15
|
-
target {
|
|
16
|
-
... on Commit {
|
|
17
|
-
history(first: 1, path: ".backportrc.json") {
|
|
18
|
-
edges {
|
|
19
|
-
remoteConfig: node {
|
|
20
|
-
file(path: ".backportrc.json") {
|
|
21
|
-
... on TreeEntry {
|
|
22
|
-
object {
|
|
23
|
-
... on Blob {
|
|
24
|
-
text
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
`;
|
|
38
|
-
const res = await (0, apiRequestV4_1.apiRequestV4)({
|
|
39
|
-
githubApiBaseUrlV4,
|
|
40
|
-
accessToken,
|
|
41
|
-
query,
|
|
42
|
-
variables: {
|
|
43
|
-
repoOwner,
|
|
44
|
-
repoName,
|
|
45
|
-
sourceBranch,
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
try {
|
|
49
|
-
return JSON.parse(res.repository.ref.target.history.edges[0].remoteConfig.file.object.text);
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
throw new Error('Project config does not exist');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.fetchProjectConfig = fetchProjectConfig;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|