backport 7.2.0-beta.1 → 7.2.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/dist/entrypoint.cli.js +0 -0
- package/dist/entrypoint.module.d.ts +4 -3
- package/dist/entrypoint.module.js +2 -7
- package/dist/options/ConfigOptions.d.ts +1 -1
- package/dist/options/cliArgs.d.ts +1 -0
- package/dist/options/cliArgs.js +4 -0
- package/dist/options/config/config.d.ts +1 -1
- package/dist/options/config/readConfigFile.d.ts +1 -1
- package/dist/options/options.d.ts +2 -1
- package/dist/services/github/v3/createStatusComment.js +1 -1
- package/dist/services/github/v4/apiRequestV4.d.ts +2 -3
- package/dist/services/github/v4/apiRequestV4.js +15 -14
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +2 -2
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +2 -2
- package/dist/services/github/v4/fetchRemoteProjectConfig.js +1 -1
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -1
- package/dist/services/github/v4/getOptionsFromGithub/query.js +1 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +6 -6
- package/dist/services/remoteConfig.js +2 -2
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +4 -1
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +5 -1
- package/dist/services/sourceCommit/getMockSourceCommit.js +19 -18
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +2 -2
- package/dist/services/sourceCommit/parseSourceCommit.js +9 -15
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +12 -18
- package/dist/ui/getCommits.js +6 -4
- package/dist/ui/maybeSetupRepo.js +7 -14
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +9 -9
- package/yarn.lock +121 -114
- package/dist/entrypoint.cli.e2e.private.test.d.ts +0 -1
- package/dist/entrypoint.cli.e2e.private.test.js +0 -386
- package/dist/entrypoint.cli.private.test.d.ts +0 -1
- package/dist/entrypoint.cli.private.test.js +0 -46
- package/dist/options/cliArgs.test.d.ts +0 -1
- package/dist/options/cliArgs.test.js +0 -182
- package/dist/options/config/config.test.d.ts +0 -1
- package/dist/options/config/config.test.js +0 -32
- package/dist/options/config/globalConfig.test.d.ts +0 -1
- package/dist/options/config/globalConfig.test.js +0 -61
- package/dist/options/config/projectConfig.test.d.ts +0 -1
- package/dist/options/config/projectConfig.test.js +0 -109
- package/dist/options/options.test.d.ts +0 -1
- package/dist/options/options.test.js +0 -384
- package/dist/runSequentially.test.d.ts +0 -1
- package/dist/runSequentially.test.js +0 -219
- package/dist/scripts/postinstall.test.d.ts +0 -1
- package/dist/scripts/postinstall.test.js +0 -53
- package/dist/services/env.test.d.ts +0 -1
- package/dist/services/env.test.js +0 -21
- package/dist/services/git.integration.test.d.ts +0 -1
- package/dist/services/git.integration.test.js +0 -320
- package/dist/services/git.test.d.ts +0 -1
- package/dist/services/git.test.js +0 -532
- package/dist/services/github/commitFormatters.test.d.ts +0 -1
- package/dist/services/github/commitFormatters.test.js +0 -11
- package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +0 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.test.js +0 -27
- package/dist/services/github/v3/createPullRequest.test.d.ts +0 -1
- package/dist/services/github/v3/createPullRequest.test.js +0 -325
- package/dist/services/github/v3/createStatusComment.test.d.ts +0 -1
- package/dist/services/github/v3/createStatusComment.test.js +0 -386
- package/dist/services/github/v4/apiRequestV4.test.d.ts +0 -1
- package/dist/services/github/v4/apiRequestV4.test.js +0 -109
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +0 -1
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +0 -112
- package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchAuthorId.private.test.js +0 -28
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +0 -93
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +0 -134
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +0 -116
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +0 -195
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -152
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +0 -102
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +0 -47
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +0 -52
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +0 -1
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +0 -117
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +0 -1
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +0 -71
- package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +0 -2
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +0 -159
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +0 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +0 -87
- package/dist/services/prompt.test.d.ts +0 -1
- package/dist/services/prompt.test.js +0 -134
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +0 -1
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +0 -433
- package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +0 -1
- package/dist/services/sourceCommit/parseSourceCommit.test.js +0 -225
- package/dist/test/ExecError.d.ts +0 -16
- package/dist/test/ExecError.js +0 -15
- package/dist/test/backport-e2e.mutation.test.d.ts +0 -1
- package/dist/test/backport-e2e.mutation.test.js +0 -347
- package/dist/test/handleUnbackportedPullRequests.private.test.d.ts +0 -1
- package/dist/test/handleUnbackportedPullRequests.private.test.js +0 -57
- package/dist/test/mockConfigFiles.d.ts +0 -5
- package/dist/test/mockConfigFiles.js +0 -21
- package/dist/test/mocks.d.ts +0 -10
- package/dist/test/mocks.js +0 -23
- package/dist/test/nockHelpers.d.ts +0 -16
- package/dist/test/nockHelpers.js +0 -36
- package/dist/test/private/getDevAccessToken.d.ts +0 -2
- package/dist/test/private/getDevAccessToken.js +0 -12
- package/dist/test/sandbox.d.ts +0 -5
- package/dist/test/sandbox.js +0 -43
- package/dist/test/setupFiles/automatic-mocks.d.ts +0 -1
- package/dist/test/setupFiles/automatic-mocks.js +0 -63
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +0 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +0 -459
- package/dist/ui/getCommitsWithoutBackports.test.d.ts +0 -1
- package/dist/ui/getCommitsWithoutBackports.test.js +0 -311
- package/dist/ui/getTargetBranches.test.d.ts +0 -1
- package/dist/ui/getTargetBranches.test.js +0 -198
- package/dist/ui/maybeSetupRepo.test.d.ts +0 -1
- package/dist/ui/maybeSetupRepo.test.js +0 -204
- package/dist/utils/excludeUndefined.test.d.ts +0 -1
- package/dist/utils/excludeUndefined.test.js +0 -24
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
4
|
-
const fetchCommitByPullNumber_1 = require("./fetchCommitByPullNumber");
|
|
5
|
-
const fetchCommitBySha_1 = require("./fetchCommitBySha");
|
|
6
|
-
const fetchCommitsByAuthor_1 = require("./fetchCommitsByAuthor");
|
|
7
|
-
const fetchPullRequestBySearchQuery_1 = require("./fetchPullRequestBySearchQuery");
|
|
8
|
-
describe('allFetchers', () => {
|
|
9
|
-
let devAccessToken;
|
|
10
|
-
let commitByAuthor;
|
|
11
|
-
beforeEach(async () => {
|
|
12
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
13
|
-
const commitsByAuthor = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
14
|
-
accessToken: devAccessToken,
|
|
15
|
-
author: 'sqren',
|
|
16
|
-
maxNumber: 1,
|
|
17
|
-
repoName: 'kibana',
|
|
18
|
-
repoOwner: 'elastic',
|
|
19
|
-
sourceBranch: 'main',
|
|
20
|
-
dateSince: '2021-01-10T00:00:00Z',
|
|
21
|
-
dateUntil: '2022-01-01T00:00:00Z',
|
|
22
|
-
commitPaths: [],
|
|
23
|
-
});
|
|
24
|
-
commitByAuthor = commitsByAuthor[0];
|
|
25
|
-
});
|
|
26
|
-
it('matches commitByAuthor with commitByPullNumber', async () => {
|
|
27
|
-
if (!commitByAuthor.sourcePullRequest) {
|
|
28
|
-
throw new Error('Missing pull number!');
|
|
29
|
-
}
|
|
30
|
-
const commitByPullNumber = await (0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)({
|
|
31
|
-
repoOwner: 'elastic',
|
|
32
|
-
repoName: 'kibana',
|
|
33
|
-
accessToken: devAccessToken,
|
|
34
|
-
pullNumber: commitByAuthor.sourcePullRequest.number,
|
|
35
|
-
sourceBranch: 'master',
|
|
36
|
-
});
|
|
37
|
-
expect(commitByAuthor).toEqual(commitByPullNumber);
|
|
38
|
-
});
|
|
39
|
-
it('matches commitByAuthor with commitBySha', async () => {
|
|
40
|
-
const commitBySha = await (0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
41
|
-
repoOwner: 'elastic',
|
|
42
|
-
repoName: 'kibana',
|
|
43
|
-
accessToken: devAccessToken,
|
|
44
|
-
sha: commitByAuthor.sourceCommit.sha,
|
|
45
|
-
sourceBranch: 'main',
|
|
46
|
-
});
|
|
47
|
-
expect(commitByAuthor).toEqual(commitBySha);
|
|
48
|
-
});
|
|
49
|
-
it('matches commitByAuthor with commitBySearchQuery', async () => {
|
|
50
|
-
const commitsBySearchQuery = await (0, fetchPullRequestBySearchQuery_1.fetchPullRequestBySearchQuery)({
|
|
51
|
-
repoOwner: 'elastic',
|
|
52
|
-
repoName: 'kibana',
|
|
53
|
-
accessToken: devAccessToken,
|
|
54
|
-
maxNumber: 1,
|
|
55
|
-
prFilter: `created:2021-12-20..2021-12-20`,
|
|
56
|
-
sourceBranch: 'main',
|
|
57
|
-
author: 'sqren',
|
|
58
|
-
});
|
|
59
|
-
const commitBySearchQuery = commitsBySearchQuery[0];
|
|
60
|
-
expect(commitByAuthor).toEqual(commitBySearchQuery);
|
|
61
|
-
});
|
|
62
|
-
it('returns correct response for commitByAuthor', async () => {
|
|
63
|
-
const expectedCommit = {
|
|
64
|
-
sourceCommit: {
|
|
65
|
-
committedDate: '2021-12-20T14:20:16Z',
|
|
66
|
-
message: '[APM] Add note about synthtrace to APM docs (#121633)',
|
|
67
|
-
sha: 'd421ddcf6157150596581c7885afa3690cec6339',
|
|
68
|
-
},
|
|
69
|
-
sourcePullRequest: {
|
|
70
|
-
number: 121633,
|
|
71
|
-
url: 'https://github.com/elastic/kibana/pull/121633',
|
|
72
|
-
mergeCommit: {
|
|
73
|
-
message: '[APM] Add note about synthtrace to APM docs (#121633)',
|
|
74
|
-
sha: 'd421ddcf6157150596581c7885afa3690cec6339',
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
sourceBranch: 'main',
|
|
78
|
-
expectedTargetPullRequests: [
|
|
79
|
-
{
|
|
80
|
-
branch: '8.0',
|
|
81
|
-
mergeCommit: {
|
|
82
|
-
message: '[APM] Add note about synthtrace to APM docs (#121633) (#121643)\n\nCo-authored-by: Søren Louv-Jansen <soren.louv@elastic.co>',
|
|
83
|
-
sha: '842adfdeb5541b059231857522f9009771a46107',
|
|
84
|
-
},
|
|
85
|
-
number: 121643,
|
|
86
|
-
state: 'MERGED',
|
|
87
|
-
url: 'https://github.com/elastic/kibana/pull/121643',
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
};
|
|
91
|
-
expect(commitByAuthor).toEqual(expectedCommit);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const graphql_1 = require("graphql");
|
|
23
|
-
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
24
|
-
const apiRequestV4Module = __importStar(require("../apiRequestV4"));
|
|
25
|
-
const fetchCommitByPullNumber_1 = require("./fetchCommitByPullNumber");
|
|
26
|
-
describe('fetchCommitByPullNumber', () => {
|
|
27
|
-
let devAccessToken;
|
|
28
|
-
beforeAll(() => {
|
|
29
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
30
|
-
});
|
|
31
|
-
describe('snapshot request/response', () => {
|
|
32
|
-
let spy;
|
|
33
|
-
let commit;
|
|
34
|
-
beforeEach(async () => {
|
|
35
|
-
spy = jest.spyOn(apiRequestV4Module, 'apiRequestV4');
|
|
36
|
-
commit = await (0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)({
|
|
37
|
-
repoOwner: 'elastic',
|
|
38
|
-
repoName: 'kibana',
|
|
39
|
-
accessToken: devAccessToken,
|
|
40
|
-
pullNumber: 121633,
|
|
41
|
-
sourceBranch: 'master',
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
it('makes the right queries', () => {
|
|
45
|
-
const queries = spy.mock.calls.reduce((acc, call) => {
|
|
46
|
-
const query = call[0].query;
|
|
47
|
-
const name = apiRequestV4Module.getQueryName(query);
|
|
48
|
-
return { ...acc, [name]: (0, graphql_1.print)(query) };
|
|
49
|
-
}, {});
|
|
50
|
-
const queryNames = Object.keys(queries);
|
|
51
|
-
expect(queryNames).toEqual(['CommitByPullNumber']);
|
|
52
|
-
queryNames.forEach((name) => {
|
|
53
|
-
expect(queries[name]).toMatchSnapshot(`Query: ${name}`);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
it('returns the correct response', async () => {
|
|
57
|
-
expect(commit).toMatchSnapshot();
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
describe('when PR was merged', () => {
|
|
61
|
-
it('is returned', async () => {
|
|
62
|
-
const options = {
|
|
63
|
-
accessToken: devAccessToken,
|
|
64
|
-
pullNumber: 5,
|
|
65
|
-
repoName: 'backport-e2e',
|
|
66
|
-
repoOwner: 'backport-org',
|
|
67
|
-
sourceBranch: 'main',
|
|
68
|
-
};
|
|
69
|
-
const expectedCommit = {
|
|
70
|
-
sourceCommit: {
|
|
71
|
-
committedDate: '2020-08-15T12:40:19Z',
|
|
72
|
-
message: 'Add 🍏 emoji (#5)',
|
|
73
|
-
sha: 'ee8c492334cef1ca077a56addb79a26f79821d2f',
|
|
74
|
-
},
|
|
75
|
-
sourcePullRequest: {
|
|
76
|
-
number: 5,
|
|
77
|
-
url: 'https://github.com/backport-org/backport-e2e/pull/5',
|
|
78
|
-
mergeCommit: {
|
|
79
|
-
message: 'Add 🍏 emoji (#5)',
|
|
80
|
-
sha: 'ee8c492334cef1ca077a56addb79a26f79821d2f',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
sourceBranch: 'master',
|
|
84
|
-
expectedTargetPullRequests: [
|
|
85
|
-
{
|
|
86
|
-
branch: '7.x',
|
|
87
|
-
state: 'MERGED',
|
|
88
|
-
number: 6,
|
|
89
|
-
url: 'https://github.com/backport-org/backport-e2e/pull/6',
|
|
90
|
-
mergeCommit: {
|
|
91
|
-
message: 'Add 🍏 emoji (#5) (#6)',
|
|
92
|
-
sha: '4bcd876d4ceaa73cf437bfc89b74d1a4e704c0a6',
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
branch: '7.8',
|
|
97
|
-
state: 'MERGED',
|
|
98
|
-
number: 7,
|
|
99
|
-
url: 'https://github.com/backport-org/backport-e2e/pull/7',
|
|
100
|
-
mergeCommit: {
|
|
101
|
-
message: 'Add 🍏 emoji (#5) (#7)',
|
|
102
|
-
sha: '46cd6f9999effdf894a36dbc7db90e890f4be840',
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
};
|
|
107
|
-
expect(await (0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)(options)).toEqual(expectedCommit);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
describe('when PR is still open', () => {
|
|
111
|
-
it('throws an error', async () => {
|
|
112
|
-
const options = {
|
|
113
|
-
accessToken: devAccessToken,
|
|
114
|
-
pullNumber: 11,
|
|
115
|
-
repoName: 'backport-e2e',
|
|
116
|
-
repoOwner: 'backport-org',
|
|
117
|
-
sourceBranch: 'main',
|
|
118
|
-
};
|
|
119
|
-
await expect((0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)(options)).rejects.toThrowError(`The PR #11 is not merged`);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
describe('when PR does not exist', () => {
|
|
123
|
-
it('throws an error', async () => {
|
|
124
|
-
const options = {
|
|
125
|
-
accessToken: devAccessToken,
|
|
126
|
-
pullNumber: 9999999999999,
|
|
127
|
-
repoName: 'backport-e2e',
|
|
128
|
-
repoOwner: 'backport-org',
|
|
129
|
-
sourceBranch: 'main',
|
|
130
|
-
};
|
|
131
|
-
await expect((0, fetchCommitByPullNumber_1.fetchCommitByPullNumber)(options)).rejects.toThrowError(`Could not resolve to a PullRequest with the number of 9999999999999. (Github API v4)`);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const graphql_1 = require("graphql");
|
|
23
|
-
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
24
|
-
const apiRequestV4Module = __importStar(require("../apiRequestV4"));
|
|
25
|
-
const fetchCommitBySha_1 = require("./fetchCommitBySha");
|
|
26
|
-
describe('fetchCommitBySha', () => {
|
|
27
|
-
let devAccessToken;
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
30
|
-
});
|
|
31
|
-
describe('snapshot request/response', () => {
|
|
32
|
-
let spy;
|
|
33
|
-
let commit;
|
|
34
|
-
beforeEach(async () => {
|
|
35
|
-
spy = jest.spyOn(apiRequestV4Module, 'apiRequestV4');
|
|
36
|
-
commit = await (0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
37
|
-
repoOwner: 'elastic',
|
|
38
|
-
repoName: 'kibana',
|
|
39
|
-
accessToken: devAccessToken,
|
|
40
|
-
sha: 'd421ddcf6157150596581c7885afa3690cec6339',
|
|
41
|
-
sourceBranch: 'main',
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
it('makes the right queries', () => {
|
|
45
|
-
const queries = spy.mock.calls.reduce((acc, call) => {
|
|
46
|
-
const query = call[0].query;
|
|
47
|
-
//@ts-expect-error
|
|
48
|
-
const name = query.definitions[0].name.value;
|
|
49
|
-
return { ...acc, [name]: (0, graphql_1.print)(query) };
|
|
50
|
-
}, {});
|
|
51
|
-
const queryNames = Object.keys(queries);
|
|
52
|
-
expect(queryNames).toEqual(['CommitsBySha']);
|
|
53
|
-
queryNames.forEach((name) => {
|
|
54
|
-
expect(queries[name]).toMatchSnapshot(`Query: ${name}`);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
it('returns the correct response', async () => {
|
|
58
|
-
expect(commit).toMatchSnapshot();
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
it('should return single commit with pull request', async () => {
|
|
62
|
-
const expectedCommit = {
|
|
63
|
-
sourceCommit: {
|
|
64
|
-
committedDate: '2020-07-07T20:40:28Z',
|
|
65
|
-
message: '[APM] Add API tests (#70740)',
|
|
66
|
-
sha: 'cb6fbc0e1b406675724181a3e9f59459b5f8f892',
|
|
67
|
-
},
|
|
68
|
-
sourcePullRequest: {
|
|
69
|
-
number: 70740,
|
|
70
|
-
url: 'https://github.com/elastic/kibana/pull/70740',
|
|
71
|
-
mergeCommit: {
|
|
72
|
-
message: '[APM] Add API tests (#70740)',
|
|
73
|
-
sha: 'cb6fbc0e1b406675724181a3e9f59459b5f8f892',
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
sourceBranch: 'master',
|
|
77
|
-
expectedTargetPullRequests: [
|
|
78
|
-
{
|
|
79
|
-
branch: '7.x',
|
|
80
|
-
state: 'MERGED',
|
|
81
|
-
number: 71014,
|
|
82
|
-
url: 'https://github.com/elastic/kibana/pull/71014',
|
|
83
|
-
mergeCommit: {
|
|
84
|
-
message: '[APM] Add API tests (#70740) (#71014)',
|
|
85
|
-
sha: 'd15242be682582e58cd69f6b7707565434e99293',
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
};
|
|
90
|
-
await expect(await (0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
91
|
-
repoOwner: 'elastic',
|
|
92
|
-
repoName: 'kibana',
|
|
93
|
-
accessToken: devAccessToken,
|
|
94
|
-
sha: 'cb6fbc0',
|
|
95
|
-
sourceBranch: 'master',
|
|
96
|
-
})).toEqual(expectedCommit);
|
|
97
|
-
});
|
|
98
|
-
it('throws if sha does not exist', async () => {
|
|
99
|
-
await expect((0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
100
|
-
repoOwner: 'elastic',
|
|
101
|
-
repoName: 'kibana',
|
|
102
|
-
accessToken: devAccessToken,
|
|
103
|
-
sha: 'fc22f59',
|
|
104
|
-
sourceBranch: 'main',
|
|
105
|
-
})).rejects.toThrowError('No commit found on branch "main" with sha "fc22f59"');
|
|
106
|
-
});
|
|
107
|
-
it('throws if sha is invalid', async () => {
|
|
108
|
-
await expect((0, fetchCommitBySha_1.fetchCommitBySha)({
|
|
109
|
-
repoOwner: 'elastic',
|
|
110
|
-
repoName: 'kibana',
|
|
111
|
-
accessToken: devAccessToken,
|
|
112
|
-
sha: 'myCommitSha',
|
|
113
|
-
sourceBranch: 'main',
|
|
114
|
-
})).rejects.toThrowError('No commit found on branch "main" with sha "myCommitSha"');
|
|
115
|
-
});
|
|
116
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const graphql_1 = require("graphql");
|
|
23
|
-
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
24
|
-
const apiRequestV4Module = __importStar(require("../apiRequestV4"));
|
|
25
|
-
const fetchCommitsByAuthor_1 = require("./fetchCommitsByAuthor");
|
|
26
|
-
describe('fetchCommitsByAuthor', () => {
|
|
27
|
-
let devAccessToken;
|
|
28
|
-
beforeAll(() => {
|
|
29
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
30
|
-
});
|
|
31
|
-
describe('snapshot request/response', () => {
|
|
32
|
-
let spy;
|
|
33
|
-
let commits;
|
|
34
|
-
beforeEach(async () => {
|
|
35
|
-
spy = jest.spyOn(apiRequestV4Module, 'apiRequestV4');
|
|
36
|
-
commits = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
37
|
-
accessToken: devAccessToken,
|
|
38
|
-
author: 'sqren',
|
|
39
|
-
maxNumber: 10,
|
|
40
|
-
repoName: 'kibana',
|
|
41
|
-
repoOwner: 'elastic',
|
|
42
|
-
sourceBranch: 'main',
|
|
43
|
-
dateSince: '2021-01-10T00:00:00Z',
|
|
44
|
-
dateUntil: '2022-01-01T00:00:00Z',
|
|
45
|
-
commitPaths: [],
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
it('makes the right queries', () => {
|
|
49
|
-
const queries = spy.mock.calls.reduce((acc, call) => {
|
|
50
|
-
const query = call[0].query;
|
|
51
|
-
//@ts-expect-error
|
|
52
|
-
const name = query.definitions[0].name.value;
|
|
53
|
-
return { ...acc, [name]: (0, graphql_1.print)(query) };
|
|
54
|
-
}, {});
|
|
55
|
-
const queryNames = Object.keys(queries);
|
|
56
|
-
expect(queryNames).toEqual(['AuthorId', 'CommitsByAuthor']);
|
|
57
|
-
queryNames.forEach((name) => {
|
|
58
|
-
expect(queries[name]).toMatchSnapshot(`Query: ${name}`);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
it('returns the correct response', async () => {
|
|
62
|
-
expect(commits).toMatchSnapshot();
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
describe('commitPaths', () => {
|
|
66
|
-
const getOptions = () => ({
|
|
67
|
-
accessToken: devAccessToken,
|
|
68
|
-
author: 'sqren',
|
|
69
|
-
maxNumber: 10,
|
|
70
|
-
repoName: 'repo-with-different-commit-paths',
|
|
71
|
-
repoOwner: 'backport-org',
|
|
72
|
-
sourceBranch: 'main',
|
|
73
|
-
dateSince: null,
|
|
74
|
-
dateUntil: null,
|
|
75
|
-
});
|
|
76
|
-
const getCommitMessages = (commits) => {
|
|
77
|
-
return commits.map((c) => c.sourceCommit.message.replace(/(\r\n|\n|\r)/gm, ''));
|
|
78
|
-
};
|
|
79
|
-
it('returns all commits', async () => {
|
|
80
|
-
const commits = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
81
|
-
...getOptions(),
|
|
82
|
-
commitPaths: [],
|
|
83
|
-
});
|
|
84
|
-
const commitMessages = getCommitMessages(commits);
|
|
85
|
-
expect(commitMessages).toEqual([
|
|
86
|
-
'Edit all lyrics',
|
|
87
|
-
'Update .backportrc.json',
|
|
88
|
-
'Edit "Take on me"',
|
|
89
|
-
'Add backportrc.json',
|
|
90
|
-
'Add "Bohemian Rhapsody""',
|
|
91
|
-
'Add "99 Luftballons"',
|
|
92
|
-
'Add "Take on me"',
|
|
93
|
-
]);
|
|
94
|
-
});
|
|
95
|
-
it('only returns commits related to "99-luftballons.txt"', async () => {
|
|
96
|
-
const commits = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
97
|
-
...getOptions(),
|
|
98
|
-
commitPaths: ['lyrics/99-luftballons.txt'],
|
|
99
|
-
});
|
|
100
|
-
const commitMessages = getCommitMessages(commits);
|
|
101
|
-
expect(commitMessages).toEqual([
|
|
102
|
-
'Edit all lyrics',
|
|
103
|
-
'Add "99 Luftballons"',
|
|
104
|
-
]);
|
|
105
|
-
});
|
|
106
|
-
it('only returns commits related to "take-on-me.txt"', async () => {
|
|
107
|
-
const commits = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
108
|
-
...getOptions(),
|
|
109
|
-
commitPaths: ['lyrics/take-on-me.txt'],
|
|
110
|
-
});
|
|
111
|
-
const commitMessages = getCommitMessages(commits);
|
|
112
|
-
expect(commitMessages).toEqual([
|
|
113
|
-
'Edit all lyrics',
|
|
114
|
-
'Edit "Take on me"',
|
|
115
|
-
'Add "Take on me"',
|
|
116
|
-
]);
|
|
117
|
-
});
|
|
118
|
-
it('removes duplicates and order by `committedDate`', async () => {
|
|
119
|
-
const commits = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
120
|
-
...getOptions(),
|
|
121
|
-
commitPaths: [
|
|
122
|
-
'lyrics/99-luftballons.txt',
|
|
123
|
-
'lyrics/take-on-me.txt',
|
|
124
|
-
'lyrics/bohemian-rhapsody.txt',
|
|
125
|
-
],
|
|
126
|
-
});
|
|
127
|
-
const commitMessages = getCommitMessages(commits);
|
|
128
|
-
expect(commitMessages).toEqual([
|
|
129
|
-
'Edit all lyrics',
|
|
130
|
-
'Edit "Take on me"',
|
|
131
|
-
'Add "Bohemian Rhapsody""',
|
|
132
|
-
'Add "99 Luftballons"',
|
|
133
|
-
'Add "Take on me"',
|
|
134
|
-
]);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
describe('expectedTargetPullRequests', () => {
|
|
138
|
-
let res;
|
|
139
|
-
beforeEach(async () => {
|
|
140
|
-
res = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
141
|
-
accessToken: devAccessToken,
|
|
142
|
-
commitPaths: [],
|
|
143
|
-
maxNumber: 10,
|
|
144
|
-
repoName: 'backport-e2e',
|
|
145
|
-
repoOwner: 'backport-org',
|
|
146
|
-
sourceBranch: 'master',
|
|
147
|
-
author: null,
|
|
148
|
-
dateSince: null,
|
|
149
|
-
dateUntil: null,
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
it('returns related OPEN PRs', async () => {
|
|
153
|
-
const commitWithOpenPR = res.find((commit) => commit.sourcePullRequest?.number === 9);
|
|
154
|
-
expect(commitWithOpenPR?.expectedTargetPullRequests).toEqual([
|
|
155
|
-
{
|
|
156
|
-
branch: '7.8',
|
|
157
|
-
state: 'OPEN',
|
|
158
|
-
number: 10,
|
|
159
|
-
url: 'https://github.com/backport-org/backport-e2e/pull/10',
|
|
160
|
-
},
|
|
161
|
-
]);
|
|
162
|
-
});
|
|
163
|
-
it('returns related MERGED PRs', async () => {
|
|
164
|
-
const commitWithMergedPRs = res.find((commit) => commit.sourcePullRequest?.number === 5);
|
|
165
|
-
expect(commitWithMergedPRs?.expectedTargetPullRequests).toEqual([
|
|
166
|
-
{
|
|
167
|
-
branch: '7.x',
|
|
168
|
-
state: 'MERGED',
|
|
169
|
-
number: 6,
|
|
170
|
-
url: 'https://github.com/backport-org/backport-e2e/pull/6',
|
|
171
|
-
mergeCommit: {
|
|
172
|
-
message: 'Add 🍏 emoji (#5) (#6)',
|
|
173
|
-
sha: '4bcd876d4ceaa73cf437bfc89b74d1a4e704c0a6',
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
branch: '7.8',
|
|
178
|
-
state: 'MERGED',
|
|
179
|
-
number: 7,
|
|
180
|
-
url: 'https://github.com/backport-org/backport-e2e/pull/7',
|
|
181
|
-
mergeCommit: {
|
|
182
|
-
message: 'Add 🍏 emoji (#5) (#7)',
|
|
183
|
-
sha: '46cd6f9999effdf894a36dbc7db90e890f4be840',
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
]);
|
|
187
|
-
});
|
|
188
|
-
it('returns missing pull requests', async () => {
|
|
189
|
-
const commitWithoutPRs = res.find((commit) => commit.sourcePullRequest?.number === 8);
|
|
190
|
-
expect(commitWithoutPRs?.expectedTargetPullRequests).toEqual([
|
|
191
|
-
{ branch: '7.x', state: 'MISSING' },
|
|
192
|
-
]);
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|