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
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.cherrypickAndCreateTargetPullRequest = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
9
|
const ora = require("ora");
|
|
@@ -62,8 +62,8 @@ async function cherrypickAndCreateTargetPullRequest({ options, commits, targetBr
|
|
|
62
62
|
// add labels to source pull requests
|
|
63
63
|
if (options.sourcePRLabels.length > 0) {
|
|
64
64
|
const promises = commits.map((commit) => {
|
|
65
|
-
if (commit.
|
|
66
|
-
return (0, addLabelsToPullRequest_1.addLabelsToPullRequest)(options, commit.
|
|
65
|
+
if (commit.sourcePullRequest) {
|
|
66
|
+
return (0, addLabelsToPullRequest_1.addLabelsToPullRequest)(options, commit.sourcePullRequest.number, options.sourcePRLabels);
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
69
|
await Promise.all(promises);
|
|
@@ -93,16 +93,15 @@ async function backportViaFilesystem({ options, prPayload, commits, targetBranch
|
|
|
93
93
|
*/
|
|
94
94
|
function getBackportBranchName(targetBranch, commits) {
|
|
95
95
|
const refValues = commits
|
|
96
|
-
.map((commit) => commit.
|
|
97
|
-
? `pr-${commit.
|
|
98
|
-
: `commit-${(0, commitFormatters_1.getShortSha)(commit.sha)}`)
|
|
96
|
+
.map((commit) => commit.sourcePullRequest
|
|
97
|
+
? `pr-${commit.sourcePullRequest.number}`
|
|
98
|
+
: `commit-${(0, commitFormatters_1.getShortSha)(commit.sourceCommit.sha)}`)
|
|
99
99
|
.join('_')
|
|
100
100
|
.slice(0, 200);
|
|
101
101
|
return `backport/${targetBranch}/${refValues}`;
|
|
102
102
|
}
|
|
103
|
-
exports.getBackportBranchName = getBackportBranchName;
|
|
104
103
|
async function waitForCherrypick(options, commit, targetBranch) {
|
|
105
|
-
const spinnerText = `Cherry-picking: ${chalk_1.default.greenBright((0, commitFormatters_1.getFirstLine)(commit.
|
|
104
|
+
const spinnerText = `Cherry-picking: ${chalk_1.default.greenBright((0, commitFormatters_1.getFirstLine)(commit.sourceCommit.message))}`;
|
|
106
105
|
const mergedTargetPullRequest = commit.expectedTargetPullRequests.find((pr) => pr.state === 'MERGED' && pr.branch === targetBranch);
|
|
107
106
|
const cherrypickSpinner = ora(spinnerText).start();
|
|
108
107
|
let conflictingFiles;
|
|
@@ -110,7 +109,7 @@ async function waitForCherrypick(options, commit, targetBranch) {
|
|
|
110
109
|
let needsResolving;
|
|
111
110
|
try {
|
|
112
111
|
await (0, git_1.fetchBranch)(options, commit.sourceBranch);
|
|
113
|
-
({ conflictingFiles, unstagedFiles, needsResolving } = await (0, git_1.cherrypick)(options, commit.sha, mergedTargetPullRequest));
|
|
112
|
+
({ conflictingFiles, unstagedFiles, needsResolving } = await (0, git_1.cherrypick)(options, commit.sourceCommit.sha, mergedTargetPullRequest));
|
|
114
113
|
// no conflicts encountered
|
|
115
114
|
if (!needsResolving) {
|
|
116
115
|
cherrypickSpinner.succeed();
|
|
@@ -147,8 +146,8 @@ async function waitForCherrypick(options, commit, targetBranch) {
|
|
|
147
146
|
conflictingFiles: conflictingFiles.map((f) => f.relative).slice(0, 50),
|
|
148
147
|
});
|
|
149
148
|
if (options.ci) {
|
|
150
|
-
throw new HandledError_1.HandledError(
|
|
151
|
-
|
|
149
|
+
throw new HandledError_1.HandledError({
|
|
150
|
+
code: 'merge-conflict-exception',
|
|
152
151
|
commitsWithoutBackports,
|
|
153
152
|
});
|
|
154
153
|
}
|
|
@@ -162,7 +161,7 @@ async function waitForCherrypick(options, commit, targetBranch) {
|
|
|
162
161
|
*/
|
|
163
162
|
if (options.editor) {
|
|
164
163
|
const repoPath = (0, env_1.getRepoPath)(options);
|
|
165
|
-
await (0, child_process_promisified_1.exec)(`${options.editor} ${repoPath}`, {});
|
|
164
|
+
await (0, child_process_promisified_1.exec)(`${options.editor} ${repoPath}`, { cwd: options.cwd });
|
|
166
165
|
}
|
|
167
166
|
// list files with conflict markers + unstaged files and require user to resolve them
|
|
168
167
|
await listConflictingAndUnstagedFiles({
|
|
@@ -208,7 +207,7 @@ ${unstagedSection}
|
|
|
208
207
|
|
|
209
208
|
Press ENTER when the conflicts are resolved and files are staged`);
|
|
210
209
|
if (!res) {
|
|
211
|
-
throw new HandledError_1.HandledError('
|
|
210
|
+
throw new HandledError_1.HandledError({ code: 'abort-exception' });
|
|
212
211
|
}
|
|
213
212
|
const MAX_RETRIES = 100;
|
|
214
213
|
if (retries++ > MAX_RETRIES) {
|
|
@@ -63,7 +63,6 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
63
63
|
assignees: [],
|
|
64
64
|
authenticatedUsername: 'sqren_authenticated',
|
|
65
65
|
fork: true,
|
|
66
|
-
prDescription: 'myPrSuffix',
|
|
67
66
|
prTitle: '[{targetBranch}] {commitMessages}',
|
|
68
67
|
repoName: 'kibana',
|
|
69
68
|
repoOwner: 'elastic',
|
|
@@ -75,19 +74,37 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
75
74
|
};
|
|
76
75
|
const commits = [
|
|
77
76
|
{
|
|
78
|
-
committedDate: 'fff',
|
|
79
77
|
sourceBranch: '7.x',
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
sourceCommit: {
|
|
79
|
+
committedDate: 'fff',
|
|
80
|
+
sha: 'mySha',
|
|
81
|
+
message: 'My original commit message (#1000)',
|
|
82
|
+
},
|
|
83
|
+
sourcePullRequest: {
|
|
84
|
+
url: 'foo',
|
|
85
|
+
number: 1000,
|
|
86
|
+
mergeCommit: {
|
|
87
|
+
sha: 'mySha',
|
|
88
|
+
message: 'My original commit message (#1000)',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
83
91
|
expectedTargetPullRequests: [],
|
|
84
92
|
},
|
|
85
93
|
{
|
|
86
|
-
committedDate: 'ggg',
|
|
87
94
|
sourceBranch: '7.x',
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
sourceCommit: {
|
|
96
|
+
committedDate: 'ggg',
|
|
97
|
+
sha: 'mySha2',
|
|
98
|
+
message: 'My other commit message (#2000)',
|
|
99
|
+
},
|
|
100
|
+
sourcePullRequest: {
|
|
101
|
+
url: 'foo',
|
|
102
|
+
number: 2000,
|
|
103
|
+
mergeCommit: {
|
|
104
|
+
sha: 'mySha2',
|
|
105
|
+
message: 'My other commit message (#2000)',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
91
108
|
expectedTargetPullRequests: [],
|
|
92
109
|
},
|
|
93
110
|
];
|
|
@@ -110,14 +127,14 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
110
127
|
"base": "6.x",
|
|
111
128
|
"body": "# Backport
|
|
112
129
|
|
|
113
|
-
This
|
|
114
|
-
- #1000
|
|
115
|
-
- #2000
|
|
130
|
+
This will backport the following commits from \`7.x\` to \`6.x\`:
|
|
131
|
+
- [My original commit message (#1000)](foo)
|
|
132
|
+
- [My other commit message (#2000)](foo)
|
|
116
133
|
|
|
117
|
-
|
|
118
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
134
|
+
<!--- Backport version: 1.2.3 -->
|
|
119
135
|
|
|
120
|
-
|
|
136
|
+
### Questions ?
|
|
137
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
121
138
|
"head": "sqren_authenticated:backport/6.x/pr-1000_pr-2000",
|
|
122
139
|
"title": "[6.x] My original commit message (#1000) | My other commit message (#2000)",
|
|
123
140
|
},
|
|
@@ -171,10 +188,12 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
171
188
|
};
|
|
172
189
|
const commits = [
|
|
173
190
|
{
|
|
174
|
-
|
|
191
|
+
sourceCommit: {
|
|
192
|
+
committedDate: 'hhh',
|
|
193
|
+
sha: 'mySha',
|
|
194
|
+
message: 'My original commit message',
|
|
195
|
+
},
|
|
175
196
|
sourceBranch: '7.x',
|
|
176
|
-
sha: 'mySha',
|
|
177
|
-
originalMessage: 'My original commit message',
|
|
178
197
|
expectedTargetPullRequests: [],
|
|
179
198
|
},
|
|
180
199
|
];
|
|
@@ -197,12 +216,13 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
197
216
|
"base": "6.x",
|
|
198
217
|
"body": "# Backport
|
|
199
218
|
|
|
200
|
-
This
|
|
219
|
+
This will backport the following commits from \`7.x\` to \`6.x\`:
|
|
201
220
|
- My original commit message (mySha)
|
|
202
221
|
|
|
222
|
+
<!--- Backport version: 1.2.3 -->
|
|
223
|
+
|
|
203
224
|
### Questions ?
|
|
204
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
205
|
-
",
|
|
225
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
206
226
|
"head": "sqren_authenticated:backport/6.x/commit-mySha",
|
|
207
227
|
"title": "[6.x] My original commit message",
|
|
208
228
|
},
|
|
@@ -251,10 +271,12 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
251
271
|
options,
|
|
252
272
|
commits: [
|
|
253
273
|
{
|
|
254
|
-
|
|
274
|
+
sourceCommit: {
|
|
275
|
+
committedDate: '2021-08-18T16:11:38Z',
|
|
276
|
+
sha: 'mySha',
|
|
277
|
+
message: 'My original commit message',
|
|
278
|
+
},
|
|
255
279
|
sourceBranch: '7.x',
|
|
256
|
-
sha: 'mySha',
|
|
257
|
-
originalMessage: 'My original commit message',
|
|
258
280
|
expectedTargetPullRequests: [],
|
|
259
281
|
},
|
|
260
282
|
],
|
|
@@ -270,12 +292,13 @@ describe('cherrypickAndCreateTargetPullRequest', () => {
|
|
|
270
292
|
"base": "6.x",
|
|
271
293
|
"body": "# Backport
|
|
272
294
|
|
|
273
|
-
This
|
|
295
|
+
This will backport the following commits from \`7.x\` to \`6.x\`:
|
|
274
296
|
- My original commit message (mySha)
|
|
275
297
|
|
|
298
|
+
<!--- Backport version: 1.2.3 -->
|
|
299
|
+
|
|
276
300
|
### Questions ?
|
|
277
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
278
|
-
",
|
|
301
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)",
|
|
279
302
|
"head": "sqren_authenticated:backport/6.x/commit-mySha",
|
|
280
303
|
"title": "[6.x] My original commit message",
|
|
281
304
|
},
|
package/dist/ui/getCommits.js
CHANGED
|
@@ -25,7 +25,7 @@ async function getCommits(options) {
|
|
|
25
25
|
if (options.sha) {
|
|
26
26
|
spinner.text = `Loading commit "${(0, commitFormatters_1.getShortSha)(options.sha)}"`;
|
|
27
27
|
const commit = await (0, fetchCommitBySha_1.fetchCommitBySha)({ ...options, sha: options.sha });
|
|
28
|
-
spinner.stopAndPersist(getOraPersistsOption('Select commit', commit.
|
|
28
|
+
spinner.stopAndPersist(getOraPersistsOption('Select commit', commit.sourceCommit.message));
|
|
29
29
|
return [commit];
|
|
30
30
|
}
|
|
31
31
|
if (options.pullNumber) {
|
|
@@ -35,24 +35,18 @@ async function getCommits(options) {
|
|
|
35
35
|
pullNumber: options.pullNumber, // must extract pullNumber to satisfy the ts gods
|
|
36
36
|
});
|
|
37
37
|
// add styles to make it look like a prompt question
|
|
38
|
-
spinner.stopAndPersist(getOraPersistsOption('Select pull request', (0, commitFormatters_1.getFirstLine)(commit.
|
|
38
|
+
spinner.stopAndPersist(getOraPersistsOption('Select pull request', (0, commitFormatters_1.getFirstLine)(commit.sourceCommit.message)));
|
|
39
39
|
return [commit];
|
|
40
40
|
}
|
|
41
41
|
if (options.ci) {
|
|
42
42
|
throw new HandledError_1.HandledError('When "--ci" flag is enabled either `--sha` or `--pr` must be specified');
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
isMultipleChoice: options.multipleCommits,
|
|
51
|
-
showDetails: options.details,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
spinner.text = `Loading commits from branch "${options.sourceBranch}"...`;
|
|
55
|
-
const commitChoices = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)(options);
|
|
44
|
+
spinner.text = options.prFilter
|
|
45
|
+
? 'Loading pull requests...'
|
|
46
|
+
: `Loading commits from branch "${options.sourceBranch}"...`;
|
|
47
|
+
const commitChoices = options.prFilter
|
|
48
|
+
? await (0, fetchPullRequestBySearchQuery_1.fetchPullRequestBySearchQuery)(options)
|
|
49
|
+
: await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)(options);
|
|
56
50
|
spinner.stop();
|
|
57
51
|
return (0, prompts_1.promptForCommits)({
|
|
58
52
|
commitChoices,
|
|
@@ -22,21 +22,21 @@ conflictingFiles, }) {
|
|
|
22
22
|
...options,
|
|
23
23
|
author: null,
|
|
24
24
|
dateSince: null,
|
|
25
|
-
dateUntil: commit.committedDate,
|
|
25
|
+
dateUntil: commit.sourceCommit.committedDate,
|
|
26
26
|
commitPaths: conflictingFiles,
|
|
27
27
|
});
|
|
28
28
|
const promises = await Promise.all(commitsInConflictingPaths
|
|
29
29
|
.filter((c) => {
|
|
30
30
|
// exclude the commit we are currently trying to backport
|
|
31
|
-
if (c.sha === commit.sha) {
|
|
31
|
+
if (c.sourceCommit.sha === commit.sourceCommit.sha) {
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
// exclude commits that are newer than the commit we are trying to backport
|
|
35
|
-
if (c.committedDate > commit.committedDate) {
|
|
35
|
+
if (c.sourceCommit.committedDate > commit.sourceCommit.committedDate) {
|
|
36
36
|
return false;
|
|
37
37
|
}
|
|
38
38
|
// only consider commits that have an associated pull request
|
|
39
|
-
if (!c.
|
|
39
|
+
if (!c.sourcePullRequest?.url) {
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
42
|
// only include commit if it has an unmerged PR for the given target branch
|
|
@@ -60,8 +60,8 @@ conflictingFiles, }) {
|
|
|
60
60
|
// get pull request for the target branch (if it exists)
|
|
61
61
|
const pendingBackportPr = c.expectedTargetPullRequests.find((pr) => pr.branch === targetBranch && pr.state === 'OPEN');
|
|
62
62
|
const formatted = pendingBackportPr
|
|
63
|
-
? ` - ${(0, commitFormatters_1.getFirstLine)(c.
|
|
64
|
-
: ` - ${(0, commitFormatters_1.getFirstLine)(c.
|
|
63
|
+
? ` - ${(0, commitFormatters_1.getFirstLine)(c.sourceCommit.message)} ${chalk_1.default.gray('(backport pending)')}\n ${pendingBackportPr.url}`
|
|
64
|
+
: ` - ${(0, commitFormatters_1.getFirstLine)(c.sourceCommit.message)} ${chalk_1.default.red('(backport missing)')}\n ${c.sourcePullRequest?.url}`;
|
|
65
65
|
return { formatted, commit: c };
|
|
66
66
|
});
|
|
67
67
|
}
|
|
@@ -37,12 +37,21 @@ describe('getCommitsWithoutBackports', () => {
|
|
|
37
37
|
.spyOn(fetchCommitsByAuthorModule, 'fetchCommitsByAuthor')
|
|
38
38
|
.mockResolvedValueOnce([
|
|
39
39
|
{
|
|
40
|
-
|
|
40
|
+
sourceCommit: {
|
|
41
|
+
committedDate: '10',
|
|
42
|
+
message: 'First commit (#1)',
|
|
43
|
+
sha: 'xyz',
|
|
44
|
+
},
|
|
45
|
+
sourcePullRequest: {
|
|
46
|
+
url: 'https://www.github.com/foo/bar/pull/123',
|
|
47
|
+
number: 123,
|
|
48
|
+
mergeCommit: {
|
|
49
|
+
message: 'First commit (#1)',
|
|
50
|
+
sha: 'xyz',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
41
53
|
expectedTargetPullRequests,
|
|
42
|
-
originalMessage: 'First commit (#1)',
|
|
43
|
-
sha: 'xyz',
|
|
44
54
|
sourceBranch: 'main',
|
|
45
|
-
pullUrl: 'https://www.github.com/foo/bar/pull/123',
|
|
46
55
|
},
|
|
47
56
|
]);
|
|
48
57
|
// simulate commit is definitely not backported
|
|
@@ -50,10 +59,12 @@ describe('getCommitsWithoutBackports', () => {
|
|
|
50
59
|
return (0, getCommitsWithoutBackports_1.getCommitsWithoutBackports)({
|
|
51
60
|
options: {},
|
|
52
61
|
commit: {
|
|
53
|
-
|
|
62
|
+
sourceCommit: {
|
|
63
|
+
committedDate: '100',
|
|
64
|
+
message: 'Second commit (#2)',
|
|
65
|
+
sha: 'abc',
|
|
66
|
+
},
|
|
54
67
|
expectedTargetPullRequests: [],
|
|
55
|
-
originalMessage: 'Second commit (#2)',
|
|
56
|
-
sha: 'abc',
|
|
57
68
|
sourceBranch: 'main',
|
|
58
69
|
},
|
|
59
70
|
targetBranch: '7.x',
|
|
@@ -119,7 +130,20 @@ describe('getCommitsWithoutBackports', () => {
|
|
|
119
130
|
.spyOn(fetchCommitsByAuthorModule, 'fetchCommitsByAuthor')
|
|
120
131
|
.mockResolvedValueOnce([
|
|
121
132
|
{
|
|
122
|
-
|
|
133
|
+
sourceCommit: {
|
|
134
|
+
committedDate: offendingCommitDate,
|
|
135
|
+
message: 'First commit (#1)',
|
|
136
|
+
sha: 'xyz',
|
|
137
|
+
},
|
|
138
|
+
sourcePullRequest: {
|
|
139
|
+
number: 123,
|
|
140
|
+
url: 'https://www.github.com/foo/bar/pull/123',
|
|
141
|
+
mergeCommit: {
|
|
142
|
+
message: 'First commit (#1)',
|
|
143
|
+
sha: 'xyz',
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
sourceBranch: 'main',
|
|
123
147
|
expectedTargetPullRequests: [
|
|
124
148
|
{
|
|
125
149
|
state: 'OPEN',
|
|
@@ -128,11 +152,6 @@ describe('getCommitsWithoutBackports', () => {
|
|
|
128
152
|
url: 'https://www.github.com/foo/bar/pull/456',
|
|
129
153
|
},
|
|
130
154
|
],
|
|
131
|
-
originalMessage: 'First commit (#1)',
|
|
132
|
-
sha: 'xyz',
|
|
133
|
-
sourceBranch: 'main',
|
|
134
|
-
pullNumber: 123,
|
|
135
|
-
pullUrl: 'https://www.github.com/foo/bar/pull/123',
|
|
136
155
|
},
|
|
137
156
|
]);
|
|
138
157
|
// simulate commit is definitely not backported
|
|
@@ -140,11 +159,21 @@ describe('getCommitsWithoutBackports', () => {
|
|
|
140
159
|
return (0, getCommitsWithoutBackports_1.getCommitsWithoutBackports)({
|
|
141
160
|
options: {},
|
|
142
161
|
commit: {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
162
|
+
sourceCommit: {
|
|
163
|
+
committedDate: currentCommitDate,
|
|
164
|
+
message: 'Second commit (#2)',
|
|
165
|
+
sha: 'abc',
|
|
166
|
+
},
|
|
167
|
+
sourcePullRequest: {
|
|
168
|
+
number: 123,
|
|
169
|
+
url: 'https://www.github.com/foo/bar/pull/123',
|
|
170
|
+
mergeCommit: {
|
|
171
|
+
message: 'Second commit (#2)',
|
|
172
|
+
sha: 'abc',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
147
175
|
sourceBranch: 'main',
|
|
176
|
+
expectedTargetPullRequests: [],
|
|
148
177
|
},
|
|
149
178
|
targetBranch: '7.x',
|
|
150
179
|
conflictingFiles: ['/foo/bar/baz.ts'],
|
|
@@ -172,9 +201,20 @@ describe('getCommitsWithoutBackports', () => {
|
|
|
172
201
|
.spyOn(fetchCommitsByAuthorModule, 'fetchCommitsByAuthor')
|
|
173
202
|
.mockResolvedValueOnce([
|
|
174
203
|
{
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
204
|
+
sourceCommit: {
|
|
205
|
+
committedDate: '10',
|
|
206
|
+
message: 'First commit (#1)',
|
|
207
|
+
sha: 'xyz',
|
|
208
|
+
},
|
|
209
|
+
sourcePullRequest: {
|
|
210
|
+
number: 123,
|
|
211
|
+
url: 'https://www.github.com/foo/bar/pull/123',
|
|
212
|
+
mergeCommit: {
|
|
213
|
+
message: 'First commit (#1)',
|
|
214
|
+
sha: 'xyz',
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
sourceBranch: 'main',
|
|
178
218
|
expectedTargetPullRequests: [
|
|
179
219
|
{
|
|
180
220
|
branch: offendingCommitTargetBranch,
|
|
@@ -183,9 +223,6 @@ describe('getCommitsWithoutBackports', () => {
|
|
|
183
223
|
number: 456,
|
|
184
224
|
},
|
|
185
225
|
],
|
|
186
|
-
originalMessage: 'First commit (#1)',
|
|
187
|
-
sha: 'xyz',
|
|
188
|
-
sourceBranch: 'main',
|
|
189
226
|
},
|
|
190
227
|
]);
|
|
191
228
|
// simulate commit is definitely not backported
|
|
@@ -194,12 +231,20 @@ describe('getCommitsWithoutBackports', () => {
|
|
|
194
231
|
options: {},
|
|
195
232
|
// commit that is being backported
|
|
196
233
|
commit: {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
234
|
+
sourceCommit: {
|
|
235
|
+
committedDate: '100',
|
|
236
|
+
message: 'Second commit (#2)',
|
|
237
|
+
sha: 'abc',
|
|
238
|
+
},
|
|
239
|
+
sourcePullRequest: {
|
|
240
|
+
url: 'https://www.github.com/foo/bar/pull/123',
|
|
241
|
+
number: 123,
|
|
242
|
+
mergeCommit: {
|
|
243
|
+
message: 'Second commit (#2)',
|
|
244
|
+
sha: 'abc',
|
|
245
|
+
},
|
|
246
|
+
},
|
|
200
247
|
expectedTargetPullRequests: [],
|
|
201
|
-
originalMessage: 'Second commit (#2)',
|
|
202
|
-
sha: 'abc',
|
|
203
248
|
sourceBranch: 'main',
|
|
204
249
|
},
|
|
205
250
|
targetBranch: currentCommitTargetBranch,
|
|
@@ -227,13 +272,12 @@ describe('getCommitsWithoutBackports', () => {
|
|
|
227
272
|
.spyOn(fetchCommitsByAuthorModule, 'fetchCommitsByAuthor')
|
|
228
273
|
.mockResolvedValueOnce([
|
|
229
274
|
{
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
275
|
+
sourceCommit: {
|
|
276
|
+
committedDate: '10',
|
|
277
|
+
sha: 'xyz',
|
|
278
|
+
message: 'First commit (#1)',
|
|
279
|
+
},
|
|
234
280
|
expectedTargetPullRequests: [],
|
|
235
|
-
originalMessage: 'First commit (#1)',
|
|
236
|
-
sha: 'xyz',
|
|
237
281
|
sourceBranch: 'main',
|
|
238
282
|
},
|
|
239
283
|
]);
|
|
@@ -242,12 +286,20 @@ describe('getCommitsWithoutBackports', () => {
|
|
|
242
286
|
const commitsWithoutBackports = await (0, getCommitsWithoutBackports_1.getCommitsWithoutBackports)({
|
|
243
287
|
options: {},
|
|
244
288
|
commit: {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
289
|
+
sourceCommit: {
|
|
290
|
+
committedDate: '100',
|
|
291
|
+
message: 'Second commit (#2)',
|
|
292
|
+
sha: 'abc',
|
|
293
|
+
},
|
|
294
|
+
sourcePullRequest: {
|
|
295
|
+
url: 'https://www.github.com/foo/bar/pull/123',
|
|
296
|
+
number: 123,
|
|
297
|
+
mergeCommit: {
|
|
298
|
+
message: 'Second commit (#2)',
|
|
299
|
+
sha: 'abc',
|
|
300
|
+
},
|
|
301
|
+
},
|
|
248
302
|
expectedTargetPullRequests: [],
|
|
249
|
-
originalMessage: 'Second commit (#2)',
|
|
250
|
-
sha: 'abc',
|
|
251
303
|
sourceBranch: 'main',
|
|
252
304
|
},
|
|
253
305
|
targetBranch: '7.x',
|
|
@@ -18,7 +18,7 @@ function getTargetBranches(options, commits) {
|
|
|
18
18
|
// automatically backport to specified target branches
|
|
19
19
|
if (options.ci) {
|
|
20
20
|
if ((0, lodash_1.isEmpty)(missingTargetBranches)) {
|
|
21
|
-
throw new HandledError_1.HandledError(
|
|
21
|
+
throw new HandledError_1.HandledError({ code: 'no-branches-exception' });
|
|
22
22
|
}
|
|
23
23
|
return missingTargetBranches;
|
|
24
24
|
}
|
|
@@ -39,11 +39,20 @@ describe('getTargetBranches', () => {
|
|
|
39
39
|
};
|
|
40
40
|
const commits = [
|
|
41
41
|
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
sourceCommit: {
|
|
43
|
+
committedDate: 'aaa',
|
|
44
|
+
message: 'hey',
|
|
45
|
+
sha: 'abcd',
|
|
46
|
+
},
|
|
47
|
+
sourcePullRequest: {
|
|
48
|
+
url: 'foo',
|
|
49
|
+
number: 1337,
|
|
50
|
+
mergeCommit: {
|
|
51
|
+
message: 'hey',
|
|
52
|
+
sha: 'abcd',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
45
55
|
sourceBranch: '7.x',
|
|
46
|
-
pullNumber: 1337,
|
|
47
56
|
expectedTargetPullRequests: [],
|
|
48
57
|
},
|
|
49
58
|
];
|
|
@@ -117,11 +126,20 @@ describe('getTargetBranches', () => {
|
|
|
117
126
|
};
|
|
118
127
|
const commits = [
|
|
119
128
|
{
|
|
120
|
-
|
|
129
|
+
sourceCommit: {
|
|
130
|
+
committedDate: 'bbb',
|
|
131
|
+
message: '[backport] Bump to 5.1.3 (#62286)',
|
|
132
|
+
sha: 'my-sha',
|
|
133
|
+
},
|
|
134
|
+
sourcePullRequest: {
|
|
135
|
+
url: 'foo',
|
|
136
|
+
number: 62286,
|
|
137
|
+
mergeCommit: {
|
|
138
|
+
message: '[backport] Bump to 5.1.3 (#62286)',
|
|
139
|
+
sha: 'my-sha',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
121
142
|
sourceBranch: 'master',
|
|
122
|
-
sha: 'my-sha',
|
|
123
|
-
originalMessage: '[backport] Bump to 5.1.3 (#62286)',
|
|
124
|
-
pullNumber: 62286,
|
|
125
143
|
expectedTargetPullRequests: [{ branch: '7.x', state: 'MISSING' }],
|
|
126
144
|
},
|
|
127
145
|
];
|
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.maybeSetupRepo = void 0;
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const del = require("del");
|
|
4
6
|
const ora = require("ora");
|
|
7
|
+
const env_1 = require("../services/env");
|
|
5
8
|
const git_1 = require("../services/git");
|
|
6
9
|
async function maybeSetupRepo(options) {
|
|
7
|
-
const
|
|
10
|
+
const repoPath = (0, env_1.getRepoPath)(options);
|
|
11
|
+
const isAlreadyCloned = await getIsRepoCloned(repoPath);
|
|
8
12
|
// clone repo if folder does not already exists
|
|
9
13
|
if (!isAlreadyCloned) {
|
|
10
14
|
const spinner = ora().start();
|
|
11
15
|
try {
|
|
12
|
-
const
|
|
16
|
+
const sourcePath = await (0, git_1.getSourceRepoPath)(options);
|
|
17
|
+
const sourcePathHumanReadable = sourcePath.includes(options.gitHostname)
|
|
18
|
+
? options.gitHostname
|
|
19
|
+
: sourcePath;
|
|
20
|
+
const spinnerCloneText = `Cloning repository from ${sourcePathHumanReadable} (one-time operation)`;
|
|
13
21
|
spinner.text = `0% ${spinnerCloneText}`;
|
|
14
|
-
await (0, git_1.cloneRepo)(
|
|
22
|
+
await (0, git_1.cloneRepo)({ sourcePath, targetPath: repoPath }, (progress) => {
|
|
15
23
|
spinner.text = `${progress}% ${spinnerCloneText}`;
|
|
16
24
|
});
|
|
17
25
|
spinner.succeed(`100% ${spinnerCloneText}`);
|
|
18
26
|
}
|
|
19
27
|
catch (e) {
|
|
20
28
|
spinner.fail();
|
|
21
|
-
await (
|
|
29
|
+
await del(repoPath);
|
|
22
30
|
throw e;
|
|
23
31
|
}
|
|
24
32
|
}
|
|
@@ -27,10 +35,22 @@ async function maybeSetupRepo(options) {
|
|
|
27
35
|
// ensure remote are setup with latest accessToken
|
|
28
36
|
await (0, git_1.deleteRemote)(options, options.authenticatedUsername);
|
|
29
37
|
await (0, git_1.addRemote)(options, options.authenticatedUsername);
|
|
30
|
-
//
|
|
38
|
+
// add remote for non-fork repo (if the above is a fork)
|
|
31
39
|
if (options.authenticatedUsername !== options.repoOwner) {
|
|
32
40
|
await (0, git_1.deleteRemote)(options, options.repoOwner);
|
|
33
41
|
await (0, git_1.addRemote)(options, options.repoOwner);
|
|
34
42
|
}
|
|
35
43
|
}
|
|
36
44
|
exports.maybeSetupRepo = maybeSetupRepo;
|
|
45
|
+
async function getIsRepoCloned(path) {
|
|
46
|
+
try {
|
|
47
|
+
const stats = await (0, promises_1.stat)(path);
|
|
48
|
+
return stats.isDirectory();
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
if (e.code === 'ENOENT') {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
throw e;
|
|
55
|
+
}
|
|
56
|
+
}
|