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
|
@@ -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,
|
|
@@ -82,9 +83,7 @@ describe('runSequentially', () => {
|
|
|
82
83
|
multipleBranches: false,
|
|
83
84
|
multipleCommits: false,
|
|
84
85
|
noVerify: true,
|
|
85
|
-
prDescription: 'myPrDescription',
|
|
86
86
|
prFilter: undefined,
|
|
87
|
-
prTitle: 'myPrTitle {targetBranch} {commitMessages}',
|
|
88
87
|
publishStatusComment: true,
|
|
89
88
|
pullNumber: undefined,
|
|
90
89
|
repoName: 'kibana',
|
|
@@ -119,12 +118,21 @@ describe('runSequentially', () => {
|
|
|
119
118
|
createPullRequestCalls = (0, nockHelpers_1.listenForCallsToNockScope)(scope);
|
|
120
119
|
const commits = [
|
|
121
120
|
{
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
+
},
|
|
126
134
|
sourceBranch: 'master',
|
|
127
|
-
|
|
135
|
+
expectedTargetPullRequests: [],
|
|
128
136
|
},
|
|
129
137
|
];
|
|
130
138
|
const targetBranches = ['7.x'];
|
|
@@ -149,27 +157,38 @@ describe('runSequentially', () => {
|
|
|
149
157
|
"base": "7.x",
|
|
150
158
|
"body": "# Backport
|
|
151
159
|
|
|
152
|
-
This
|
|
153
|
-
-
|
|
160
|
+
This will backport the following commits from \`master\` to \`7.x\`:
|
|
161
|
+
- [My commit message](foo)
|
|
154
162
|
|
|
155
|
-
|
|
156
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
163
|
+
<!--- Backport version: 1.2.3 -->
|
|
157
164
|
|
|
158
|
-
|
|
165
|
+
### Questions ?
|
|
166
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
159
167
|
"head": "sqren_authenticated:backport/7.x/pr-55",
|
|
160
|
-
"title": "
|
|
168
|
+
"title": "[7.x] My commit message",
|
|
161
169
|
},
|
|
162
170
|
]
|
|
163
171
|
`);
|
|
164
172
|
});
|
|
165
|
-
it('should run all commands in the
|
|
166
|
-
expect(rpcExecMock.mock.calls.every(
|
|
173
|
+
it('should run all exec commands in the either source or backport directory', () => {
|
|
167
174
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
168
|
-
([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
|
+
]);
|
|
169
188
|
});
|
|
170
|
-
it('exec should be called with correct args', () => {
|
|
171
|
-
expect(rpcExecMock).toHaveBeenCalledTimes(10);
|
|
189
|
+
it('exec commands should be called with correct args', () => {
|
|
172
190
|
expect(rpcExecMock.mock.calls.map(([cmd]) => cmd)).toEqual([
|
|
191
|
+
'git remote --verbose',
|
|
173
192
|
'git remote rm origin',
|
|
174
193
|
'git remote rm sqren_authenticated',
|
|
175
194
|
'git remote add sqren_authenticated https://x-access-token:myAccessToken@github.com/sqren_authenticated/kibana.git',
|
|
@@ -6,10 +6,10 @@ const env_1 = require("../services/env");
|
|
|
6
6
|
const logger_1 = require("../services/logger");
|
|
7
7
|
async function postinstall() {
|
|
8
8
|
try {
|
|
9
|
-
const
|
|
9
|
+
const globalConfigPath = (0, env_1.getGlobalConfigPath)();
|
|
10
|
+
const didCreate = await (0, globalConfig_1.createGlobalConfigAndFolderIfNotExist)(globalConfigPath);
|
|
10
11
|
if (didCreate) {
|
|
11
|
-
|
|
12
|
-
(0, logger_1.consoleLog)(`Global config successfully created in ${GLOBAL_CONFIG_PATH}`);
|
|
12
|
+
(0, logger_1.consoleLog)(`Global config successfully created in ${globalConfigPath}`);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
catch (e) {
|
|
@@ -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
|
}>;
|
package/dist/services/env.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ValidConfigOptions } from '../options/options';
|
|
2
2
|
export declare function getBackportDirPath(): string;
|
|
3
|
-
export declare function getLogfilePath(
|
|
3
|
+
export declare function getLogfilePath({ logFilePath }: {
|
|
4
|
+
logFilePath?: string;
|
|
5
|
+
}): string;
|
|
4
6
|
export declare function getGlobalConfigPath(): string;
|
|
5
7
|
export declare function getRepoPath({ repoOwner, repoName, dir }: ValidConfigOptions): string;
|
package/dist/services/env.js
CHANGED
|
@@ -10,7 +10,10 @@ function getBackportDirPath() {
|
|
|
10
10
|
return path_1.default.join((0, os_1.homedir)(), '.backport');
|
|
11
11
|
}
|
|
12
12
|
exports.getBackportDirPath = getBackportDirPath;
|
|
13
|
-
function getLogfilePath() {
|
|
13
|
+
function getLogfilePath({ logFilePath }) {
|
|
14
|
+
if (logFilePath) {
|
|
15
|
+
return path_1.default.resolve(logFilePath);
|
|
16
|
+
}
|
|
14
17
|
return path_1.default.join((0, os_1.homedir)(), '.backport', 'backport.log');
|
|
15
18
|
}
|
|
16
19
|
exports.getLogfilePath = getLogfilePath;
|
|
@@ -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
|
+
}
|