backport 6.1.5 → 6.3.0-beta-2
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/{main.d.ts → backportRun.d.ts} +3 -3
- package/dist/{main.js → backportRun.js} +21 -10
- package/dist/{entrypoint.module.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/{options/getValidatedOptions.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 +5 -1
- package/dist/options/cliArgs.d.ts +16 -14
- package/dist/options/cliArgs.js +15 -5
- package/dist/options/cliArgs.test.js +28 -10
- package/dist/options/config/config.d.ts +10 -4
- 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 +19 -32
- 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 +27 -23
- package/dist/options/config/readConfigFile.js +2 -2
- package/dist/options/options.d.ts +18 -39
- package/dist/options/options.js +40 -32
- package/dist/options/options.test.js +83 -47
- package/dist/runSequentially.d.ts +0 -1
- package/dist/runSequentially.js +0 -1
- package/dist/runSequentially.test.js +39 -20
- 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 +165 -70
- package/dist/services/github/v3/getGithubV3ErrorMessage.d.ts +2 -1
- 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 +38 -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 +6 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +41 -34
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +6 -0
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +2 -1
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.d.ts +29 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +56 -0
- package/dist/{options/parseRequiredOptions.test.d.ts → services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts} +0 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +71 -0
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +11 -11
- package/dist/services/github/v4/throwOnInvalidAccessToken.d.ts +4 -5
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +10 -7
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +5 -5
- package/dist/services/logger.d.ts +9 -3
- package/dist/services/logger.js +38 -35
- 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/{integration/integration.private.test.js → backport-e2e.mutation.test.js} +143 -123
- package/dist/{scripts/generate-gql.d.ts → test/handleUnbackportedPullRequests.private.test.d.ts} +0 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.js +57 -0
- 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/test/sandbox.js +43 -0
- 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 -14
- package/dist/utils/maybe.d.ts +1 -0
- package/dist/utils/maybe.js +7 -0
- package/dist/utils/packageVersion.d.ts +1 -0
- package/dist/{types/PromiseReturnType.js → utils/packageVersion.js} +2 -0
- package/package.json +24 -20
- package/yarn.lock +160 -237
- 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/options/config/getOptionsFromGit.d.ts +0 -4
- package/dist/options/config/getOptionsFromGit.js +0 -8
- 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/runWithOptions.d.ts +0 -9
- package/dist/runWithOptions.js +0 -43
- package/dist/runWithOptions.test.js +0 -304
- package/dist/scripts/generate-gql.js +0 -15
- package/dist/services/fs-promisified.d.ts +0 -6
- package/dist/services/fs-promisified.js +0 -12
- 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/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/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/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.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
|
@@ -1,7 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const nock_1 = __importDefault(require("nock"));
|
|
3
7
|
const HandledError_1 = require("../../HandledError");
|
|
4
8
|
const createStatusComment_1 = require("./createStatusComment");
|
|
9
|
+
describe('createStatusComment', () => {
|
|
10
|
+
it('redacts accessToken if it is included in the error message', async () => {
|
|
11
|
+
const accessToken = 'ghp_abcdefg';
|
|
12
|
+
const scope = (0, nock_1.default)('https://api.github.com')
|
|
13
|
+
.post('/repos/elastic/kibana/issues/100/comments')
|
|
14
|
+
.reply(200, 'some response');
|
|
15
|
+
let postedCommentBody = '';
|
|
16
|
+
scope.on('request', (req, interceptor, body) => {
|
|
17
|
+
postedCommentBody = JSON.parse(body).body;
|
|
18
|
+
});
|
|
19
|
+
await (0, createStatusComment_1.createStatusComment)({
|
|
20
|
+
options: {
|
|
21
|
+
repoName: 'kibana',
|
|
22
|
+
repoOwner: 'elastic',
|
|
23
|
+
accessToken,
|
|
24
|
+
backportBinary: 'node scripts/backport',
|
|
25
|
+
publishStatusComment: true,
|
|
26
|
+
githubApiBaseUrlV3: 'https://api.github.com',
|
|
27
|
+
ci: true,
|
|
28
|
+
},
|
|
29
|
+
backportResponse: {
|
|
30
|
+
commits: [{ sourcePullRequest: { number: 100 } }],
|
|
31
|
+
status: 'failure',
|
|
32
|
+
error: new Error(`Error message containing very secret access token: ${accessToken}.`),
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
expect(postedCommentBody).toContain('Error message containing very secret access token: <REDACTED>');
|
|
36
|
+
scope.done();
|
|
37
|
+
nock_1.default.cleanAll();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
5
40
|
describe('getCommentBody', () => {
|
|
6
41
|
describe('when an unknown error occurs', () => {
|
|
7
42
|
const getParams = (opts) => ({
|
|
@@ -12,25 +47,26 @@ describe('getCommentBody', () => {
|
|
|
12
47
|
pullNumber: 55,
|
|
13
48
|
backportResponse: {
|
|
14
49
|
status: 'failure',
|
|
15
|
-
|
|
50
|
+
error: new Error('A terrible error occured'),
|
|
16
51
|
},
|
|
17
52
|
});
|
|
18
53
|
it('posts a comment when running on ci', () => {
|
|
19
54
|
const params = getParams({ ci: true });
|
|
20
55
|
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
56
|
+
"## 💔 Backport failed
|
|
57
|
+
The pull request could not be backported due to the following error:
|
|
58
|
+
\`A terrible error occured\`
|
|
24
59
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
60
|
+
### Manual backport
|
|
61
|
+
To create the backport manually run:
|
|
62
|
+
\`\`\`
|
|
63
|
+
node scripts/backport --pr 55
|
|
64
|
+
\`\`\`
|
|
30
65
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
66
|
+
### Questions ?
|
|
67
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
68
|
+
<!--- Backport version: 1.2.3 -->"
|
|
69
|
+
`);
|
|
34
70
|
});
|
|
35
71
|
it('does not post a comment when running manually', () => {
|
|
36
72
|
const params = getParams({ ci: false });
|
|
@@ -67,34 +103,36 @@ describe('getCommentBody', () => {
|
|
|
67
103
|
it('posts a comment on ci', () => {
|
|
68
104
|
const params = getParams({ ci: true });
|
|
69
105
|
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
70
|
-
|
|
106
|
+
"## 💚 All backports created successfully
|
|
71
107
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
108
|
+
| Status | Branch | Result |
|
|
109
|
+
|:------:|:------:|:------|
|
|
110
|
+
|✅|7.x|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/55\\">](url-to-pr)|
|
|
111
|
+
|✅|7.1|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/66\\">](url-to-pr)|
|
|
76
112
|
|
|
77
|
-
|
|
113
|
+
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
78
114
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
115
|
+
### Questions ?
|
|
116
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
117
|
+
<!--- Backport version: 1.2.3 -->"
|
|
118
|
+
`);
|
|
82
119
|
});
|
|
83
120
|
it('posts a comment when running locally', () => {
|
|
84
121
|
const params = getParams({ ci: false });
|
|
85
122
|
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
86
|
-
|
|
123
|
+
"## 💚 All backports created successfully
|
|
87
124
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
125
|
+
| Status | Branch | Result |
|
|
126
|
+
|:------:|:------:|:------|
|
|
127
|
+
|✅|7.x|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/55\\">](url-to-pr)|
|
|
128
|
+
|✅|7.1|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/66\\">](url-to-pr)|
|
|
92
129
|
|
|
93
|
-
|
|
130
|
+
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
94
131
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
132
|
+
### Questions ?
|
|
133
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
134
|
+
<!--- Backport version: 1.2.3 -->"
|
|
135
|
+
`);
|
|
98
136
|
});
|
|
99
137
|
});
|
|
100
138
|
describe('when all backports fail', () => {
|
|
@@ -113,14 +151,12 @@ describe('getCommentBody', () => {
|
|
|
113
151
|
{
|
|
114
152
|
status: 'failure',
|
|
115
153
|
targetBranch: '7.x',
|
|
116
|
-
error: new Error('
|
|
117
|
-
errorMessage: 'My boom error!',
|
|
154
|
+
error: new Error('My boom error!'),
|
|
118
155
|
},
|
|
119
156
|
{
|
|
120
157
|
status: 'failure',
|
|
121
158
|
targetBranch: '7.1',
|
|
122
|
-
error: new Error('
|
|
123
|
-
errorMessage: 'My boom error!',
|
|
159
|
+
error: new Error('My boom error!'),
|
|
124
160
|
},
|
|
125
161
|
],
|
|
126
162
|
},
|
|
@@ -135,14 +171,15 @@ describe('getCommentBody', () => {
|
|
|
135
171
|
|❌|7.x|My boom error!|
|
|
136
172
|
|❌|7.1|My boom error!|
|
|
137
173
|
|
|
138
|
-
###
|
|
139
|
-
|
|
174
|
+
### Manual backport
|
|
175
|
+
To create the backport manually run:
|
|
140
176
|
\`\`\`
|
|
141
177
|
node scripts/backport --pr 55
|
|
142
178
|
\`\`\`
|
|
143
179
|
|
|
144
180
|
### Questions ?
|
|
145
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
181
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
182
|
+
<!--- Backport version: 1.2.3 -->"
|
|
146
183
|
`);
|
|
147
184
|
});
|
|
148
185
|
it('does not post a comment when running manaully', () => {
|
|
@@ -172,8 +209,7 @@ describe('getCommentBody', () => {
|
|
|
172
209
|
{
|
|
173
210
|
status: 'failure',
|
|
174
211
|
targetBranch: '7.1',
|
|
175
|
-
error: new Error('
|
|
176
|
-
errorMessage: 'My boom error!',
|
|
212
|
+
error: new Error('My boom error!'),
|
|
177
213
|
},
|
|
178
214
|
],
|
|
179
215
|
},
|
|
@@ -181,23 +217,24 @@ describe('getCommentBody', () => {
|
|
|
181
217
|
it('post a comment when running on CI', () => {
|
|
182
218
|
const params = getParams({ ci: true });
|
|
183
219
|
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
184
|
-
|
|
220
|
+
"## 💔 Some backports could not be created
|
|
185
221
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
222
|
+
| Status | Branch | Result |
|
|
223
|
+
|:------:|:------:|:------|
|
|
224
|
+
|✅|7.x|[<img src=\\"https://img.shields.io/github/pulls/detail/state/elastic/kibana/55\\">](url-to-pr-55)|
|
|
225
|
+
|❌|7.1|My boom error!|
|
|
190
226
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
227
|
+
### Manual backport
|
|
228
|
+
To create the backport manually run:
|
|
229
|
+
\`\`\`
|
|
230
|
+
node scripts/backport --pr 55
|
|
231
|
+
\`\`\`
|
|
232
|
+
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
197
233
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
234
|
+
### Questions ?
|
|
235
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
236
|
+
<!--- Backport version: 1.2.3 -->"
|
|
237
|
+
`);
|
|
201
238
|
});
|
|
202
239
|
it('does not post a comment when running manually because some backports failed', () => {
|
|
203
240
|
const params = getParams({ ci: false });
|
|
@@ -226,24 +263,45 @@ describe('getCommentBody', () => {
|
|
|
226
263
|
{
|
|
227
264
|
status: 'failure',
|
|
228
265
|
targetBranch: '7.1',
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
type: 'merge-conflict-due-to-missing-backports',
|
|
266
|
+
error: new HandledError_1.HandledError({
|
|
267
|
+
code: 'merge-conflict-exception',
|
|
232
268
|
commitsWithoutBackports: [
|
|
269
|
+
//@ts-expect-error
|
|
233
270
|
{
|
|
234
|
-
//@ts-expect-error
|
|
235
271
|
commit: {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
272
|
+
sourceBranch: 'master',
|
|
273
|
+
sourcePullRequest: {
|
|
274
|
+
number: 5,
|
|
275
|
+
url: 'url-to-pr-5',
|
|
276
|
+
mergeCommit: {
|
|
277
|
+
sha: '',
|
|
278
|
+
message: 'New Zealand commit message',
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
sourceCommit: {
|
|
282
|
+
committedDate: '',
|
|
283
|
+
sha: '',
|
|
284
|
+
message: 'New Zealand commit message',
|
|
285
|
+
},
|
|
286
|
+
expectedTargetPullRequests: [],
|
|
239
287
|
},
|
|
240
288
|
},
|
|
241
289
|
{
|
|
242
290
|
//@ts-expect-error
|
|
243
291
|
commit: {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
292
|
+
sourcePullRequest: {
|
|
293
|
+
number: 44,
|
|
294
|
+
url: 'url-to-pr-44',
|
|
295
|
+
mergeCommit: {
|
|
296
|
+
sha: '',
|
|
297
|
+
message: 'Australia commit',
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
sourceCommit: {
|
|
301
|
+
committedDate: '',
|
|
302
|
+
sha: '',
|
|
303
|
+
message: 'Australia commit',
|
|
304
|
+
},
|
|
247
305
|
},
|
|
248
306
|
},
|
|
249
307
|
],
|
|
@@ -252,9 +310,8 @@ describe('getCommentBody', () => {
|
|
|
252
310
|
{
|
|
253
311
|
status: 'failure',
|
|
254
312
|
targetBranch: '7.2',
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
type: 'merge-conflict-due-to-missing-backports',
|
|
313
|
+
error: new HandledError_1.HandledError({
|
|
314
|
+
code: 'merge-conflict-exception',
|
|
258
315
|
commitsWithoutBackports: [],
|
|
259
316
|
}),
|
|
260
317
|
},
|
|
@@ -272,20 +329,58 @@ describe('getCommentBody', () => {
|
|
|
272
329
|
|❌|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)|
|
|
273
330
|
|❌|7.2|**Backport failed because of merge conflicts**|
|
|
274
331
|
|
|
275
|
-
###
|
|
276
|
-
|
|
332
|
+
### Manual backport
|
|
333
|
+
To create the backport manually run:
|
|
277
334
|
\`\`\`
|
|
278
335
|
node scripts/backport --pr 55
|
|
279
336
|
\`\`\`
|
|
280
337
|
Note: Successful backport PRs will be merged automatically after passing CI.
|
|
281
338
|
|
|
282
339
|
### Questions ?
|
|
283
|
-
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
340
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
341
|
+
<!--- Backport version: 1.2.3 -->"
|
|
284
342
|
`);
|
|
285
343
|
});
|
|
286
344
|
it('does not post a comment when running manually because some backports failed', () => {
|
|
287
345
|
const params = getParams({ ci: false });
|
|
288
|
-
expect((0, createStatusComment_1.getCommentBody)(params)).
|
|
346
|
+
expect((0, createStatusComment_1.getCommentBody)(params)).toBe(undefined);
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
describe('when all backports fail due to missing branches', () => {
|
|
350
|
+
const getParams = (opts) => ({
|
|
351
|
+
options: {
|
|
352
|
+
repoName: 'kibana',
|
|
353
|
+
repoOwner: 'elastic',
|
|
354
|
+
autoMerge: true,
|
|
355
|
+
backportBinary: 'node scripts/backport',
|
|
356
|
+
...opts,
|
|
357
|
+
},
|
|
358
|
+
pullNumber: 55,
|
|
359
|
+
backportResponse: {
|
|
360
|
+
status: 'failure',
|
|
361
|
+
error: new HandledError_1.HandledError({ code: 'no-branches-exception' }),
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
it('posts a comment when running on CI', () => {
|
|
365
|
+
const params = getParams({ ci: true });
|
|
366
|
+
expect((0, createStatusComment_1.getCommentBody)(params)).toMatchInlineSnapshot(`
|
|
367
|
+
"## ⚪ Backport skipped
|
|
368
|
+
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.
|
|
369
|
+
|
|
370
|
+
### Manual backport
|
|
371
|
+
To create the backport manually run:
|
|
372
|
+
\`\`\`
|
|
373
|
+
node scripts/backport --pr 55
|
|
374
|
+
\`\`\`
|
|
375
|
+
|
|
376
|
+
### Questions ?
|
|
377
|
+
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
378
|
+
<!--- Backport version: 1.2.3 -->"
|
|
379
|
+
`);
|
|
380
|
+
});
|
|
381
|
+
it('does not post a comment when running manually', () => {
|
|
382
|
+
const params = getParams({ ci: false });
|
|
383
|
+
expect((0, createStatusComment_1.getCommentBody)(params)).toBe(undefined);
|
|
289
384
|
});
|
|
290
385
|
});
|
|
291
386
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
declare type GithubV3Error = {
|
|
2
2
|
name: string;
|
|
3
3
|
status: number;
|
|
4
4
|
documentation_url: string;
|
|
@@ -11,3 +11,4 @@ export declare type GithubV3Error = {
|
|
|
11
11
|
}>;
|
|
12
12
|
};
|
|
13
13
|
export declare function getGithubV3ErrorMessage(e: GithubV3Error): string | undefined;
|
|
14
|
+
export {};
|
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
import { ValidConfigOptions } from '../../../options/options';
|
|
2
|
-
export interface PullRequestResponse {
|
|
3
|
-
repository: {
|
|
4
|
-
pullRequest: {
|
|
5
|
-
id: string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
2
|
export declare function fetchPullRequestId(options: ValidConfigOptions, pullNumber: number): Promise<string>;
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
interface GithubError {
|
|
3
|
+
type: string;
|
|
4
|
+
path: string[];
|
|
5
|
+
locations: {
|
|
6
|
+
line: number;
|
|
7
|
+
column: number;
|
|
8
|
+
}[];
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
3
11
|
export interface GithubV4Response<DataResponse> {
|
|
4
12
|
data: DataResponse;
|
|
5
|
-
errors?:
|
|
6
|
-
type: string;
|
|
7
|
-
path: string[];
|
|
8
|
-
locations: {
|
|
9
|
-
line: number;
|
|
10
|
-
column: number;
|
|
11
|
-
}[];
|
|
12
|
-
message: string;
|
|
13
|
-
}[];
|
|
13
|
+
errors?: GithubError[];
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
declare type Variables = Record<string, string | number | null>;
|
|
16
|
+
export declare function apiRequestV4<DataResponse>({ githubApiBaseUrlV4, accessToken, query, variables, }: {
|
|
16
17
|
githubApiBaseUrlV4?: string;
|
|
17
18
|
accessToken: string;
|
|
18
19
|
query: string;
|
|
19
|
-
variables?:
|
|
20
|
-
[key: string]: string | number | null;
|
|
21
|
-
};
|
|
22
|
-
handleError?: boolean;
|
|
20
|
+
variables?: Variables;
|
|
23
21
|
}): Promise<DataResponse>;
|
|
24
|
-
|
|
22
|
+
declare type AxiosGithubResponse<DataResponse> = AxiosResponse<GithubV4Response<DataResponse | null>, any>;
|
|
23
|
+
export declare class GithubV4Exception<DataResponse> extends Error {
|
|
24
|
+
message: string;
|
|
25
|
+
axiosResponse: AxiosGithubResponse<DataResponse>;
|
|
26
|
+
constructor(message: string, axiosResponse: AxiosGithubResponse<DataResponse>);
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -3,11 +3,11 @@ 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.GithubV4Exception = exports.apiRequestV4 = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const HandledError_1 = require("../../HandledError");
|
|
9
9
|
const logger_1 = require("../../logger");
|
|
10
|
-
async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graphql', accessToken, query, variables,
|
|
10
|
+
async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graphql', accessToken, query, variables, }) {
|
|
11
11
|
try {
|
|
12
12
|
const response = await axios_1.default.post(githubApiBaseUrlV4, { query, variables }, {
|
|
13
13
|
headers: {
|
|
@@ -16,40 +16,50 @@ async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graph
|
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
18
|
if (response.data.errors) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
throw
|
|
19
|
+
const message = `${response.data.errors
|
|
20
|
+
.map((error) => error.message)
|
|
21
|
+
.join(',')} (Github API v4)`;
|
|
22
|
+
throw new GithubV4Exception(message, response);
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
addDebugLogs({
|
|
25
|
+
githubApiBaseUrlV4,
|
|
26
|
+
query,
|
|
27
|
+
variables,
|
|
28
|
+
axiosResponse: response,
|
|
29
|
+
didSucceed: false,
|
|
30
|
+
});
|
|
29
31
|
return response.data.data;
|
|
30
32
|
}
|
|
31
33
|
catch (e) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
if (axios_1.default.isAxiosError(e) && e.response) {
|
|
35
|
+
addDebugLogs({
|
|
36
|
+
githubApiBaseUrlV4,
|
|
37
|
+
query,
|
|
38
|
+
variables,
|
|
39
|
+
axiosResponse: e.response,
|
|
40
|
+
didSucceed: false,
|
|
41
|
+
});
|
|
42
|
+
throw new GithubV4Exception(`${e.message} (Unhandled Github API v4)`, e.response);
|
|
39
43
|
}
|
|
40
44
|
throw e;
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
exports.apiRequestV4 = apiRequestV4;
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
function addDebugLogs({ githubApiBaseUrlV4, query, variables, axiosResponse, didSucceed, }) {
|
|
49
|
+
logger_1.logger.info(`POST ${githubApiBaseUrlV4} (status: ${axiosResponse.status})`);
|
|
50
|
+
const logMethod = didSucceed ? logger_1.logger.verbose : logger_1.logger.info;
|
|
51
|
+
logMethod('Query:', query);
|
|
52
|
+
logMethod('Variables:', variables);
|
|
53
|
+
logMethod('Response headers:', axiosResponse.headers);
|
|
54
|
+
logMethod('Response data:', axiosResponse.data);
|
|
55
|
+
}
|
|
56
|
+
class GithubV4Exception extends Error {
|
|
57
|
+
constructor(message, axiosResponse) {
|
|
58
|
+
super(message);
|
|
59
|
+
this.message = message;
|
|
60
|
+
this.axiosResponse = axiosResponse;
|
|
61
|
+
Error.captureStackTrace(this, HandledError_1.HandledError);
|
|
62
|
+
this.name = 'GithubV4Exception';
|
|
52
63
|
}
|
|
53
|
-
return new HandledError_1.HandledError(`Unexpected response from Github API (v4):\n${JSON.stringify(e.response.data, null, 2)}`);
|
|
54
64
|
}
|
|
55
|
-
exports.
|
|
65
|
+
exports.GithubV4Exception = GithubV4Exception;
|
|
@@ -43,13 +43,13 @@ describe('apiRequestV4', () => {
|
|
|
43
43
|
beforeEach(() => {
|
|
44
44
|
(0, nockHelpers_1.mockGqlRequest)({
|
|
45
45
|
name: 'MyQuery',
|
|
46
|
-
statusCode:
|
|
46
|
+
statusCode: 200,
|
|
47
47
|
body: {
|
|
48
48
|
errors: [{ message: 'some error' }, { message: 'some other error' }],
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
-
it('should return
|
|
52
|
+
it('should return error containing the error messages', async () => {
|
|
53
53
|
return expect((0, apiRequestV4_1.apiRequestV4)({
|
|
54
54
|
accessToken: 'myAccessToken',
|
|
55
55
|
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
@@ -57,7 +57,7 @@ describe('apiRequestV4', () => {
|
|
|
57
57
|
variables: {
|
|
58
58
|
foo: 'bar',
|
|
59
59
|
},
|
|
60
|
-
})).rejects.toThrowError(new HandledError_1.HandledError(`some error,
|
|
60
|
+
})).rejects.toThrowError(new HandledError_1.HandledError(`some error,some other error (Github API v4)`));
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
63
|
describe('when request fails without error messages', () => {
|
|
@@ -76,7 +76,7 @@ describe('apiRequestV4', () => {
|
|
|
76
76
|
variables: {
|
|
77
77
|
foo: 'bar',
|
|
78
78
|
},
|
|
79
|
-
})).rejects.
|
|
79
|
+
})).rejects.toThrowError('Request failed with status code 500');
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
82
|
});
|
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
import { ValidConfigOptions } from '../../../options/options';
|
|
2
|
-
export interface PullRequestAutoMergeResponse {
|
|
3
|
-
disablePullRequestAutoMerge: {
|
|
4
|
-
pullRequest?: {
|
|
5
|
-
number: number;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
2
|
export declare function disablePullRequestAutoMerge(options: ValidConfigOptions, pullNumber: number): Promise<number | undefined>;
|
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
import { ValidConfigOptions } from '../../../options/options';
|
|
2
|
-
export interface PullRequestAutoMergeResponse {
|
|
3
|
-
enablePullRequestAutoMerge: {
|
|
4
|
-
pullRequest?: {
|
|
5
|
-
number: number;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
2
|
export declare function enablePullRequestAutoMerge(options: ValidConfigOptions, targetPullRequestNumber: number): Promise<number | undefined>;
|