backport 7.3.6 → 7.4.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 +1 -5
- package/dist/backportRun.d.ts +9 -3
- package/dist/backportRun.js +18 -9
- package/dist/entrypoint.cli.js +1 -1
- package/dist/entrypoint.module.js +5 -1
- package/dist/entrypoint.module.private.test.js +103 -5
- package/dist/options/ConfigOptions.d.ts +2 -2
- package/dist/options/cliArgs.d.ts +1 -2
- package/dist/options/cliArgs.js +4 -6
- package/dist/options/config/config.d.ts +2 -2
- package/dist/options/config/config.js +2 -2
- 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 +2 -2
- package/dist/options/options.d.ts +1 -2
- package/dist/options/options.js +2 -3
- package/dist/options/options.test.js +2 -3
- package/dist/runSequentially.d.ts +1 -1
- package/dist/runSequentially.js +0 -1
- package/dist/services/HandledError.d.ts +6 -2
- package/dist/services/HandledError.js +8 -8
- package/dist/services/git.js +0 -4
- package/dist/services/git.test.js +0 -34
- package/dist/services/github/v3/createStatusComment.js +3 -2
- package/dist/services/github/v3/createStatusComment.test.js +2 -0
- package/dist/services/github/v4/apiRequestV4.js +6 -9
- 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.private.test.js +5 -8
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +5 -8
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +4 -7
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +3 -6
- 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 +4 -7
- package/dist/services/logger.d.ts +1 -4
- package/dist/services/logger.js +9 -18
- package/dist/test/e2e/cli/entrypoint.cli.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +219 -0
- package/dist/test/e2e/module/entrypoint.module.mutation.test.d.ts +1 -0
- package/dist/test/e2e/module/entrypoint.module.mutation.test.js +369 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.js +1 -2
- package/dist/test/setupFiles/automatic-mocks.js +11 -11
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +7 -3
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +1 -1
|
@@ -2,28 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HandledError = void 0;
|
|
4
4
|
function getMessage(errorContext) {
|
|
5
|
-
if (typeof errorContext === 'string') {
|
|
6
|
-
return errorContext;
|
|
7
|
-
}
|
|
8
5
|
switch (errorContext.code) {
|
|
9
6
|
case 'merge-conflict-exception':
|
|
10
|
-
return `Commit could not be cherrypicked due to conflicts`;
|
|
7
|
+
return `Commit could not be cherrypicked due to conflicts in: ${errorContext.conflictingFiles.join(',')}`;
|
|
11
8
|
case 'no-branches-exception':
|
|
12
9
|
return 'There are no branches to backport to. Aborting.';
|
|
13
10
|
case 'abort-exception':
|
|
14
11
|
return 'Aborted';
|
|
12
|
+
case 'custom-exception':
|
|
13
|
+
return errorContext.message;
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
class HandledError extends Error {
|
|
18
|
-
constructor(
|
|
17
|
+
constructor(errorContextOrString) {
|
|
18
|
+
const errorContext = typeof errorContextOrString === 'string'
|
|
19
|
+
? { code: 'custom-exception', message: errorContextOrString }
|
|
20
|
+
: errorContextOrString;
|
|
19
21
|
const message = getMessage(errorContext);
|
|
20
22
|
super(message);
|
|
21
23
|
Error.captureStackTrace(this, HandledError);
|
|
22
24
|
this.name = 'HandledError';
|
|
23
25
|
this.message = message;
|
|
24
|
-
|
|
25
|
-
this.errorContext = errorContext;
|
|
26
|
-
}
|
|
26
|
+
this.errorContext = errorContext;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
exports.HandledError = HandledError;
|
package/dist/services/git.js
CHANGED
|
@@ -217,10 +217,6 @@ async function cherrypick({ options, sha, mergedTargetPullRequest, commitAuthor,
|
|
|
217
217
|
? `It looks like the commit was already backported in ${mergedTargetPullRequest.url}`
|
|
218
218
|
: 'Did you already backport this commit? '}`);
|
|
219
219
|
}
|
|
220
|
-
// git info missing
|
|
221
|
-
if (e.message.includes('Please tell me who you are')) {
|
|
222
|
-
throw new HandledError_1.HandledError(e.message);
|
|
223
|
-
}
|
|
224
220
|
if (e.message.includes(`bad object ${sha}`)) {
|
|
225
221
|
throw new HandledError_1.HandledError(`Cherrypick failed because commit "${sha}" was not found`);
|
|
226
222
|
}
|
|
@@ -400,40 +400,6 @@ Or refer to the git documentation for more information: https://git-scm.com/docs
|
|
|
400
400
|
commitAuthor,
|
|
401
401
|
})).rejects.toThrowError(`Cherrypick failed because the selected commit (abcd) is empty. Did you already backport this commit?`);
|
|
402
402
|
});
|
|
403
|
-
it('gracefully handles missing git info', async () => {
|
|
404
|
-
jest
|
|
405
|
-
.spyOn(childProcess, 'exec')
|
|
406
|
-
// mock getIsMergeCommit(...)
|
|
407
|
-
.mockResolvedValueOnce({ stderr: '', stdout: '' })
|
|
408
|
-
// mock cherry pick command
|
|
409
|
-
.mockRejectedValueOnce(new ExecError_1.ExecError({
|
|
410
|
-
killed: false,
|
|
411
|
-
code: 128,
|
|
412
|
-
signal: null,
|
|
413
|
-
cmd: 'git cherry-pick 83ad852b6ba1a64c8047f07201018eb6fb020db8',
|
|
414
|
-
stdout: '',
|
|
415
|
-
stderr: '\n*** Please tell me who you are.\n\nRun\n\n git config --global user.email "you@example.com"\n git config --global user.name "Your Name"\n\nto set your account\'s default identity.\nOmit --global to set the identity only in this repository.\n\nfatal: empty ident name (for <foo@bar.net>) not allowed\n',
|
|
416
|
-
}));
|
|
417
|
-
await expect((0, git_1.cherrypick)({
|
|
418
|
-
options,
|
|
419
|
-
sha: 'abcd',
|
|
420
|
-
commitAuthor,
|
|
421
|
-
})).rejects.toThrowErrorMatchingInlineSnapshot(`
|
|
422
|
-
"
|
|
423
|
-
*** Please tell me who you are.
|
|
424
|
-
|
|
425
|
-
Run
|
|
426
|
-
|
|
427
|
-
git config --global user.email \\"you@example.com\\"
|
|
428
|
-
git config --global user.name \\"Your Name\\"
|
|
429
|
-
|
|
430
|
-
to set your account's default identity.
|
|
431
|
-
Omit --global to set the identity only in this repository.
|
|
432
|
-
|
|
433
|
-
fatal: empty ident name (for <foo@bar.net>) not allowed
|
|
434
|
-
"
|
|
435
|
-
`);
|
|
436
|
-
});
|
|
437
403
|
it('should re-throw non-cherrypick errors', async () => {
|
|
438
404
|
jest
|
|
439
405
|
.spyOn(childProcess, 'exec')
|
|
@@ -64,7 +64,7 @@ function getCommentBody({ options, pullNumber, backportResponse, }) {
|
|
|
64
64
|
const questionsAndLinkToBackport = '\n\n### Questions ?\nPlease refer to the [Backport tool documentation](https://github.com/sqren/backport)';
|
|
65
65
|
if (backportResponse.status === 'failure') {
|
|
66
66
|
if (backportResponse.error instanceof HandledError_1.HandledError &&
|
|
67
|
-
backportResponse.error.errorContext
|
|
67
|
+
backportResponse.error.errorContext.code === 'no-branches-exception') {
|
|
68
68
|
return `## ⚪ Backport skipped
|
|
69
69
|
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
70
|
${manualBackportCommand}${questionsAndLinkToBackport}${packageVersionSection}`;
|
|
@@ -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
|
});
|
|
@@ -265,6 +265,7 @@ describe('getCommentBody', () => {
|
|
|
265
265
|
targetBranch: '7.1',
|
|
266
266
|
error: new HandledError_1.HandledError({
|
|
267
267
|
code: 'merge-conflict-exception',
|
|
268
|
+
conflictingFiles: ['readme.md'],
|
|
268
269
|
commitsWithoutBackports: [
|
|
269
270
|
{
|
|
270
271
|
formatted: 'some-formatted-text',
|
|
@@ -322,6 +323,7 @@ describe('getCommentBody', () => {
|
|
|
322
323
|
targetBranch: '7.2',
|
|
323
324
|
error: new HandledError_1.HandledError({
|
|
324
325
|
code: 'merge-conflict-exception',
|
|
326
|
+
conflictingFiles: ['my-file.txt'],
|
|
325
327
|
commitsWithoutBackports: [],
|
|
326
328
|
}),
|
|
327
329
|
},
|
|
@@ -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) {
|
|
@@ -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',
|
|
@@ -23,11 +23,8 @@ const graphql_1 = require("graphql");
|
|
|
23
23
|
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
24
24
|
const apiRequestV4Module = __importStar(require("../apiRequestV4"));
|
|
25
25
|
const fetchCommitByPullNumber_1 = require("./fetchCommitByPullNumber");
|
|
26
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
26
27
|
describe('fetchCommitByPullNumber', () => {
|
|
27
|
-
let devAccessToken;
|
|
28
|
-
beforeAll(() => {
|
|
29
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
30
|
-
});
|
|
31
28
|
describe('snapshot request/response', () => {
|
|
32
29
|
let spy;
|
|
33
30
|
let commit;
|
|
@@ -36,7 +33,7 @@ describe('fetchCommitByPullNumber', () => {
|
|
|
36
33
|
commit = await (0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)({
|
|
37
34
|
repoOwner: 'elastic',
|
|
38
35
|
repoName: 'kibana',
|
|
39
|
-
accessToken
|
|
36
|
+
accessToken,
|
|
40
37
|
pullNumber: 121633,
|
|
41
38
|
sourceBranch: 'master',
|
|
42
39
|
});
|
|
@@ -60,7 +57,7 @@ describe('fetchCommitByPullNumber', () => {
|
|
|
60
57
|
describe('when PR was merged', () => {
|
|
61
58
|
it('is returned', async () => {
|
|
62
59
|
const options = {
|
|
63
|
-
accessToken
|
|
60
|
+
accessToken,
|
|
64
61
|
pullNumber: 5,
|
|
65
62
|
repoName: 'backport-e2e',
|
|
66
63
|
repoOwner: 'backport-org',
|
|
@@ -111,7 +108,7 @@ describe('fetchCommitByPullNumber', () => {
|
|
|
111
108
|
describe('when PR is still open', () => {
|
|
112
109
|
it('throws an error', async () => {
|
|
113
110
|
const options = {
|
|
114
|
-
accessToken
|
|
111
|
+
accessToken,
|
|
115
112
|
pullNumber: 11,
|
|
116
113
|
repoName: 'backport-e2e',
|
|
117
114
|
repoOwner: 'backport-org',
|
|
@@ -123,7 +120,7 @@ describe('fetchCommitByPullNumber', () => {
|
|
|
123
120
|
describe('when PR does not exist', () => {
|
|
124
121
|
it('throws an error', async () => {
|
|
125
122
|
const options = {
|
|
126
|
-
accessToken
|
|
123
|
+
accessToken,
|
|
127
124
|
pullNumber: 9999999999999,
|
|
128
125
|
repoName: 'backport-e2e',
|
|
129
126
|
repoOwner: 'backport-org',
|
|
@@ -23,11 +23,8 @@ const graphql_1 = require("graphql");
|
|
|
23
23
|
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
24
24
|
const apiRequestV4Module = __importStar(require("../apiRequestV4"));
|
|
25
25
|
const fetchCommitBySha_1 = require("./fetchCommitBySha");
|
|
26
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
26
27
|
describe('fetchCommitBySha', () => {
|
|
27
|
-
let devAccessToken;
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
30
|
-
});
|
|
31
28
|
describe('snapshot request/response', () => {
|
|
32
29
|
let spy;
|
|
33
30
|
let commit;
|
|
@@ -36,7 +33,7 @@ describe('fetchCommitBySha', () => {
|
|
|
36
33
|
commit = await (0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
37
34
|
repoOwner: 'elastic',
|
|
38
35
|
repoName: 'kibana',
|
|
39
|
-
accessToken
|
|
36
|
+
accessToken,
|
|
40
37
|
sha: 'd421ddcf6157150596581c7885afa3690cec6339',
|
|
41
38
|
sourceBranch: 'main',
|
|
42
39
|
});
|
|
@@ -91,7 +88,7 @@ describe('fetchCommitBySha', () => {
|
|
|
91
88
|
await expect(await (0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
92
89
|
repoOwner: 'elastic',
|
|
93
90
|
repoName: 'kibana',
|
|
94
|
-
accessToken
|
|
91
|
+
accessToken,
|
|
95
92
|
sha: 'cb6fbc0',
|
|
96
93
|
sourceBranch: 'master',
|
|
97
94
|
})).toEqual(expectedCommit);
|
|
@@ -100,7 +97,7 @@ describe('fetchCommitBySha', () => {
|
|
|
100
97
|
await expect((0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
101
98
|
repoOwner: 'elastic',
|
|
102
99
|
repoName: 'kibana',
|
|
103
|
-
accessToken
|
|
100
|
+
accessToken,
|
|
104
101
|
sha: 'fc22f59',
|
|
105
102
|
sourceBranch: 'main',
|
|
106
103
|
})).rejects.toThrowError('No commit found on branch "main" with sha "fc22f59"');
|
|
@@ -109,7 +106,7 @@ describe('fetchCommitBySha', () => {
|
|
|
109
106
|
await expect((0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
110
107
|
repoOwner: 'elastic',
|
|
111
108
|
repoName: 'kibana',
|
|
112
|
-
accessToken
|
|
109
|
+
accessToken,
|
|
113
110
|
sha: 'myCommitSha',
|
|
114
111
|
sourceBranch: 'main',
|
|
115
112
|
})).rejects.toThrowError('No commit found on branch "main" with sha "myCommitSha"');
|
|
@@ -23,18 +23,15 @@ const graphql_1 = require("graphql");
|
|
|
23
23
|
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
24
24
|
const apiRequestV4Module = __importStar(require("../apiRequestV4"));
|
|
25
25
|
const fetchCommitsByAuthor_1 = require("./fetchCommitsByAuthor");
|
|
26
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
26
27
|
describe('fetchCommitsByAuthor', () => {
|
|
27
|
-
let devAccessToken;
|
|
28
|
-
beforeAll(() => {
|
|
29
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
30
|
-
});
|
|
31
28
|
describe('snapshot request/response', () => {
|
|
32
29
|
let spy;
|
|
33
30
|
let commits;
|
|
34
31
|
beforeEach(async () => {
|
|
35
32
|
spy = jest.spyOn(apiRequestV4Module, 'apiRequestV4');
|
|
36
33
|
commits = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
37
|
-
accessToken
|
|
34
|
+
accessToken,
|
|
38
35
|
author: 'sqren',
|
|
39
36
|
maxNumber: 10,
|
|
40
37
|
repoName: 'kibana',
|
|
@@ -64,7 +61,7 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
64
61
|
});
|
|
65
62
|
describe('commitPaths', () => {
|
|
66
63
|
const getOptions = () => ({
|
|
67
|
-
accessToken
|
|
64
|
+
accessToken,
|
|
68
65
|
author: 'sqren',
|
|
69
66
|
maxNumber: 10,
|
|
70
67
|
repoName: 'repo-with-different-commit-paths',
|
|
@@ -138,7 +135,7 @@ describe('fetchCommitsByAuthor', () => {
|
|
|
138
135
|
let res;
|
|
139
136
|
beforeEach(async () => {
|
|
140
137
|
res = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
141
|
-
accessToken
|
|
138
|
+
accessToken,
|
|
142
139
|
commitPaths: [],
|
|
143
140
|
maxNumber: 10,
|
|
144
141
|
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');
|
|
@@ -23,9 +23,9 @@ export declare function getOptionsFromGithub(options: {
|
|
|
23
23
|
cherrypickRef?: boolean | undefined;
|
|
24
24
|
ci?: boolean | undefined;
|
|
25
25
|
commitPaths?: string[] | undefined;
|
|
26
|
-
configFile?: string | undefined;
|
|
27
26
|
details?: boolean | undefined;
|
|
28
27
|
dir?: string | undefined;
|
|
28
|
+
dryRun?: boolean | undefined;
|
|
29
29
|
editor?: string | undefined;
|
|
30
30
|
fork?: boolean | undefined;
|
|
31
31
|
gitAuthorEmail?: string | undefined;
|
|
@@ -42,6 +42,7 @@ export declare function getOptionsFromGithub(options: {
|
|
|
42
42
|
noVerify?: boolean | undefined;
|
|
43
43
|
prDescription?: string | undefined;
|
|
44
44
|
prFilter?: string | undefined;
|
|
45
|
+
projectConfigFile?: string | undefined;
|
|
45
46
|
prTitle?: string | undefined;
|
|
46
47
|
publishStatusComment?: boolean | undefined;
|
|
47
48
|
pullNumber?: number | undefined;
|
|
@@ -57,7 +58,6 @@ export declare function getOptionsFromGithub(options: {
|
|
|
57
58
|
targetBranchChoices?: import("../../../../options/ConfigOptions").TargetBranchChoiceOrString[] | undefined;
|
|
58
59
|
targetBranches?: string[] | undefined;
|
|
59
60
|
targetPRLabels?: string[] | undefined;
|
|
60
|
-
verbose?: boolean | undefined;
|
|
61
61
|
help?: boolean | undefined;
|
|
62
62
|
version?: boolean | undefined;
|
|
63
63
|
v?: boolean | undefined;
|
|
@@ -6,10 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const os_1 = __importDefault(require("os"));
|
|
7
7
|
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
8
8
|
const getOptionsFromGithub_1 = require("./getOptionsFromGithub");
|
|
9
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
10
|
describe('getOptionsFromGithub', () => {
|
|
10
|
-
let devAccessToken;
|
|
11
11
|
beforeAll(async () => {
|
|
12
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
13
12
|
jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
|
|
14
13
|
});
|
|
15
14
|
describe('access token', () => {
|
|
@@ -29,7 +28,7 @@ describe('getOptionsFromGithub', () => {
|
|
|
29
28
|
it('returns the options', async () => {
|
|
30
29
|
const combinedOptions = {
|
|
31
30
|
author: 'sqren',
|
|
32
|
-
accessToken
|
|
31
|
+
accessToken,
|
|
33
32
|
repoOwner: 'backport-org',
|
|
34
33
|
repoName: 'backport-e2e',
|
|
35
34
|
cwd: process.cwd(),
|
|
@@ -58,7 +57,7 @@ describe('getOptionsFromGithub', () => {
|
|
|
58
57
|
it('returns original repoOwner', async () => {
|
|
59
58
|
const combinedOptions = {
|
|
60
59
|
author: 'sqren',
|
|
61
|
-
accessToken
|
|
60
|
+
accessToken,
|
|
62
61
|
repoOwner: 'sqren',
|
|
63
62
|
repoName: 'backport-e2e',
|
|
64
63
|
cwd: process.cwd(),
|
|
@@ -72,7 +71,7 @@ describe('getOptionsFromGithub', () => {
|
|
|
72
71
|
it('uses the default branch of the repo', async () => {
|
|
73
72
|
const combinedOptions = {
|
|
74
73
|
author: 'sqren',
|
|
75
|
-
accessToken
|
|
74
|
+
accessToken,
|
|
76
75
|
repoOwner: 'backport-org',
|
|
77
76
|
repoName: 'repo-with-non-standard-main-branch',
|
|
78
77
|
cwd: process.cwd(),
|
|
@@ -87,7 +86,7 @@ describe('getOptionsFromGithub', () => {
|
|
|
87
86
|
it('shows a warning', async () => {
|
|
88
87
|
const combinedOptions = {
|
|
89
88
|
author: 'sqren',
|
|
90
|
-
accessToken
|
|
89
|
+
accessToken,
|
|
91
90
|
repoOwner: 'backport-org',
|
|
92
91
|
repoName: 'repo-with-branch-named-backport',
|
|
93
92
|
cwd: process.cwd(),
|
|
@@ -102,7 +101,7 @@ describe('getOptionsFromGithub', () => {
|
|
|
102
101
|
it('does not throw', async () => {
|
|
103
102
|
const combinedOptions = {
|
|
104
103
|
author: 'sqren',
|
|
105
|
-
accessToken
|
|
104
|
+
accessToken,
|
|
106
105
|
repoOwner: 'backport-org',
|
|
107
106
|
repoName: 'repo-with-backportrc-removed',
|
|
108
107
|
cwd: process.cwd(),
|
|
@@ -24,11 +24,8 @@ const sandbox_1 = require("../../../test/sandbox");
|
|
|
24
24
|
const childProcess = __importStar(require("../../child-process-promisified"));
|
|
25
25
|
const getRepoOwnerAndNameFromGitRemotes_1 = require("./getRepoOwnerAndNameFromGitRemotes");
|
|
26
26
|
const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
27
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
27
28
|
describe('fetchRemoteProjectConfig', () => {
|
|
28
|
-
let devAccessToken;
|
|
29
|
-
beforeEach(() => {
|
|
30
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
31
|
-
});
|
|
32
29
|
describe('when the remote is a fork', () => {
|
|
33
30
|
it('retrives the original owner from github', async () => {
|
|
34
31
|
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
@@ -36,7 +33,7 @@ describe('fetchRemoteProjectConfig', () => {
|
|
|
36
33
|
await childProcess.exec(`git init`, execOpts);
|
|
37
34
|
await childProcess.exec(`git remote add sqren git@github.com:sqren/kibana.git`, execOpts);
|
|
38
35
|
expect(await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
|
|
39
|
-
accessToken
|
|
36
|
+
accessToken,
|
|
40
37
|
cwd: sandboxPath,
|
|
41
38
|
})).toEqual({
|
|
42
39
|
repoName: 'kibana',
|
|
@@ -52,7 +49,7 @@ describe('fetchRemoteProjectConfig', () => {
|
|
|
52
49
|
await childProcess.exec(`git remote add foo git@github.com:foo/kibana.git`, execOpts);
|
|
53
50
|
await childProcess.exec(`git remote add bar git@github.com:bar/kibana.git`, execOpts);
|
|
54
51
|
expect(await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
|
|
55
|
-
accessToken
|
|
52
|
+
accessToken,
|
|
56
53
|
cwd: sandboxPath,
|
|
57
54
|
})).toEqual({});
|
|
58
55
|
});
|
|
@@ -63,7 +60,7 @@ describe('fetchRemoteProjectConfig', () => {
|
|
|
63
60
|
const execOpts = { cwd: sandboxPath };
|
|
64
61
|
await childProcess.exec(`git init`, execOpts);
|
|
65
62
|
expect(await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
|
|
66
|
-
accessToken
|
|
63
|
+
accessToken,
|
|
67
64
|
cwd: sandboxPath,
|
|
68
65
|
})).toEqual({});
|
|
69
66
|
});
|
|
@@ -6,7 +6,4 @@ export declare function initLogger({ ci, accessToken, logFilePath, }: {
|
|
|
6
6
|
logFilePath?: string;
|
|
7
7
|
}): winston.Logger;
|
|
8
8
|
export declare function consoleLog(message: string): void;
|
|
9
|
-
export declare function
|
|
10
|
-
accessToken: string;
|
|
11
|
-
verbose?: boolean;
|
|
12
|
-
}): void;
|
|
9
|
+
export declare function setAccessToken(accessToken: string): void;
|