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
package/dist/runSequentially.js
CHANGED
|
@@ -29,10 +29,10 @@ async function runSequentially({ options, commits, targetBranches, }) {
|
|
|
29
29
|
results.push({
|
|
30
30
|
targetBranch,
|
|
31
31
|
status: 'failure',
|
|
32
|
-
errorMessage: e.message,
|
|
33
32
|
error: e,
|
|
34
33
|
});
|
|
35
34
|
(0, logger_1.consoleLog)(e.message);
|
|
35
|
+
logger_1.logger.error('Could not backport commit', e);
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
// return the results for consumers to programatically read
|
|
@@ -68,6 +68,7 @@ describe('runSequentially', () => {
|
|
|
68
68
|
cherrypickRef: true,
|
|
69
69
|
ci: false,
|
|
70
70
|
commitPaths: [],
|
|
71
|
+
cwd: '/path/to/source/repo',
|
|
71
72
|
dateSince: null,
|
|
72
73
|
dateUntil: null,
|
|
73
74
|
details: false,
|
|
@@ -117,12 +118,21 @@ describe('runSequentially', () => {
|
|
|
117
118
|
createPullRequestCalls = (0, nockHelpers_1.listenForCallsToNockScope)(scope);
|
|
118
119
|
const commits = [
|
|
119
120
|
{
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
sourceCommit: {
|
|
122
|
+
committedDate: '1',
|
|
123
|
+
message: 'My commit message',
|
|
124
|
+
sha: 'abcd',
|
|
125
|
+
},
|
|
126
|
+
sourcePullRequest: {
|
|
127
|
+
url: 'foo',
|
|
128
|
+
number: 55,
|
|
129
|
+
mergeCommit: {
|
|
130
|
+
message: 'My commit message',
|
|
131
|
+
sha: 'abcd',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
124
134
|
sourceBranch: 'master',
|
|
125
|
-
|
|
135
|
+
expectedTargetPullRequests: [],
|
|
126
136
|
},
|
|
127
137
|
];
|
|
128
138
|
const targetBranches = ['7.x'];
|
|
@@ -147,8 +157,10 @@ describe('runSequentially', () => {
|
|
|
147
157
|
"base": "7.x",
|
|
148
158
|
"body": "# Backport
|
|
149
159
|
|
|
150
|
-
This
|
|
151
|
-
-
|
|
160
|
+
This will backport the following commits from \`master\` to \`7.x\`:
|
|
161
|
+
- [My commit message](foo)
|
|
162
|
+
|
|
163
|
+
<!--- Backport version: 1.2.3 -->
|
|
152
164
|
|
|
153
165
|
### Questions ?
|
|
154
166
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
@@ -158,14 +170,25 @@ describe('runSequentially', () => {
|
|
|
158
170
|
]
|
|
159
171
|
`);
|
|
160
172
|
});
|
|
161
|
-
it('should run all commands in the
|
|
162
|
-
expect(rpcExecMock.mock.calls.every(
|
|
173
|
+
it('should run all exec commands in the either source or backport directory', () => {
|
|
163
174
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
164
|
-
([cmd, opts]) => opts.cwd
|
|
175
|
+
expect(rpcExecMock.mock.calls.map(([cmd, opts]) => opts.cwd)).toEqual([
|
|
176
|
+
'/path/to/source/repo',
|
|
177
|
+
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
178
|
+
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
179
|
+
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
180
|
+
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
181
|
+
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
182
|
+
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
183
|
+
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
184
|
+
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
185
|
+
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
186
|
+
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
187
|
+
]);
|
|
165
188
|
});
|
|
166
|
-
it('exec should be called with correct args', () => {
|
|
167
|
-
expect(rpcExecMock).toHaveBeenCalledTimes(10);
|
|
189
|
+
it('exec commands should be called with correct args', () => {
|
|
168
190
|
expect(rpcExecMock.mock.calls.map(([cmd]) => cmd)).toEqual([
|
|
191
|
+
'git remote --verbose',
|
|
169
192
|
'git remote rm origin',
|
|
170
193
|
'git remote rm sqren_authenticated',
|
|
171
194
|
'git remote add sqren_authenticated https://x-access-token:myAccessToken@github.com/sqren_authenticated/kibana.git',
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Commit } from './sourceCommit/parseSourceCommit';
|
|
2
|
-
declare type
|
|
3
|
-
|
|
2
|
+
declare type ErrorContext = {
|
|
3
|
+
code: 'merge-conflict-exception';
|
|
4
4
|
commitsWithoutBackports: {
|
|
5
5
|
formatted: string;
|
|
6
6
|
commit: Commit;
|
|
7
7
|
}[];
|
|
8
|
+
} | {
|
|
9
|
+
code: 'no-branches-exception' | 'abort-exception';
|
|
8
10
|
};
|
|
9
11
|
export declare class HandledError extends Error {
|
|
10
|
-
|
|
11
|
-
constructor(
|
|
12
|
+
errorContext?: ErrorContext;
|
|
13
|
+
constructor(errorContext: ErrorContext | string);
|
|
12
14
|
}
|
|
13
15
|
export {};
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HandledError = void 0;
|
|
4
|
+
function getMessage(errorContext) {
|
|
5
|
+
if (typeof errorContext === 'string') {
|
|
6
|
+
return errorContext;
|
|
7
|
+
}
|
|
8
|
+
switch (errorContext.code) {
|
|
9
|
+
case 'merge-conflict-exception':
|
|
10
|
+
return `Commit could not be cherrypicked due to conflicts`;
|
|
11
|
+
case 'no-branches-exception':
|
|
12
|
+
return 'There are no branches to backport to. Aborting.';
|
|
13
|
+
case 'abort-exception':
|
|
14
|
+
return 'Aborted';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
4
17
|
class HandledError extends Error {
|
|
5
|
-
constructor(
|
|
6
|
-
super(
|
|
18
|
+
constructor(errorContext) {
|
|
19
|
+
super(getMessage(errorContext));
|
|
7
20
|
Error.captureStackTrace(this, HandledError);
|
|
8
21
|
this.name = 'HandledError';
|
|
9
|
-
|
|
22
|
+
if (typeof errorContext !== 'string') {
|
|
23
|
+
this.errorContext = errorContext;
|
|
24
|
+
}
|
|
10
25
|
}
|
|
11
26
|
}
|
|
12
27
|
exports.HandledError = HandledError;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import child_process from 'child_process';
|
|
3
|
-
export declare function exec(cmd: string, options: child_process.ExecOptions
|
|
3
|
+
export declare function exec(cmd: string, options: child_process.ExecOptions & {
|
|
4
|
+
cwd: string;
|
|
5
|
+
}): Promise<{
|
|
4
6
|
stdout: string;
|
|
5
7
|
stderr: string;
|
|
6
8
|
}>;
|
|
@@ -9,10 +9,10 @@ describe('env', () => {
|
|
|
9
9
|
beforeEach(() => {
|
|
10
10
|
jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
it('getGlobalConfigPath', () => {
|
|
13
13
|
expect((0, env_1.getGlobalConfigPath)()).toBe('/myHomeDir/.backport/config.json');
|
|
14
14
|
});
|
|
15
|
-
|
|
15
|
+
it('getRepoPath', () => {
|
|
16
16
|
expect((0, env_1.getRepoPath)({
|
|
17
17
|
repoOwner: 'elastic',
|
|
18
18
|
repoName: 'kibana',
|
package/dist/services/git.d.ts
CHANGED
|
@@ -1,22 +1,34 @@
|
|
|
1
1
|
import { ValidConfigOptions } from '../options/options';
|
|
2
2
|
import { ExpectedTargetPullRequest } from './sourceCommit/getExpectedTargetPullRequests';
|
|
3
3
|
import { Commit } from './sourceCommit/parseSourceCommit';
|
|
4
|
-
export declare function repoExists(options: ValidConfigOptions): Promise<boolean>;
|
|
5
|
-
export declare function deleteRepo(options: ValidConfigOptions): Promise<string[]>;
|
|
6
4
|
export declare function getRemoteUrl({ repoName, accessToken, gitHostname }: ValidConfigOptions, repoOwner: string): string;
|
|
7
|
-
export declare function cloneRepo(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export declare function
|
|
5
|
+
export declare function cloneRepo({ sourcePath, targetPath }: {
|
|
6
|
+
sourcePath: string;
|
|
7
|
+
targetPath: string;
|
|
8
|
+
}, onProgress: (progress: number) => void): Promise<void>;
|
|
9
|
+
export declare function getLocalConfigFileCommitDate({ cwd }: {
|
|
10
|
+
cwd: string;
|
|
11
|
+
}): Promise<number | undefined>;
|
|
12
|
+
export declare function isLocalConfigFileUntracked({ cwd }: {
|
|
13
|
+
cwd: string;
|
|
14
|
+
}): Promise<boolean | undefined>;
|
|
15
|
+
export declare function isLocalConfigFileModified({ cwd }: {
|
|
16
|
+
cwd: string;
|
|
17
|
+
}): Promise<boolean | undefined>;
|
|
18
|
+
export declare function getRepoInfoFromGitRemotes({ cwd }: {
|
|
19
|
+
cwd: string;
|
|
20
|
+
}): Promise<{
|
|
12
21
|
repoOwner: string;
|
|
13
22
|
repoName: string;
|
|
14
|
-
}
|
|
23
|
+
}[]>;
|
|
24
|
+
export declare function getGitProjectRoot({ cwd }: {
|
|
25
|
+
cwd: string;
|
|
26
|
+
}): Promise<string | undefined>;
|
|
15
27
|
export declare function getIsCommitInBranch(options: ValidConfigOptions, commitSha: string): Promise<boolean>;
|
|
16
28
|
export declare function deleteRemote(options: ValidConfigOptions, remoteName: string): Promise<void>;
|
|
17
29
|
export declare function addRemote(options: ValidConfigOptions, remoteName: string): Promise<void>;
|
|
18
30
|
export declare function fetchBranch(options: ValidConfigOptions, branch: string): Promise<void>;
|
|
19
|
-
export declare function cherrypick(options: ValidConfigOptions, sha:
|
|
31
|
+
export declare function cherrypick(options: ValidConfigOptions, sha: string, mergedTargetPullRequest?: ExpectedTargetPullRequest): Promise<{
|
|
20
32
|
conflictingFiles: {
|
|
21
33
|
absolute: string;
|
|
22
34
|
relative: string;
|
|
@@ -55,3 +67,4 @@ export declare function pushBackportBranch({ options, backportBranch, }: {
|
|
|
55
67
|
stdout: string;
|
|
56
68
|
stderr: string;
|
|
57
69
|
}>;
|
|
70
|
+
export declare function getSourceRepoPath(options: ValidConfigOptions): Promise<string>;
|
|
@@ -22,22 +22,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const
|
|
26
|
-
const del_1 = __importDefault(require("del"));
|
|
25
|
+
const promises_1 = require("fs/promises");
|
|
27
26
|
const make_dir_1 = __importDefault(require("make-dir"));
|
|
27
|
+
const nockHelpers_1 = require("../test/nockHelpers");
|
|
28
|
+
const sandbox_1 = require("../test/sandbox");
|
|
28
29
|
const childProcess = __importStar(require("./child-process-promisified"));
|
|
29
|
-
const env = __importStar(require("./env"));
|
|
30
30
|
const git_1 = require("./git");
|
|
31
31
|
const commitFormatters_1 = require("./github/commitFormatters");
|
|
32
|
-
jest.unmock('make-dir');
|
|
33
32
|
jest.unmock('del');
|
|
34
|
-
|
|
35
|
-
async function resetGitSandbox() {
|
|
36
|
-
await (0, del_1.default)(GIT_SANDBOX_DIR_PATH);
|
|
37
|
-
await (0, make_dir_1.default)(GIT_SANDBOX_DIR_PATH);
|
|
38
|
-
// mock repo path to point to git-sandbox dir
|
|
39
|
-
jest.spyOn(env, 'getRepoPath').mockReturnValue(GIT_SANDBOX_DIR_PATH);
|
|
40
|
-
}
|
|
33
|
+
jest.unmock('make-dir');
|
|
41
34
|
async function createAndCommitFile({ filename, content, execOpts, }) {
|
|
42
35
|
await childProcess.exec(`echo "${content}" > "${filename}"`, execOpts);
|
|
43
36
|
await childProcess.exec(`git add -A && git commit -m 'Update ${filename}'`, execOpts);
|
|
@@ -55,9 +48,13 @@ describe('git.integration', () => {
|
|
|
55
48
|
describe('getIsCommitInBranch', () => {
|
|
56
49
|
let firstSha;
|
|
57
50
|
let secondSha;
|
|
51
|
+
const sandboxPath = (0, sandbox_1.getSandboxPath)({
|
|
52
|
+
filename: __filename,
|
|
53
|
+
specname: 'getIsCommitInBranch',
|
|
54
|
+
});
|
|
58
55
|
beforeEach(async () => {
|
|
59
|
-
await
|
|
60
|
-
const execOpts = { cwd:
|
|
56
|
+
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
57
|
+
const execOpts = { cwd: sandboxPath };
|
|
61
58
|
// create and commit first file
|
|
62
59
|
await childProcess.exec('git init', execOpts);
|
|
63
60
|
firstSha = await createAndCommitFile({
|
|
@@ -77,15 +74,15 @@ describe('git.integration', () => {
|
|
|
77
74
|
await childProcess.exec('git checkout 7.x', execOpts);
|
|
78
75
|
});
|
|
79
76
|
it('should contain the first commit', async () => {
|
|
80
|
-
const isFirstCommitInBranch = await (0, git_1.getIsCommitInBranch)({}, firstSha);
|
|
77
|
+
const isFirstCommitInBranch = await (0, git_1.getIsCommitInBranch)({ dir: sandboxPath }, firstSha);
|
|
81
78
|
expect(isFirstCommitInBranch).toEqual(true);
|
|
82
79
|
});
|
|
83
80
|
it('should not contain the second commit', async () => {
|
|
84
|
-
const isSecondCommitInBranch = await (0, git_1.getIsCommitInBranch)({}, secondSha);
|
|
81
|
+
const isSecondCommitInBranch = await (0, git_1.getIsCommitInBranch)({ dir: sandboxPath }, secondSha);
|
|
85
82
|
expect(isSecondCommitInBranch).toEqual(false);
|
|
86
83
|
});
|
|
87
84
|
it('should not contain a random commit', async () => {
|
|
88
|
-
const isSecondCommitInBranch = await (0, git_1.getIsCommitInBranch)({}, 'abcdefg');
|
|
85
|
+
const isSecondCommitInBranch = await (0, git_1.getIsCommitInBranch)({ dir: sandboxPath }, 'abcdefg');
|
|
89
86
|
expect(isSecondCommitInBranch).toEqual(false);
|
|
90
87
|
});
|
|
91
88
|
});
|
|
@@ -94,9 +91,13 @@ describe('git.integration', () => {
|
|
|
94
91
|
let secondSha;
|
|
95
92
|
let fourthSha;
|
|
96
93
|
let execOpts;
|
|
94
|
+
const sandboxPath = (0, sandbox_1.getSandboxPath)({
|
|
95
|
+
filename: __filename,
|
|
96
|
+
specname: 'cherrypick',
|
|
97
|
+
});
|
|
97
98
|
beforeEach(async () => {
|
|
98
|
-
await
|
|
99
|
-
execOpts = { cwd:
|
|
99
|
+
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
100
|
+
execOpts = { cwd: sandboxPath };
|
|
100
101
|
// create and commit first file
|
|
101
102
|
await childProcess.exec('git init', execOpts);
|
|
102
103
|
firstSha = await createAndCommitFile({
|
|
@@ -129,10 +130,13 @@ describe('git.integration', () => {
|
|
|
129
130
|
});
|
|
130
131
|
it('should not cherrypick commit that already exists', async () => {
|
|
131
132
|
const shortSha = (0, commitFormatters_1.getShortSha)(firstSha);
|
|
132
|
-
return expect(() => (0, git_1.cherrypick)({}, firstSha)).rejects.toThrowError(`Cherrypick failed because the selected commit (${shortSha}) is empty. Did you already backport this commit?`);
|
|
133
|
+
return expect(() => (0, git_1.cherrypick)({ dir: sandboxPath }, firstSha)).rejects.toThrowError(`Cherrypick failed because the selected commit (${shortSha}) is empty. Did you already backport this commit?`);
|
|
133
134
|
});
|
|
134
135
|
it('should cherrypick commit cleanly', async () => {
|
|
135
|
-
const res = await (0, git_1.cherrypick)({
|
|
136
|
+
const res = await (0, git_1.cherrypick)({
|
|
137
|
+
cherrypickRef: false,
|
|
138
|
+
dir: sandboxPath,
|
|
139
|
+
}, secondSha);
|
|
136
140
|
expect(res).toEqual({
|
|
137
141
|
conflictingFiles: [],
|
|
138
142
|
needsResolving: false,
|
|
@@ -142,7 +146,10 @@ describe('git.integration', () => {
|
|
|
142
146
|
expect(message).toEqual(`Update bar.md`);
|
|
143
147
|
});
|
|
144
148
|
it('should cherrypick commit cleanly and append "(cherry picked from commit...)"', async () => {
|
|
145
|
-
const res = await (0, git_1.cherrypick)({
|
|
149
|
+
const res = await (0, git_1.cherrypick)({
|
|
150
|
+
cherrypickRef: true,
|
|
151
|
+
dir: sandboxPath,
|
|
152
|
+
}, secondSha);
|
|
146
153
|
expect(res).toEqual({
|
|
147
154
|
conflictingFiles: [],
|
|
148
155
|
needsResolving: false,
|
|
@@ -152,17 +159,109 @@ describe('git.integration', () => {
|
|
|
152
159
|
expect(message).toEqual(`Update bar.md\n\n(cherry picked from commit ${secondSha})`);
|
|
153
160
|
});
|
|
154
161
|
it('should cherrypick commit with conflicts', async () => {
|
|
155
|
-
const res = await (0, git_1.cherrypick)({}, fourthSha);
|
|
162
|
+
const res = await (0, git_1.cherrypick)({ dir: sandboxPath }, fourthSha);
|
|
156
163
|
expect(res).toEqual({
|
|
157
164
|
needsResolving: true,
|
|
158
165
|
conflictingFiles: [
|
|
159
166
|
{
|
|
160
|
-
absolute: `${
|
|
167
|
+
absolute: `${sandboxPath}/foo.md`,
|
|
161
168
|
relative: 'foo.md',
|
|
162
169
|
},
|
|
163
170
|
],
|
|
164
|
-
unstagedFiles: [`${
|
|
171
|
+
unstagedFiles: [`${sandboxPath}/foo.md`],
|
|
165
172
|
});
|
|
166
173
|
});
|
|
167
174
|
});
|
|
175
|
+
describe('cloneRepo', () => {
|
|
176
|
+
const sandboxPath = (0, sandbox_1.getSandboxPath)({
|
|
177
|
+
filename: __filename,
|
|
178
|
+
specname: 'cloneRepo',
|
|
179
|
+
});
|
|
180
|
+
const sourceRepo = `${sandboxPath}/source-repo`;
|
|
181
|
+
const backportRepo = `${sandboxPath}/backport-repo`;
|
|
182
|
+
beforeEach(async () => {
|
|
183
|
+
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
184
|
+
await (0, make_dir_1.default)(sourceRepo);
|
|
185
|
+
const execOpts = { cwd: sourceRepo };
|
|
186
|
+
await childProcess.exec(`git init`, execOpts);
|
|
187
|
+
await childProcess.exec(`git remote add origin git@github.com:elastic/kibana.git`, execOpts);
|
|
188
|
+
await createAndCommitFile({
|
|
189
|
+
filename: 'my-file.txt',
|
|
190
|
+
content: 'Hello!',
|
|
191
|
+
execOpts,
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
it('clones the repo', async () => {
|
|
195
|
+
// file should not exist before clone
|
|
196
|
+
await expect(() => (0, promises_1.access)(`${backportRepo}/my-file.txt`)).rejects.toThrowError();
|
|
197
|
+
await (0, git_1.cloneRepo)({ sourcePath: sourceRepo, targetPath: backportRepo }, () => null);
|
|
198
|
+
//file should exist after clone
|
|
199
|
+
await expect(() => (0, promises_1.access)(`${backportRepo}/my-file.txt`)).not.toThrowError();
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
describe('getSourceRepoPath', () => {
|
|
203
|
+
let sourceRepo;
|
|
204
|
+
beforeEach(async () => {
|
|
205
|
+
const sandboxPath = (0, sandbox_1.getSandboxPath)({
|
|
206
|
+
filename: __filename,
|
|
207
|
+
specname: 'getSourceRepoPath',
|
|
208
|
+
});
|
|
209
|
+
sourceRepo = `${sandboxPath}/source-repo`;
|
|
210
|
+
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
211
|
+
await (0, make_dir_1.default)(sourceRepo);
|
|
212
|
+
const execOpts = { cwd: sourceRepo };
|
|
213
|
+
await childProcess.exec(`git init`, execOpts);
|
|
214
|
+
await childProcess.exec(`git remote add origin git@github.com:elastic/kibana.git`, execOpts);
|
|
215
|
+
mockRepoOwnerAndName({
|
|
216
|
+
childRepoOwner: 'sqren',
|
|
217
|
+
parentRepoOwner: 'elastic',
|
|
218
|
+
repoName: 'kibana',
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
it('returns local source repo, when one remote matches', async () => {
|
|
222
|
+
const options = {
|
|
223
|
+
accessToken: 'verysecret',
|
|
224
|
+
repoName: 'kibana',
|
|
225
|
+
repoOwner: 'elastic',
|
|
226
|
+
cwd: sourceRepo,
|
|
227
|
+
githubApiBaseUrlV4: 'http://localhost/graphql', // required to mock the response
|
|
228
|
+
};
|
|
229
|
+
expect(await (0, git_1.getSourceRepoPath)(options)).toBe(sourceRepo);
|
|
230
|
+
});
|
|
231
|
+
it("returns remote source repo when remotes don't match", async () => {
|
|
232
|
+
const options = {
|
|
233
|
+
accessToken: 'verysecret',
|
|
234
|
+
repoName: 'kibana',
|
|
235
|
+
repoOwner: 'not-a-match',
|
|
236
|
+
cwd: sourceRepo,
|
|
237
|
+
githubApiBaseUrlV4: 'http://localhost/graphql', // required to mock the response
|
|
238
|
+
};
|
|
239
|
+
expect(await (0, git_1.getSourceRepoPath)(options)).toBe('https://x-access-token:verysecret@github.com/not-a-match/kibana.git');
|
|
240
|
+
});
|
|
241
|
+
});
|
|
168
242
|
});
|
|
243
|
+
function mockRepoOwnerAndName({ repoName, parentRepoOwner, childRepoOwner, }) {
|
|
244
|
+
return (0, nockHelpers_1.mockGqlRequest)({
|
|
245
|
+
name: 'RepoOwnerAndName',
|
|
246
|
+
statusCode: 200,
|
|
247
|
+
body: {
|
|
248
|
+
data: {
|
|
249
|
+
// @ts-expect-error
|
|
250
|
+
repository: {
|
|
251
|
+
isFork: !!parentRepoOwner,
|
|
252
|
+
name: repoName,
|
|
253
|
+
owner: {
|
|
254
|
+
login: childRepoOwner,
|
|
255
|
+
},
|
|
256
|
+
parent: parentRepoOwner
|
|
257
|
+
? {
|
|
258
|
+
owner: {
|
|
259
|
+
login: parentRepoOwner,
|
|
260
|
+
},
|
|
261
|
+
}
|
|
262
|
+
: null,
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
}
|
package/dist/services/git.js
CHANGED
|
@@ -3,69 +3,54 @@ 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.pushBackportBranch = exports.getRepoForkOwner = exports.deleteBackportBranch = exports.createBackportBranch = exports.setCommitAuthor = exports.getUnstagedFiles = exports.getConflictingFiles = exports.commitChanges = exports.cherrypick = exports.fetchBranch = exports.addRemote = exports.deleteRemote = exports.getIsCommitInBranch = exports.
|
|
6
|
+
exports.getSourceRepoPath = exports.pushBackportBranch = exports.getRepoForkOwner = exports.deleteBackportBranch = exports.createBackportBranch = exports.setCommitAuthor = exports.getUnstagedFiles = exports.getConflictingFiles = exports.commitChanges = exports.cherrypick = exports.fetchBranch = exports.addRemote = exports.deleteRemote = exports.getIsCommitInBranch = exports.getGitProjectRoot = exports.getRepoInfoFromGitRemotes = exports.isLocalConfigFileModified = exports.isLocalConfigFileUntracked = exports.getLocalConfigFileCommitDate = exports.cloneRepo = exports.getRemoteUrl = void 0;
|
|
7
7
|
const path_1 = require("path");
|
|
8
|
-
const del_1 = __importDefault(require("del"));
|
|
9
8
|
const lodash_1 = require("lodash");
|
|
10
9
|
const ora_1 = __importDefault(require("ora"));
|
|
10
|
+
const filterEmpty_1 = require("../utils/filterEmpty");
|
|
11
11
|
const HandledError_1 = require("./HandledError");
|
|
12
12
|
const child_process_promisified_1 = require("./child-process-promisified");
|
|
13
13
|
const env_1 = require("./env");
|
|
14
|
-
const fs_promisified_1 = require("./fs-promisified");
|
|
15
14
|
const commitFormatters_1 = require("./github/commitFormatters");
|
|
15
|
+
const getRepoOwnerAndNameFromGitRemotes_1 = require("./github/v4/getRepoOwnerAndNameFromGitRemotes");
|
|
16
16
|
const logger_1 = require("./logger");
|
|
17
|
-
async function folderExists(path) {
|
|
18
|
-
try {
|
|
19
|
-
const stats = await (0, fs_promisified_1.stat)(path);
|
|
20
|
-
return stats.isDirectory();
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
if (e.code === 'ENOENT') {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
throw e;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function repoExists(options) {
|
|
30
|
-
return folderExists((0, env_1.getRepoPath)(options));
|
|
31
|
-
}
|
|
32
|
-
exports.repoExists = repoExists;
|
|
33
|
-
function deleteRepo(options) {
|
|
34
|
-
const repoPath = (0, env_1.getRepoPath)(options);
|
|
35
|
-
return (0, del_1.default)(repoPath);
|
|
36
|
-
}
|
|
37
|
-
exports.deleteRepo = deleteRepo;
|
|
38
17
|
function getRemoteUrl({ repoName, accessToken, gitHostname = 'github.com' }, repoOwner) {
|
|
39
18
|
return `https://x-access-token:${accessToken}@${gitHostname}/${repoOwner}/${repoName}.git`;
|
|
40
19
|
}
|
|
41
20
|
exports.getRemoteUrl = getRemoteUrl;
|
|
42
|
-
function cloneRepo(
|
|
21
|
+
async function cloneRepo({ sourcePath, targetPath }, onProgress) {
|
|
43
22
|
return new Promise((resolve, reject) => {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
23
|
+
const execProcess = (0, child_process_promisified_1.execAsCallback)(`git clone ${sourcePath} ${targetPath} --progress`, { maxBuffer: 100 * 1024 * 1024 }, (error) => {
|
|
24
|
+
return error ? reject(error) : resolve();
|
|
25
|
+
});
|
|
26
|
+
const progress = {
|
|
27
|
+
fileUpdate: 0,
|
|
28
|
+
objectReceive: 0,
|
|
51
29
|
};
|
|
52
|
-
const execProcess = (0, child_process_promisified_1.execAsCallback)(`git clone ${getRemoteUrl(options, options.repoOwner)} ${(0, env_1.getRepoPath)(options)} --progress`, { maxBuffer: 100 * 1024 * 1024 }, cb);
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
54
30
|
if (execProcess.stderr) {
|
|
55
31
|
execProcess.stderr.on('data', (data) => {
|
|
56
|
-
|
|
57
|
-
const [,
|
|
58
|
-
if (
|
|
59
|
-
|
|
32
|
+
logger_1.logger.verbose(data);
|
|
33
|
+
const [, objectReceiveProgress] = data.toString().match(/^Receiving objects:\s+(\d+)%/) || [];
|
|
34
|
+
if (objectReceiveProgress) {
|
|
35
|
+
progress.objectReceive = parseInt(objectReceiveProgress, 10);
|
|
36
|
+
}
|
|
37
|
+
const [, fileUpdateProgress] = data.toString().match(/^Updating files:\s+(\d+)%/) || [];
|
|
38
|
+
if (fileUpdateProgress) {
|
|
39
|
+
progress.objectReceive = 100;
|
|
40
|
+
progress.fileUpdate = parseInt(fileUpdateProgress, 10);
|
|
41
|
+
}
|
|
42
|
+
const progressSum = Math.round(progress.fileUpdate * 0.1 + progress.objectReceive * 0.9);
|
|
43
|
+
if (progressSum > 0) {
|
|
44
|
+
onProgress(progressSum);
|
|
60
45
|
}
|
|
61
46
|
});
|
|
62
47
|
}
|
|
63
48
|
});
|
|
64
49
|
}
|
|
65
50
|
exports.cloneRepo = cloneRepo;
|
|
66
|
-
async function getLocalConfigFileCommitDate() {
|
|
51
|
+
async function getLocalConfigFileCommitDate({ cwd }) {
|
|
67
52
|
try {
|
|
68
|
-
const { stdout } = await (0, child_process_promisified_1.exec)('git --no-pager log -1 --format=%cd .backportrc.js*', {});
|
|
53
|
+
const { stdout } = await (0, child_process_promisified_1.exec)('git --no-pager log -1 --format=%cd .backportrc.js*', { cwd });
|
|
69
54
|
const timestamp = Date.parse(stdout);
|
|
70
55
|
if (timestamp > 0) {
|
|
71
56
|
return timestamp;
|
|
@@ -76,10 +61,10 @@ async function getLocalConfigFileCommitDate() {
|
|
|
76
61
|
}
|
|
77
62
|
}
|
|
78
63
|
exports.getLocalConfigFileCommitDate = getLocalConfigFileCommitDate;
|
|
79
|
-
async function isLocalConfigFileUntracked() {
|
|
64
|
+
async function isLocalConfigFileUntracked({ cwd }) {
|
|
80
65
|
try {
|
|
81
66
|
// list untracked files
|
|
82
|
-
const { stdout } = await (0, child_process_promisified_1.exec)('git ls-files .backportrc.js* --exclude-standard --others', {});
|
|
67
|
+
const { stdout } = await (0, child_process_promisified_1.exec)('git ls-files .backportrc.js* --exclude-standard --others', { cwd });
|
|
83
68
|
return !!stdout;
|
|
84
69
|
}
|
|
85
70
|
catch (e) {
|
|
@@ -87,9 +72,9 @@ async function isLocalConfigFileUntracked() {
|
|
|
87
72
|
}
|
|
88
73
|
}
|
|
89
74
|
exports.isLocalConfigFileUntracked = isLocalConfigFileUntracked;
|
|
90
|
-
async function isLocalConfigFileModified() {
|
|
75
|
+
async function isLocalConfigFileModified({ cwd }) {
|
|
91
76
|
try {
|
|
92
|
-
const { stdout } = await (0, child_process_promisified_1.exec)('git --no-pager diff HEAD --name-only .backportrc.js*', {});
|
|
77
|
+
const { stdout } = await (0, child_process_promisified_1.exec)('git --no-pager diff HEAD --name-only .backportrc.js*', { cwd });
|
|
93
78
|
return !!stdout;
|
|
94
79
|
}
|
|
95
80
|
catch (e) {
|
|
@@ -97,25 +82,41 @@ async function isLocalConfigFileModified() {
|
|
|
97
82
|
}
|
|
98
83
|
}
|
|
99
84
|
exports.isLocalConfigFileModified = isLocalConfigFileModified;
|
|
100
|
-
async function
|
|
85
|
+
async function getRepoInfoFromGitRemotes({ cwd }) {
|
|
101
86
|
try {
|
|
102
|
-
const { stdout } = await (0, child_process_promisified_1.exec)('git remote --verbose', {});
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
87
|
+
const { stdout } = await (0, child_process_promisified_1.exec)('git remote --verbose', { cwd });
|
|
88
|
+
const remotes = stdout
|
|
89
|
+
.split('\n')
|
|
90
|
+
.map((line) => {
|
|
91
|
+
const match = line.match(/.+github.com:(.+?)(.git)? \((fetch|push)\)/);
|
|
92
|
+
return match?.[1];
|
|
93
|
+
})
|
|
94
|
+
.filter(filterEmpty_1.filterNil);
|
|
95
|
+
return (0, lodash_1.uniq)(remotes).map((remote) => {
|
|
96
|
+
const [repoOwner, repoName] = remote.split('/');
|
|
106
97
|
return { repoOwner, repoName };
|
|
107
|
-
}
|
|
98
|
+
});
|
|
108
99
|
}
|
|
109
100
|
catch (e) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.getRepoInfoFromGitRemotes = getRepoInfoFromGitRemotes;
|
|
105
|
+
async function getGitProjectRoot({ cwd }) {
|
|
106
|
+
try {
|
|
107
|
+
const { stdout } = await (0, child_process_promisified_1.exec)('git rev-parse --show-toplevel', { cwd });
|
|
108
|
+
return stdout.trim();
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
logger_1.logger.error('An error occurred while retrieving git project root', e);
|
|
110
112
|
return;
|
|
111
113
|
}
|
|
112
114
|
}
|
|
113
|
-
exports.
|
|
115
|
+
exports.getGitProjectRoot = getGitProjectRoot;
|
|
114
116
|
async function getIsCommitInBranch(options, commitSha) {
|
|
115
117
|
try {
|
|
116
|
-
const cwd = (0, env_1.getRepoPath)(options);
|
|
117
118
|
await (0, child_process_promisified_1.exec)(`git merge-base --is-ancestor ${commitSha} HEAD`, {
|
|
118
|
-
cwd,
|
|
119
|
+
cwd: (0, env_1.getRepoPath)(options),
|
|
119
120
|
});
|
|
120
121
|
return true;
|
|
121
122
|
}
|
|
@@ -214,7 +215,7 @@ async function commitChanges(commit, options) {
|
|
|
214
215
|
// manually set the commit message if the inferred commit message is empty
|
|
215
216
|
// this can happen if the user runs `git reset HEAD` and thereby aborts the cherrypick process
|
|
216
217
|
if (e.stderr?.includes('Aborting commit due to empty commit message')) {
|
|
217
|
-
await (0, child_process_promisified_1.exec)(`git commit -m "${commit.
|
|
218
|
+
await (0, child_process_promisified_1.exec)(`git commit -m "${commit.sourceCommit.message}" ${noVerifyFlag}`, {
|
|
218
219
|
cwd: (0, env_1.getRepoPath)(options),
|
|
219
220
|
});
|
|
220
221
|
return;
|
|
@@ -331,3 +332,14 @@ async function pushBackportBranch({ options, backportBranch, }) {
|
|
|
331
332
|
}
|
|
332
333
|
}
|
|
333
334
|
exports.pushBackportBranch = pushBackportBranch;
|
|
335
|
+
async function getSourceRepoPath(options) {
|
|
336
|
+
const gitRemote = await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)(options);
|
|
337
|
+
// where to fetch the repo from (either remotely from Github or from a local path)
|
|
338
|
+
const remoteUrl = getRemoteUrl(options, options.repoOwner);
|
|
339
|
+
const sourcePath = options.repoName === gitRemote.repoName &&
|
|
340
|
+
options.repoOwner === gitRemote.repoOwner
|
|
341
|
+
? (await getGitProjectRoot(options)) ?? remoteUrl
|
|
342
|
+
: remoteUrl;
|
|
343
|
+
return sourcePath;
|
|
344
|
+
}
|
|
345
|
+
exports.getSourceRepoPath = getSourceRepoPath;
|