backport 7.3.6 → 8.1.0
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 +16 -21
- package/dist/backportRun.d.ts +18 -6
- package/dist/backportRun.js +70 -50
- package/dist/entrypoint.cli.js +4 -8
- package/dist/entrypoint.module.d.ts +13 -6
- package/dist/entrypoint.module.js +17 -19
- package/dist/entrypoint.module.private.test.js +129 -330
- package/dist/errors/BackportError.d.ts +19 -0
- package/dist/errors/BackportError.js +29 -0
- package/dist/lib/BackportError.d.ts +19 -0
- package/dist/lib/BackportError.js +29 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.d.ts +13 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.js +238 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
- package/dist/lib/cherrypickAndCreateTargetPullRequest.test.js +321 -0
- package/dist/lib/child-process-promisified.d.ts +25 -0
- package/dist/lib/child-process-promisified.js +58 -0
- package/dist/lib/env.d.ts +7 -0
- package/dist/lib/env.js +33 -0
- package/dist/lib/env.test.d.ts +1 -0
- package/dist/lib/env.test.js +26 -0
- package/dist/lib/getCommits.d.ts +2 -0
- package/dist/lib/getCommits.js +75 -0
- package/dist/lib/getCommitsWithoutBackports.d.ts +11 -0
- package/dist/lib/getCommitsWithoutBackports.js +68 -0
- package/dist/lib/getCommitsWithoutBackports.test.d.ts +1 -0
- package/dist/lib/getCommitsWithoutBackports.test.js +335 -0
- package/dist/lib/getGitConfigAuthor.d.ts +6 -0
- package/dist/lib/getGitConfigAuthor.js +15 -0
- package/dist/lib/getTargetBranches.d.ts +5 -0
- package/dist/lib/getTargetBranches.js +67 -0
- package/dist/lib/getTargetBranches.test.d.ts +1 -0
- package/dist/lib/getTargetBranches.test.js +206 -0
- package/dist/lib/git.d.ts +77 -0
- package/dist/lib/git.js +439 -0
- package/dist/lib/git.private.test.d.ts +1 -0
- package/dist/lib/git.private.test.js +618 -0
- package/dist/lib/git.test.d.ts +1 -0
- package/dist/lib/git.test.js +580 -0
- package/dist/lib/github/commitFormatters.d.ts +3 -0
- package/dist/lib/github/commitFormatters.js +17 -0
- package/dist/lib/github/commitFormatters.test.d.ts +1 -0
- package/dist/lib/github/commitFormatters.test.js +11 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.js +32 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.test.d.ts +1 -0
- package/dist/lib/github/v3/addAssigneesToPullRequest.test.js +27 -0
- package/dist/lib/github/v3/addLabelsToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addLabelsToPullRequest.js +30 -0
- package/dist/lib/github/v3/addReviewersToPullRequest.d.ts +2 -0
- package/dist/lib/github/v3/addReviewersToPullRequest.js +32 -0
- package/dist/lib/github/v3/createPullRequest.d.ts +29 -0
- package/dist/lib/github/v3/createPullRequest.js +91 -0
- package/dist/lib/github/v3/createPullRequest.test.d.ts +1 -0
- package/dist/lib/github/v3/createPullRequest.test.js +377 -0
- package/dist/lib/github/v3/createStatusComment.d.ts +11 -0
- package/dist/lib/github/v3/createStatusComment.js +136 -0
- package/dist/lib/github/v3/createStatusComment.test.d.ts +1 -0
- package/dist/lib/github/v3/createStatusComment.test.js +461 -0
- package/dist/lib/github/v3/getGithubV3ErrorMessage.d.ts +14 -0
- package/dist/lib/github/v3/getGithubV3ErrorMessage.js +16 -0
- package/dist/lib/github/v4/FetchPullRequestId.d.ts +2 -0
- package/dist/lib/github/v4/FetchPullRequestId.js +36 -0
- package/dist/lib/github/v4/apiRequestV4.d.ts +31 -0
- package/dist/lib/github/v4/apiRequestV4.js +71 -0
- package/dist/lib/github/v4/apiRequestV4.test.d.ts +1 -0
- package/dist/lib/github/v4/apiRequestV4.test.js +109 -0
- package/dist/lib/github/v4/disablePullRequestAutoMerge.d.ts +2 -0
- package/dist/lib/github/v4/disablePullRequestAutoMerge.js +32 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.d.ts +2 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.js +50 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
- package/dist/lib/github/v4/enablePullRequestAutoMerge.private.test.js +112 -0
- package/dist/lib/github/v4/fetchAuthorId.d.ts +10 -0
- package/dist/lib/github/v4/fetchAuthorId.js +28 -0
- package/dist/lib/github/v4/fetchAuthorId.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchAuthorId.private.test.js +25 -0
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/allFetchers.private.test.js +93 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +11 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.js +58 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +136 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.d.ts +11 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.js +48 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitBySha.private.test.js +118 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +29 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.js +110 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +196 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +157 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +107 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.d.ts +12 -0
- package/dist/lib/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +69 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.d.ts +9 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.js +64 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchExistingPullRequest.private.test.js +44 -0
- package/dist/lib/github/v4/fetchPullRequestAutoMergeMethod.d.ts +2 -0
- package/dist/lib/github/v4/fetchPullRequestAutoMergeMethod.js +39 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.d.ts +8 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.js +49 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.private.test.d.ts +1 -0
- package/dist/lib/github/v4/fetchRemoteProjectConfig.private.test.js +49 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +72 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +78 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
- package/dist/lib/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +116 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.d.ts +16 -0
- package/dist/lib/github/v4/getOptionsFromGithub/query.js +29 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.js +61 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +1 -0
- package/dist/lib/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +72 -0
- package/dist/lib/github/v4/mocks/commitsByAuthorMock.d.ts +2 -0
- package/dist/lib/github/v4/mocks/commitsByAuthorMock.js +176 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.d.ts +7 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.js +45 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.test.d.ts +1 -0
- package/dist/lib/github/v4/throwOnInvalidAccessToken.test.js +87 -0
- package/dist/lib/logger.d.ts +9 -0
- package/dist/lib/logger.js +74 -0
- package/dist/lib/ora.d.ts +2 -0
- package/dist/lib/ora.js +21 -0
- package/dist/lib/prompt.test.d.ts +1 -0
- package/dist/lib/prompt.test.js +139 -0
- package/dist/lib/prompts.d.ts +17 -0
- package/dist/lib/prompts.js +132 -0
- package/dist/lib/remoteConfig.d.ts +20 -0
- package/dist/lib/remoteConfig.js +52 -0
- package/dist/lib/sequentially.d.ts +1 -0
- package/dist/lib/sequentially.js +10 -0
- package/dist/lib/setupRepo.d.ts +2 -0
- package/dist/lib/setupRepo.js +56 -0
- package/dist/lib/setupRepo.test.d.ts +1 -0
- package/dist/lib/setupRepo.test.js +278 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.d.ts +16 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.js +102 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
- package/dist/lib/sourceCommit/getExpectedTargetPullRequests.test.js +467 -0
- package/dist/lib/sourceCommit/getMockSourceCommit.d.ts +26 -0
- package/dist/lib/sourceCommit/getMockSourceCommit.js +103 -0
- package/dist/lib/sourceCommit/parseSourceCommit.d.ts +108 -0
- package/dist/lib/sourceCommit/parseSourceCommit.js +123 -0
- package/dist/lib/sourceCommit/parseSourceCommit.test.d.ts +1 -0
- package/dist/lib/sourceCommit/parseSourceCommit.test.js +226 -0
- package/dist/options/ConfigOptions.d.ts +6 -4
- package/dist/options/cliArgs.d.ts +16 -9
- package/dist/options/cliArgs.js +54 -28
- package/dist/options/cliArgs.test.js +128 -4
- package/dist/options/config/config.d.ts +7 -6
- package/dist/options/config/config.js +5 -7
- package/dist/options/config/config.test.js +0 -1
- package/dist/options/config/globalConfig.d.ts +5 -3
- package/dist/options/config/globalConfig.js +17 -14
- package/dist/options/config/projectConfig.d.ts +2 -2
- package/dist/options/config/projectConfig.js +3 -3
- package/dist/options/config/projectConfig.test.js +19 -7
- package/dist/options/config/readConfigFile.d.ts +9 -7
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +44 -9
- package/dist/options/options.js +22 -27
- package/dist/options/options.test.js +119 -58
- package/dist/runSequentially.d.ts +14 -7
- package/dist/runSequentially.js +26 -11
- package/dist/scripts/postinstall.js +4 -3
- package/dist/scripts/postinstall.test.js +6 -2
- package/dist/services/BackportError.d.ts +19 -0
- package/dist/services/BackportError.js +29 -0
- package/dist/services/HandledBackportError.d.ts +19 -0
- package/dist/services/HandledBackportError.js +29 -0
- package/dist/services/HandledError.d.ts +7 -3
- package/dist/services/HandledError.js +13 -13
- package/dist/services/child-process-promisified.d.ts +19 -3
- package/dist/services/child-process-promisified.js +46 -17
- package/dist/services/git.d.ts +6 -7
- package/dist/services/git.integration.test.js +381 -65
- package/dist/services/git.js +189 -127
- package/dist/services/git.private.test.d.ts +1 -0
- package/dist/services/git.private.test.js +618 -0
- package/dist/services/git.test.js +167 -158
- package/dist/services/github/v3/addAssigneesToPullRequest.js +1 -1
- package/dist/services/github/v3/addLabelsToPullRequest.js +1 -1
- package/dist/services/github/v3/addReviewersToPullRequest.js +2 -1
- package/dist/services/github/v3/createPullRequest.js +4 -2
- package/dist/services/github/v3/createStatusComment.js +17 -17
- package/dist/services/github/v3/createStatusComment.test.js +22 -9
- package/dist/services/github/v4/apiRequestV4.js +8 -11
- package/dist/services/github/v4/apiRequestV4.test.js +2 -2
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +2 -4
- package/dist/services/github/v4/fetchAuthorId.private.test.js +3 -6
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +5 -6
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +4 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +10 -9
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +3 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +10 -9
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +4 -3
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +9 -8
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +3 -6
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +3 -2
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +3 -6
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +4 -7
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +2 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +2 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +6 -7
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +9 -8
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +5 -5
- package/dist/services/logger.d.ts +1 -4
- package/dist/services/logger.js +14 -19
- package/dist/services/test.d.ts +1 -0
- package/dist/services/test.js +23 -0
- package/dist/state.d.ts +0 -0
- package/dist/state.js +1 -0
- package/dist/test/e2e/cli/commit-author.private.test.js +4 -4
- package/dist/test/e2e/cli/different-merge-strategies.private.test.js +26 -24
- package/dist/test/e2e/cli/entrypoint.cli.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +450 -0
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +27 -28
- package/dist/test/e2e/cli/runBackportViaCli.d.ts +6 -2
- package/dist/test/e2e/cli/runBackportViaCli.js +44 -23
- package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +22 -14
- package/dist/test/e2e/module/entrypoint.module.mutation.test.d.ts +1 -0
- package/dist/test/e2e/module/entrypoint.module.mutation.test.js +376 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.js +12 -10
- package/dist/test/sandbox.js +5 -1
- package/dist/test/setupFiles/automatic-mocks.js +17 -13
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +11 -7
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +7 -159
- package/dist/ui/getCommits.js +2 -2
- package/dist/ui/getCommitsWithoutBackports.test.js +5 -1
- package/dist/ui/getGitConfigAuthor.js +1 -1
- package/dist/ui/getTargetBranches.js +3 -3
- package/dist/ui/getTargetBranches.test.js +5 -1
- package/dist/ui/ora.d.ts +1 -8
- package/dist/ui/setupRepo.js +3 -3
- package/dist/ui/setupRepo.test.js +98 -61
- package/dist/utils/isErrnoError.d.ts +2 -0
- package/dist/utils/isErrnoError.js +7 -0
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +17 -17
- package/yarn.lock +461 -695
|
@@ -4,7 +4,7 @@ exports.getTitle = exports.getPullRequestBody = exports.createPullRequest = void
|
|
|
4
4
|
const rest_1 = require("@octokit/rest");
|
|
5
5
|
const ora_1 = require("../../../ui/ora");
|
|
6
6
|
const packageVersion_1 = require("../../../utils/packageVersion");
|
|
7
|
-
const
|
|
7
|
+
const BackportError_1 = require("../../BackportError");
|
|
8
8
|
const logger_1 = require("../../logger");
|
|
9
9
|
const commitFormatters_1 = require("../commitFormatters");
|
|
10
10
|
const fetchExistingPullRequest_1 = require("../v4/fetchExistingPullRequest");
|
|
@@ -48,7 +48,9 @@ async function createPullRequest({ options, prPayload, }) {
|
|
|
48
48
|
// swallow error
|
|
49
49
|
}
|
|
50
50
|
spinner.fail();
|
|
51
|
-
throw new
|
|
51
|
+
throw new BackportError_1.BackportError(
|
|
52
|
+
//@ts-expect-error
|
|
53
|
+
`Could not create pull request: ${(0, getGithubV3ErrorMessage_1.getGithubV3ErrorMessage)(e)}`);
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
exports.createPullRequest = createPullRequest;
|
|
@@ -4,7 +4,7 @@ exports.getCommentBody = exports.createStatusComment = void 0;
|
|
|
4
4
|
const rest_1 = require("@octokit/rest");
|
|
5
5
|
const packageVersion_1 = require("../../../utils/packageVersion");
|
|
6
6
|
const redact_1 = require("../../../utils/redact");
|
|
7
|
-
const
|
|
7
|
+
const BackportError_1 = require("../../BackportError");
|
|
8
8
|
const logger_1 = require("../../logger");
|
|
9
9
|
const commitFormatters_1 = require("../commitFormatters");
|
|
10
10
|
async function createStatusComment({ options, backportResponse, }) {
|
|
@@ -32,7 +32,7 @@ async function createStatusComment({ options, backportResponse, }) {
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
return octokit.issues.createComment({
|
|
35
|
-
baseUrl:
|
|
35
|
+
baseUrl: githubApiBaseUrlV3,
|
|
36
36
|
owner: repoOwner,
|
|
37
37
|
repo: repoName,
|
|
38
38
|
issue_number: commit.sourcePullRequest.number,
|
|
@@ -41,7 +41,7 @@ async function createStatusComment({ options, backportResponse, }) {
|
|
|
41
41
|
}));
|
|
42
42
|
}
|
|
43
43
|
catch (e) {
|
|
44
|
-
logger_1.logger.info(`Could not create status comment `, e
|
|
44
|
+
logger_1.logger.info(`Could not create status comment `, e);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
exports.createStatusComment = createStatusComment;
|
|
@@ -49,8 +49,8 @@ function getCommentBody({ options, pullNumber, backportResponse, }) {
|
|
|
49
49
|
const { repoName, repoOwner, autoMerge } = options;
|
|
50
50
|
// custom handling when running backport locally (as opposed to on CI)
|
|
51
51
|
if (!options.ci) {
|
|
52
|
-
//
|
|
53
|
-
if (backportResponse.status
|
|
52
|
+
// only post successful backports when not running in CI
|
|
53
|
+
if (backportResponse.status !== 'success') {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
56
|
// only post a comment if all backports succeeded
|
|
@@ -60,15 +60,15 @@ function getCommentBody({ options, pullNumber, backportResponse, }) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
const packageVersionSection = `\n<!--- Backport version: ${packageVersion_1.PACKAGE_VERSION} -->`;
|
|
63
|
-
const manualBackportCommand = `\n### Manual backport\nTo create the backport manually run:\n\`\`\`\n${options.backportBinary} --pr ${pullNumber}\n
|
|
64
|
-
const questionsAndLinkToBackport = '\n
|
|
65
|
-
if (backportResponse.status === '
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return `## ⚪ Backport skipped
|
|
63
|
+
const manualBackportCommand = `\n### Manual backport\nTo create the backport manually run:\n\`\`\`\n${options.backportBinary} --pr ${pullNumber}\n\`\`\`\n`;
|
|
64
|
+
const questionsAndLinkToBackport = '\n### Questions ?\nPlease refer to the [Backport tool documentation](https://github.com/sqren/backport)\n';
|
|
65
|
+
if (backportResponse.status === 'aborted' &&
|
|
66
|
+
backportResponse.error.errorContext.code === 'no-branches-exception') {
|
|
67
|
+
return `## ⚪ Backport skipped
|
|
69
68
|
The pull request was not backported as there were no branches to backport to. If this is a mistake, please apply the desired version labels or run the backport tool manually.
|
|
70
69
|
${manualBackportCommand}${questionsAndLinkToBackport}${packageVersionSection}`;
|
|
71
|
-
|
|
70
|
+
}
|
|
71
|
+
if (backportResponse.status !== 'success') {
|
|
72
72
|
return `## 💔 Backport failed
|
|
73
73
|
The pull request could not be backported due to the following error:
|
|
74
74
|
\`${backportResponse.error.message}\`
|
|
@@ -87,7 +87,8 @@ ${manualBackportCommand}${questionsAndLinkToBackport}${packageVersionSection}`;
|
|
|
87
87
|
`[<img src="https://img.shields.io/github/pulls/detail/state/${repoOwner}/${repoName}/${result.pullRequestNumber}">](${result.pullRequestUrl})`,
|
|
88
88
|
];
|
|
89
89
|
}
|
|
90
|
-
if (result.error
|
|
90
|
+
if (result.error instanceof BackportError_1.BackportError &&
|
|
91
|
+
result.error.errorContext.code === 'merge-conflict-exception') {
|
|
91
92
|
const unmergedBackports = result.error.errorContext.commitsWithoutBackports.map((c) => {
|
|
92
93
|
return ` - [${(0, commitFormatters_1.getFirstLine)(c.commit.sourceCommit.message)}](${c.commit.sourcePullRequest?.url})`;
|
|
93
94
|
});
|
|
@@ -105,7 +106,7 @@ ${manualBackportCommand}${questionsAndLinkToBackport}${packageVersionSection}`;
|
|
|
105
106
|
.map((line) => line.join('|'))
|
|
106
107
|
.join('|\n|');
|
|
107
108
|
const table = backportResponse.results.length
|
|
108
|
-
?
|
|
109
|
+
? `\n\n| Status | Branch | Result |\n|:------:|:------:|:------|\n|${tableBody}|\n`
|
|
109
110
|
: '';
|
|
110
111
|
const didAllBackportsSucceed = backportResponse.results.every((r) => r.status === 'success');
|
|
111
112
|
const didAnyBackportsSucceed = backportResponse.results.some((r) => r.status === 'success');
|
|
@@ -120,12 +121,11 @@ ${manualBackportCommand}${questionsAndLinkToBackport}${packageVersionSection}`;
|
|
|
120
121
|
header = '## 💔 All backports failed';
|
|
121
122
|
}
|
|
122
123
|
const autoMergeMessage = autoMerge && didAnyBackportsSucceed
|
|
123
|
-
? '\nNote: Successful backport PRs will be merged automatically after passing CI
|
|
124
|
+
? '\nNote: Successful backport PRs will be merged automatically after passing CI.\n'
|
|
124
125
|
: '';
|
|
125
126
|
const backportPRCommandMessage = !didAllBackportsSucceed
|
|
126
127
|
? `${manualBackportCommand}`
|
|
127
128
|
: '';
|
|
128
|
-
return `${header}
|
|
129
|
-
${backportPRCommandMessage}${autoMergeMessage}${questionsAndLinkToBackport}${packageVersionSection}`;
|
|
129
|
+
return `${header}${table}${autoMergeMessage}${backportPRCommandMessage}${questionsAndLinkToBackport}${packageVersionSection}`;
|
|
130
130
|
}
|
|
131
131
|
exports.getCommentBody = getCommentBody;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const nock_1 = __importDefault(require("nock"));
|
|
7
|
-
const
|
|
7
|
+
const BackportError_1 = require("../../BackportError");
|
|
8
8
|
const createStatusComment_1 = require("./createStatusComment");
|
|
9
9
|
describe('createStatusComment', () => {
|
|
10
10
|
it('redacts accessToken if it is included in the error message', async () => {
|
|
@@ -65,6 +65,7 @@ describe('getCommentBody', () => {
|
|
|
65
65
|
|
|
66
66
|
### Questions ?
|
|
67
67
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
68
|
+
|
|
68
69
|
<!--- Backport version: 1.2.3-mocked -->"
|
|
69
70
|
`);
|
|
70
71
|
});
|
|
@@ -114,6 +115,7 @@ describe('getCommentBody', () => {
|
|
|
114
115
|
|
|
115
116
|
### Questions ?
|
|
116
117
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
118
|
+
|
|
117
119
|
<!--- Backport version: 1.2.3-mocked -->"
|
|
118
120
|
`);
|
|
119
121
|
});
|
|
@@ -131,6 +133,7 @@ describe('getCommentBody', () => {
|
|
|
131
133
|
|
|
132
134
|
### Questions ?
|
|
133
135
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
136
|
+
|
|
134
137
|
<!--- Backport version: 1.2.3-mocked -->"
|
|
135
138
|
`);
|
|
136
139
|
});
|
|
@@ -149,12 +152,12 @@ describe('getCommentBody', () => {
|
|
|
149
152
|
status: 'success',
|
|
150
153
|
results: [
|
|
151
154
|
{
|
|
152
|
-
status: '
|
|
155
|
+
status: 'unhandled-error',
|
|
153
156
|
targetBranch: '7.x',
|
|
154
157
|
error: new Error('My boom error!'),
|
|
155
158
|
},
|
|
156
159
|
{
|
|
157
|
-
status: '
|
|
160
|
+
status: 'unhandled-error',
|
|
158
161
|
targetBranch: '7.1',
|
|
159
162
|
error: new Error('My boom error!'),
|
|
160
163
|
},
|
|
@@ -179,6 +182,7 @@ describe('getCommentBody', () => {
|
|
|
179
182
|
|
|
180
183
|
### Questions ?
|
|
181
184
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
185
|
+
|
|
182
186
|
<!--- Backport version: 1.2.3-mocked -->"
|
|
183
187
|
`);
|
|
184
188
|
});
|
|
@@ -224,15 +228,17 @@ describe('getCommentBody', () => {
|
|
|
224
228
|
|✅|7.x|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/55\\">](url-to-pr-55)|
|
|
225
229
|
|❌|7.1|My boom error!|
|
|
226
230
|
|
|
231
|
+
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
232
|
+
|
|
227
233
|
### Manual backport
|
|
228
234
|
To create the backport manually run:
|
|
229
235
|
\`\`\`
|
|
230
236
|
node scripts/backport --pr 55
|
|
231
237
|
\`\`\`
|
|
232
|
-
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
233
238
|
|
|
234
239
|
### Questions ?
|
|
235
240
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
241
|
+
|
|
236
242
|
<!--- Backport version: 1.2.3-mocked -->"
|
|
237
243
|
`);
|
|
238
244
|
});
|
|
@@ -263,8 +269,9 @@ describe('getCommentBody', () => {
|
|
|
263
269
|
{
|
|
264
270
|
status: 'failure',
|
|
265
271
|
targetBranch: '7.1',
|
|
266
|
-
error: new
|
|
272
|
+
error: new BackportError_1.BackportError({
|
|
267
273
|
code: 'merge-conflict-exception',
|
|
274
|
+
conflictingFiles: ['readme.md'],
|
|
268
275
|
commitsWithoutBackports: [
|
|
269
276
|
{
|
|
270
277
|
formatted: 'some-formatted-text',
|
|
@@ -320,8 +327,9 @@ describe('getCommentBody', () => {
|
|
|
320
327
|
{
|
|
321
328
|
status: 'failure',
|
|
322
329
|
targetBranch: '7.2',
|
|
323
|
-
error: new
|
|
330
|
+
error: new BackportError_1.BackportError({
|
|
324
331
|
code: 'merge-conflict-exception',
|
|
332
|
+
conflictingFiles: ['my-file.txt'],
|
|
325
333
|
commitsWithoutBackports: [],
|
|
326
334
|
}),
|
|
327
335
|
},
|
|
@@ -339,15 +347,17 @@ describe('getCommentBody', () => {
|
|
|
339
347
|
|❌|7.1|**Backport failed because of merge conflicts**<br><br>You might need to backport the following PRs to 7.1:<br> - [New Zealand commit message](url-to-pr-5)<br> - [Australia commit](url-to-pr-44)|
|
|
340
348
|
|❌|7.2|**Backport failed because of merge conflicts**|
|
|
341
349
|
|
|
350
|
+
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
351
|
+
|
|
342
352
|
### Manual backport
|
|
343
353
|
To create the backport manually run:
|
|
344
354
|
\`\`\`
|
|
345
355
|
node scripts/backport --pr 55
|
|
346
356
|
\`\`\`
|
|
347
|
-
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
348
357
|
|
|
349
358
|
### Questions ?
|
|
350
359
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
360
|
+
|
|
351
361
|
<!--- Backport version: 1.2.3-mocked -->"
|
|
352
362
|
`);
|
|
353
363
|
});
|
|
@@ -367,8 +377,10 @@ describe('getCommentBody', () => {
|
|
|
367
377
|
},
|
|
368
378
|
pullNumber: 55,
|
|
369
379
|
backportResponse: {
|
|
370
|
-
status: '
|
|
371
|
-
|
|
380
|
+
status: 'aborted',
|
|
381
|
+
commits: [],
|
|
382
|
+
error: new BackportError_1.BackportError({ code: 'no-branches-exception' }),
|
|
383
|
+
errorMessage: 'my message',
|
|
372
384
|
},
|
|
373
385
|
});
|
|
374
386
|
it('posts a comment when running on CI', () => {
|
|
@@ -385,6 +397,7 @@ describe('getCommentBody', () => {
|
|
|
385
397
|
|
|
386
398
|
### Questions ?
|
|
387
399
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
400
|
+
|
|
388
401
|
<!--- Backport version: 1.2.3-mocked -->"
|
|
389
402
|
`);
|
|
390
403
|
});
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getQueryName = exports.GithubV4Exception = exports.apiRequestV4 = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const printer_1 = require("graphql/language/printer");
|
|
9
|
-
const
|
|
9
|
+
const BackportError_1 = require("../../BackportError");
|
|
10
10
|
const logger_1 = require("../../logger");
|
|
11
11
|
async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graphql', accessToken, query, variables, }) {
|
|
12
12
|
try {
|
|
@@ -24,7 +24,6 @@ async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graph
|
|
|
24
24
|
query,
|
|
25
25
|
variables,
|
|
26
26
|
githubResponse: response,
|
|
27
|
-
didSucceed: false,
|
|
28
27
|
});
|
|
29
28
|
return response.data.data;
|
|
30
29
|
}
|
|
@@ -35,7 +34,6 @@ async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graph
|
|
|
35
34
|
query,
|
|
36
35
|
variables,
|
|
37
36
|
githubResponse: e.response,
|
|
38
|
-
didSucceed: false,
|
|
39
37
|
});
|
|
40
38
|
throw new GithubV4Exception(e.response, e.message);
|
|
41
39
|
}
|
|
@@ -43,15 +41,14 @@ async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graph
|
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
exports.apiRequestV4 = apiRequestV4;
|
|
46
|
-
function addDebugLogs({ githubApiBaseUrlV4, query, variables, githubResponse,
|
|
44
|
+
function addDebugLogs({ githubApiBaseUrlV4, query, variables, githubResponse, }) {
|
|
47
45
|
const gqlQueryName = getQueryName(query);
|
|
48
46
|
logger_1.logger.info(`POST ${githubApiBaseUrlV4} (name:${gqlQueryName}, status: ${githubResponse.status})`);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
logMethod('Response data:', githubResponse.data);
|
|
47
|
+
logger_1.logger.info(`Query name ${gqlQueryName}`);
|
|
48
|
+
logger_1.logger.info(`Query: ${query}`);
|
|
49
|
+
logger_1.logger.info('Variables:', variables);
|
|
50
|
+
logger_1.logger.info('Response headers:', githubResponse.headers);
|
|
51
|
+
logger_1.logger.info('Response data:', githubResponse.data);
|
|
55
52
|
}
|
|
56
53
|
class GithubV4Exception extends Error {
|
|
57
54
|
constructor(githubResponse, errorMessage) {
|
|
@@ -60,7 +57,7 @@ class GithubV4Exception extends Error {
|
|
|
60
57
|
.join(',');
|
|
61
58
|
const message = `${errorMessage ?? githubMessage ?? 'Unknown error'} (Github API v4)`;
|
|
62
59
|
super(message);
|
|
63
|
-
Error.captureStackTrace(this,
|
|
60
|
+
Error.captureStackTrace(this, BackportError_1.BackportError);
|
|
64
61
|
this.name = 'GithubV4Exception';
|
|
65
62
|
this.message = message;
|
|
66
63
|
this.githubResponse = { ...githubResponse, request: undefined };
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
7
7
|
const nock_1 = __importDefault(require("nock"));
|
|
8
8
|
const nockHelpers_1 = require("../../../test/nockHelpers");
|
|
9
|
-
const
|
|
9
|
+
const BackportError_1 = require("../../BackportError");
|
|
10
10
|
const apiRequestV4_1 = require("./apiRequestV4");
|
|
11
11
|
describe('apiRequestV4', () => {
|
|
12
12
|
afterEach(() => {
|
|
@@ -78,7 +78,7 @@ describe('apiRequestV4', () => {
|
|
|
78
78
|
variables: {
|
|
79
79
|
foo: 'bar',
|
|
80
80
|
},
|
|
81
|
-
})).rejects.toThrowError(new
|
|
81
|
+
})).rejects.toThrowError(new BackportError_1.BackportError(`some error,some other error (Github API v4)`));
|
|
82
82
|
});
|
|
83
83
|
});
|
|
84
84
|
describe('when request fails without error messages', () => {
|
|
@@ -43,10 +43,8 @@ async function enablePullRequestAutoMerge(options, targetPullRequestNumber) {
|
|
|
43
43
|
return res.enablePullRequestAutoMerge.pullRequest?.number;
|
|
44
44
|
}
|
|
45
45
|
catch (e) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
logger_1.logger.info(`Could not enable auto merging for ${targetPullRequestNumber}`, e.stack);
|
|
49
|
-
}
|
|
46
|
+
spinner.fail();
|
|
47
|
+
logger_1.logger.info(`Could not enable auto merging for ${targetPullRequestNumber}`, e);
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
exports.enablePullRequestAutoMerge = enablePullRequestAutoMerge;
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
4
4
|
const fetchAuthorId_1 = require("./fetchAuthorId");
|
|
5
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
5
6
|
describe('fetchAuthorId', () => {
|
|
6
|
-
let devAccessToken;
|
|
7
|
-
beforeAll(() => {
|
|
8
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
|
-
});
|
|
10
7
|
describe('author = null', () => {
|
|
11
8
|
it('returns null', async () => {
|
|
12
9
|
const options = {
|
|
13
|
-
accessToken
|
|
10
|
+
accessToken,
|
|
14
11
|
author: null,
|
|
15
12
|
};
|
|
16
13
|
expect(await (0, fetchAuthorId_1.fetchAuthorId)(options)).toEqual(null);
|
|
@@ -19,7 +16,7 @@ describe('fetchAuthorId', () => {
|
|
|
19
16
|
describe('author is "sqren"', () => {
|
|
20
17
|
it('returns author id', async () => {
|
|
21
18
|
const options = {
|
|
22
|
-
accessToken
|
|
19
|
+
accessToken,
|
|
23
20
|
author: 'sqren',
|
|
24
21
|
};
|
|
25
22
|
expect(await (0, fetchAuthorId_1.fetchAuthorId)(options)).toEqual('MDQ6VXNlcjIwOTk2Ng==');
|
|
@@ -5,13 +5,12 @@ const fetchCommitByPullNumber_1 = require("./fetchCommitByPullNumber");
|
|
|
5
5
|
const fetchCommitBySha_1 = require("./fetchCommitBySha");
|
|
6
6
|
const fetchCommitsByAuthor_1 = require("./fetchCommitsByAuthor");
|
|
7
7
|
const fetchPullRequestsBySearchQuery_1 = require("./fetchPullRequestsBySearchQuery");
|
|
8
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
8
9
|
describe('allFetchers', () => {
|
|
9
|
-
let devAccessToken;
|
|
10
10
|
let commitByAuthor;
|
|
11
11
|
beforeEach(async () => {
|
|
12
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
13
12
|
const commitsByAuthor = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
14
|
-
accessToken
|
|
13
|
+
accessToken,
|
|
15
14
|
author: 'sqren',
|
|
16
15
|
maxNumber: 1,
|
|
17
16
|
repoName: 'kibana',
|
|
@@ -30,7 +29,7 @@ describe('allFetchers', () => {
|
|
|
30
29
|
const commitByPullNumber = await (0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)({
|
|
31
30
|
repoOwner: 'elastic',
|
|
32
31
|
repoName: 'kibana',
|
|
33
|
-
accessToken
|
|
32
|
+
accessToken,
|
|
34
33
|
pullNumber: commitByAuthor.sourcePullRequest.number,
|
|
35
34
|
sourceBranch: 'master',
|
|
36
35
|
});
|
|
@@ -40,7 +39,7 @@ describe('allFetchers', () => {
|
|
|
40
39
|
const commitBySha = await (0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
41
40
|
repoOwner: 'elastic',
|
|
42
41
|
repoName: 'kibana',
|
|
43
|
-
accessToken
|
|
42
|
+
accessToken,
|
|
44
43
|
sha: commitByAuthor.sourceCommit.sha,
|
|
45
44
|
sourceBranch: 'main',
|
|
46
45
|
});
|
|
@@ -50,7 +49,7 @@ describe('allFetchers', () => {
|
|
|
50
49
|
const commitsBySearchQuery = await (0, fetchPullRequestsBySearchQuery_1.fetchPullRequestsBySearchQuery)({
|
|
51
50
|
repoOwner: 'elastic',
|
|
52
51
|
repoName: 'kibana',
|
|
53
|
-
accessToken
|
|
52
|
+
accessToken,
|
|
54
53
|
maxNumber: 1,
|
|
55
54
|
prFilter: `created:2021-12-20..2021-12-20`,
|
|
56
55
|
sourceBranch: 'main',
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fetchCommitByPullNumber = void 0;
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
-
const
|
|
8
|
+
const BackportError_1 = require("../../../BackportError");
|
|
9
9
|
const remoteConfig_1 = require("../../../remoteConfig");
|
|
10
10
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
11
11
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
@@ -42,15 +42,16 @@ async function fetchCommitByPullNumber(options) {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
catch (e) {
|
|
45
|
+
//@ts-expect-error
|
|
45
46
|
res = (0, remoteConfig_1.swallowMissingConfigFileException)(e);
|
|
46
47
|
}
|
|
47
48
|
const pullRequestNode = res.repository.pullRequest;
|
|
48
49
|
if (!pullRequestNode) {
|
|
49
|
-
throw new
|
|
50
|
+
throw new BackportError_1.BackportError(`The PR #${pullNumber} does not exist`);
|
|
50
51
|
}
|
|
51
52
|
const sourceCommit = pullRequestNode.mergeCommit;
|
|
52
53
|
if (sourceCommit === null) {
|
|
53
|
-
throw new
|
|
54
|
+
throw new BackportError_1.BackportError(`The PR #${pullNumber} is not merged`);
|
|
54
55
|
}
|
|
55
56
|
return (0, parseSourceCommit_1.parseSourceCommit)({ options, sourceCommit });
|
|
56
57
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -23,11 +27,8 @@ const graphql_1 = require("graphql");
|
|
|
23
27
|
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
24
28
|
const apiRequestV4Module = __importStar(require("../apiRequestV4"));
|
|
25
29
|
const fetchCommitByPullNumber_1 = require("./fetchCommitByPullNumber");
|
|
30
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
26
31
|
describe('fetchCommitByPullNumber', () => {
|
|
27
|
-
let devAccessToken;
|
|
28
|
-
beforeAll(() => {
|
|
29
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
30
|
-
});
|
|
31
32
|
describe('snapshot request/response', () => {
|
|
32
33
|
let spy;
|
|
33
34
|
let commit;
|
|
@@ -36,7 +37,7 @@ describe('fetchCommitByPullNumber', () => {
|
|
|
36
37
|
commit = await (0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)({
|
|
37
38
|
repoOwner: 'elastic',
|
|
38
39
|
repoName: 'kibana',
|
|
39
|
-
accessToken
|
|
40
|
+
accessToken,
|
|
40
41
|
pullNumber: 121633,
|
|
41
42
|
sourceBranch: 'master',
|
|
42
43
|
});
|
|
@@ -60,7 +61,7 @@ describe('fetchCommitByPullNumber', () => {
|
|
|
60
61
|
describe('when PR was merged', () => {
|
|
61
62
|
it('is returned', async () => {
|
|
62
63
|
const options = {
|
|
63
|
-
accessToken
|
|
64
|
+
accessToken,
|
|
64
65
|
pullNumber: 5,
|
|
65
66
|
repoName: 'backport-e2e',
|
|
66
67
|
repoOwner: 'backport-org',
|
|
@@ -111,7 +112,7 @@ describe('fetchCommitByPullNumber', () => {
|
|
|
111
112
|
describe('when PR is still open', () => {
|
|
112
113
|
it('throws an error', async () => {
|
|
113
114
|
const options = {
|
|
114
|
-
accessToken
|
|
115
|
+
accessToken,
|
|
115
116
|
pullNumber: 11,
|
|
116
117
|
repoName: 'backport-e2e',
|
|
117
118
|
repoOwner: 'backport-org',
|
|
@@ -123,7 +124,7 @@ describe('fetchCommitByPullNumber', () => {
|
|
|
123
124
|
describe('when PR does not exist', () => {
|
|
124
125
|
it('throws an error', async () => {
|
|
125
126
|
const options = {
|
|
126
|
-
accessToken
|
|
127
|
+
accessToken,
|
|
127
128
|
pullNumber: 9999999999999,
|
|
128
129
|
repoName: 'backport-e2e',
|
|
129
130
|
repoOwner: 'backport-org',
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fetchCommitBySha = void 0;
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
-
const
|
|
8
|
+
const BackportError_1 = require("../../../BackportError");
|
|
9
9
|
const remoteConfig_1 = require("../../../remoteConfig");
|
|
10
10
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
11
11
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
@@ -36,11 +36,12 @@ async function fetchCommitBySha(options) {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
catch (e) {
|
|
39
|
+
//@ts-expect-error
|
|
39
40
|
res = (0, remoteConfig_1.swallowMissingConfigFileException)(e);
|
|
40
41
|
}
|
|
41
42
|
const sourceCommit = res.repository.object;
|
|
42
43
|
if (!sourceCommit) {
|
|
43
|
-
throw new
|
|
44
|
+
throw new BackportError_1.BackportError(`No commit found on branch "${sourceBranch}" with sha "${sha}"`);
|
|
44
45
|
}
|
|
45
46
|
return (0, parseSourceCommit_1.parseSourceCommit)({ options, sourceCommit });
|
|
46
47
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -23,11 +27,8 @@ const graphql_1 = require("graphql");
|
|
|
23
27
|
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
24
28
|
const apiRequestV4Module = __importStar(require("../apiRequestV4"));
|
|
25
29
|
const fetchCommitBySha_1 = require("./fetchCommitBySha");
|
|
30
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
26
31
|
describe('fetchCommitBySha', () => {
|
|
27
|
-
let devAccessToken;
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
30
|
-
});
|
|
31
32
|
describe('snapshot request/response', () => {
|
|
32
33
|
let spy;
|
|
33
34
|
let commit;
|
|
@@ -36,7 +37,7 @@ describe('fetchCommitBySha', () => {
|
|
|
36
37
|
commit = await (0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
37
38
|
repoOwner: 'elastic',
|
|
38
39
|
repoName: 'kibana',
|
|
39
|
-
accessToken
|
|
40
|
+
accessToken,
|
|
40
41
|
sha: 'd421ddcf6157150596581c7885afa3690cec6339',
|
|
41
42
|
sourceBranch: 'main',
|
|
42
43
|
});
|
|
@@ -91,7 +92,7 @@ describe('fetchCommitBySha', () => {
|
|
|
91
92
|
await expect(await (0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
92
93
|
repoOwner: 'elastic',
|
|
93
94
|
repoName: 'kibana',
|
|
94
|
-
accessToken
|
|
95
|
+
accessToken,
|
|
95
96
|
sha: 'cb6fbc0',
|
|
96
97
|
sourceBranch: 'master',
|
|
97
98
|
})).toEqual(expectedCommit);
|
|
@@ -100,7 +101,7 @@ describe('fetchCommitBySha', () => {
|
|
|
100
101
|
await expect((0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
101
102
|
repoOwner: 'elastic',
|
|
102
103
|
repoName: 'kibana',
|
|
103
|
-
accessToken
|
|
104
|
+
accessToken,
|
|
104
105
|
sha: 'fc22f59',
|
|
105
106
|
sourceBranch: 'main',
|
|
106
107
|
})).rejects.toThrowError('No commit found on branch "main" with sha "fc22f59"');
|
|
@@ -109,7 +110,7 @@ describe('fetchCommitBySha', () => {
|
|
|
109
110
|
await expect((0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
110
111
|
repoOwner: 'elastic',
|
|
111
112
|
repoName: 'kibana',
|
|
112
|
-
accessToken
|
|
113
|
+
accessToken,
|
|
113
114
|
sha: 'myCommitSha',
|
|
114
115
|
sourceBranch: 'main',
|
|
115
116
|
})).rejects.toThrowError('No commit found on branch "main" with sha "myCommitSha"');
|
|
@@ -8,7 +8,7 @@ const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
9
|
const filterEmpty_1 = require("../../../../utils/filterEmpty");
|
|
10
10
|
const filterUnmergedCommits_1 = require("../../../../utils/filterUnmergedCommits");
|
|
11
|
-
const
|
|
11
|
+
const BackportError_1 = require("../../../BackportError");
|
|
12
12
|
const remoteConfig_1 = require("../../../remoteConfig");
|
|
13
13
|
const parseSourceCommit_1 = require("../../../sourceCommit/parseSourceCommit");
|
|
14
14
|
const apiRequestV4_1 = require("../apiRequestV4");
|
|
@@ -70,6 +70,7 @@ async function fetchByCommitPath({ options, authorId, commitPath, }) {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
catch (e) {
|
|
73
|
+
//@ts-expect-error
|
|
73
74
|
return (0, remoteConfig_1.swallowMissingConfigFileException)(e);
|
|
74
75
|
}
|
|
75
76
|
}
|
|
@@ -81,7 +82,7 @@ async function fetchCommitsByAuthor(options) {
|
|
|
81
82
|
: commitPaths.map((commitPath) => fetchByCommitPath({ options, authorId, commitPath })));
|
|
82
83
|
// we only need to check if the first item is `null` (if the first is `null` they all are)
|
|
83
84
|
if (responses[0].repository.ref === null) {
|
|
84
|
-
throw new
|
|
85
|
+
throw new BackportError_1.BackportError(`The upstream branch "${sourceBranch}" does not exist. Try specifying a different branch with "--source-branch <your-branch>"`);
|
|
85
86
|
}
|
|
86
87
|
const commits = responses
|
|
87
88
|
.flatMap((res) => {
|
|
@@ -97,7 +98,7 @@ async function fetchCommitsByAuthor(options) {
|
|
|
97
98
|
const errorText = options.author
|
|
98
99
|
? `There are no commits by "${options.author}" in this repository${pathText}. Try with \`--all\` for commits by all users or \`--author=<username>\` for commits from a specific user`
|
|
99
100
|
: `There are no commits in this repository${pathText}`;
|
|
100
|
-
throw new
|
|
101
|
+
throw new BackportError_1.BackportError(errorText);
|
|
101
102
|
}
|
|
102
103
|
const commitsUnique = (0, lodash_1.uniqBy)(commits, (c) => c.sourceCommit.sha);
|
|
103
104
|
const commitsSorted = (0, lodash_1.orderBy)(commitsUnique, (c) => c.sourceCommit.committedDate, 'desc');
|