backport 7.3.5 → 8.0.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 +13 -18
- package/dist/backportRun.d.ts +14 -3
- package/dist/backportRun.js +59 -37
- package/dist/entrypoint.cli.js +1 -1
- package/dist/entrypoint.module.d.ts +8 -3
- package/dist/entrypoint.module.js +6 -10
- package/dist/entrypoint.module.private.test.js +129 -330
- package/dist/options/ConfigOptions.d.ts +2 -2
- package/dist/options/cliArgs.d.ts +10 -6
- package/dist/options/cliArgs.js +32 -21
- package/dist/options/cliArgs.test.js +3 -3
- package/dist/options/config/config.d.ts +2 -2
- package/dist/options/config/config.js +2 -2
- package/dist/options/config/globalConfig.d.ts +2 -2
- package/dist/options/config/globalConfig.js +13 -10
- 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 +4 -4
- package/dist/options/options.d.ts +4 -5
- package/dist/options/options.js +2 -3
- package/dist/options/options.test.js +7 -4
- package/dist/runSequentially.d.ts +5 -1
- package/dist/runSequentially.js +23 -8
- package/dist/scripts/postinstall.js +1 -0
- package/dist/scripts/postinstall.test.js +5 -1
- package/dist/services/HandledError.d.ts +6 -2
- package/dist/services/HandledError.js +8 -8
- 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 +188 -126
- 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 +3 -1
- package/dist/services/github/v3/createStatusComment.js +16 -16
- package/dist/services/github/v3/createStatusComment.test.js +17 -5
- package/dist/services/github/v4/apiRequestV4.js +6 -9
- 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 +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +10 -9
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +10 -9
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +1 -0
- 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 +1 -0
- 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.private.test.js +6 -7
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +9 -8
- 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/test/e2e/cli/entrypoint.cli.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +401 -0
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +17 -16
- package/dist/test/e2e/cli/runBackportViaCli.d.ts +2 -1
- package/dist/test/e2e/cli/runBackportViaCli.js +10 -2
- 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 +11 -10
- package/dist/test/sandbox.js +5 -1
- package/dist/test/setupFiles/automatic-mocks.js +16 -12
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +8 -4
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +7 -159
- package/dist/ui/getCommitsWithoutBackports.test.js +5 -1
- package/dist/ui/getGitConfigAuthor.js +1 -1
- package/dist/ui/getTargetBranches.test.js +5 -1
- package/dist/ui/ora.d.ts +1 -8
- package/dist/ui/setupRepo.js +1 -1
- 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 +13 -13
- package/yarn.lock +414 -695
|
@@ -48,7 +48,9 @@ async function createPullRequest({ options, prPayload, }) {
|
|
|
48
48
|
// swallow error
|
|
49
49
|
}
|
|
50
50
|
spinner.fail();
|
|
51
|
-
throw new HandledError_1.HandledError(
|
|
51
|
+
throw new HandledError_1.HandledError(
|
|
52
|
+
//@ts-expect-error
|
|
53
|
+
`Could not create pull request: ${(0, getGithubV3ErrorMessage_1.getGithubV3ErrorMessage)(e)}`);
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
exports.createPullRequest = createPullRequest;
|
|
@@ -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 HandledError_1.HandledError &&
|
|
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;
|
|
@@ -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
|
});
|
|
@@ -265,6 +271,7 @@ describe('getCommentBody', () => {
|
|
|
265
271
|
targetBranch: '7.1',
|
|
266
272
|
error: new HandledError_1.HandledError({
|
|
267
273
|
code: 'merge-conflict-exception',
|
|
274
|
+
conflictingFiles: ['readme.md'],
|
|
268
275
|
commitsWithoutBackports: [
|
|
269
276
|
{
|
|
270
277
|
formatted: 'some-formatted-text',
|
|
@@ -322,6 +329,7 @@ describe('getCommentBody', () => {
|
|
|
322
329
|
targetBranch: '7.2',
|
|
323
330
|
error: new HandledError_1.HandledError({
|
|
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,7 +377,8 @@ describe('getCommentBody', () => {
|
|
|
367
377
|
},
|
|
368
378
|
pullNumber: 55,
|
|
369
379
|
backportResponse: {
|
|
370
|
-
status: '
|
|
380
|
+
status: 'aborted',
|
|
381
|
+
commits: [],
|
|
371
382
|
error: new HandledError_1.HandledError({ code: 'no-branches-exception' }),
|
|
372
383
|
},
|
|
373
384
|
});
|
|
@@ -385,6 +396,7 @@ describe('getCommentBody', () => {
|
|
|
385
396
|
|
|
386
397
|
### Questions ?
|
|
387
398
|
Please refer to the [Backport tool documentation](https://github.com/sqren/backport)
|
|
399
|
+
|
|
388
400
|
<!--- Backport version: 1.2.3-mocked -->"
|
|
389
401
|
`);
|
|
390
402
|
});
|
|
@@ -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) {
|
|
@@ -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',
|
|
@@ -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',
|
|
@@ -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"');
|
|
@@ -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,18 +27,15 @@ const graphql_1 = require("graphql");
|
|
|
23
27
|
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
24
28
|
const apiRequestV4Module = __importStar(require("../apiRequestV4"));
|
|
25
29
|
const fetchCommitsByAuthor_1 = require("./fetchCommitsByAuthor");
|
|
30
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
26
31
|
describe('fetchCommitsByAuthor', () => {
|
|
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 commits;
|
|
34
35
|
beforeEach(async () => {
|
|
35
36
|
spy = jest.spyOn(apiRequestV4Module, 'apiRequestV4');
|
|
36
37
|
commits = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
37
|
-
accessToken
|
|
38
|
+
accessToken,
|
|
38
39
|
author: 'sqren',
|
|
39
40
|
maxNumber: 10,
|
|
40
41
|
repoName: 'kibana',
|
|
@@ -64,7 +65,7 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
64
65
|
});
|
|
65
66
|
describe('commitPaths', () => {
|
|
66
67
|
const getOptions = () => ({
|
|
67
|
-
accessToken
|
|
68
|
+
accessToken,
|
|
68
69
|
author: 'sqren',
|
|
69
70
|
maxNumber: 10,
|
|
70
71
|
repoName: 'repo-with-different-commit-paths',
|
|
@@ -138,7 +139,7 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
138
139
|
let res;
|
|
139
140
|
beforeEach(async () => {
|
|
140
141
|
res = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
141
|
-
accessToken
|
|
142
|
+
accessToken,
|
|
142
143
|
commitPaths: [],
|
|
143
144
|
maxNumber: 10,
|
|
144
145
|
repoName: 'backport-e2e',
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
4
4
|
const fetchPullRequestsBySearchQuery_1 = require("./fetchPullRequestsBySearchQuery");
|
|
5
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
5
6
|
describe('fetchPullRequestsBySearchQuery', () => {
|
|
6
|
-
let devAccessToken;
|
|
7
|
-
beforeAll(() => {
|
|
8
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
|
-
});
|
|
10
7
|
describe('when filter does not match any PRs', () => {
|
|
11
8
|
it('throws an error', async () => {
|
|
12
9
|
const options = {
|
|
13
|
-
accessToken
|
|
10
|
+
accessToken,
|
|
14
11
|
maxNumber: 10,
|
|
15
12
|
prFilter: 'label:non-existing',
|
|
16
13
|
repoName: 'backport-e2e',
|
|
@@ -30,7 +27,7 @@ describe('fetchPullRequestsBySearchQuery', () => {
|
|
|
30
27
|
describe('when filter matches PRs', () => {
|
|
31
28
|
it('returns the merge commits for those PRs', async () => {
|
|
32
29
|
const options = {
|
|
33
|
-
accessToken
|
|
30
|
+
accessToken,
|
|
34
31
|
maxNumber: 10,
|
|
35
32
|
prFilter: 'label:v7.8.0',
|
|
36
33
|
repoName: 'backport-e2e',
|
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
4
4
|
const fetchExistingPullRequest_1 = require("./fetchExistingPullRequest");
|
|
5
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
5
6
|
describe('fetchExistingPullRequest', () => {
|
|
6
|
-
let devAccessToken;
|
|
7
|
-
beforeAll(() => {
|
|
8
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
|
-
});
|
|
10
7
|
describe('when PR does not exist', () => {
|
|
11
8
|
it('returns undefined', async () => {
|
|
12
9
|
const options = {
|
|
13
|
-
accessToken
|
|
10
|
+
accessToken,
|
|
14
11
|
};
|
|
15
12
|
const prPayload = {
|
|
16
13
|
owner: 'backport-org',
|
|
@@ -27,7 +24,7 @@ describe('fetchExistingPullRequest', () => {
|
|
|
27
24
|
describe('when PR exists', () => {
|
|
28
25
|
it('returns the PR number and url', async () => {
|
|
29
26
|
const options = {
|
|
30
|
-
accessToken
|
|
27
|
+
accessToken,
|
|
31
28
|
};
|
|
32
29
|
const prPayload = {
|
|
33
30
|
owner: 'backport-org',
|
|
@@ -2,16 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
4
4
|
const fetchRemoteProjectConfig_1 = require("./fetchRemoteProjectConfig");
|
|
5
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
5
6
|
describe('fetchRemoteProjectConfig', () => {
|
|
6
|
-
let devAccessToken;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
|
-
});
|
|
10
7
|
it('returns the backport config from "main" branch', async () => {
|
|
11
8
|
const projectConfig = await (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
12
9
|
repoOwner: 'backport-org',
|
|
13
10
|
repoName: 'repo-with-project-config',
|
|
14
|
-
accessToken
|
|
11
|
+
accessToken,
|
|
15
12
|
sourceBranch: 'main',
|
|
16
13
|
});
|
|
17
14
|
expect(projectConfig).toEqual({
|
|
@@ -31,7 +28,7 @@ describe('fetchRemoteProjectConfig', () => {
|
|
|
31
28
|
const projectConfig = await (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
32
29
|
repoOwner: 'backport-org',
|
|
33
30
|
repoName: 'repo-with-project-config',
|
|
34
|
-
accessToken
|
|
31
|
+
accessToken,
|
|
35
32
|
sourceBranch: 'branch-with-legacy-config',
|
|
36
33
|
});
|
|
37
34
|
expect(projectConfig).toEqual({
|
|
@@ -44,7 +41,7 @@ describe('fetchRemoteProjectConfig', () => {
|
|
|
44
41
|
const promise = (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
45
42
|
repoOwner: 'backport-org',
|
|
46
43
|
repoName: 'repo-with-project-config',
|
|
47
|
-
accessToken
|
|
44
|
+
accessToken,
|
|
48
45
|
sourceBranch: 'branch-with-no-config',
|
|
49
46
|
});
|
|
50
47
|
await expect(promise).rejects.toThrowError('Project config does not exist');
|