backport 7.0.1-beta.2 → 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/backportRun.d.ts +1 -0
- package/dist/backportRun.js +3 -2
- package/dist/entrypoint.cli.js +12 -1
- 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 +2 -1
- package/dist/options/cliArgs.js +4 -0
- package/dist/options/config/config.d.ts +1 -1
- package/dist/options/config/readConfigFile.d.ts +2 -2
- package/dist/options/options.d.ts +3 -6
- package/dist/runSequentially.js +1 -0
- package/dist/services/HandledError.js +3 -1
- package/dist/services/git.d.ts +2 -0
- package/dist/services/git.js +47 -10
- package/dist/services/github/v3/addAssigneesToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addAssigneesToPullRequest.js +3 -6
- package/dist/services/github/v3/addLabelsToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addLabelsToPullRequest.js +3 -6
- package/dist/services/github/v3/addReviewersToPullRequest.d.ts +1 -1
- package/dist/services/github/v3/addReviewersToPullRequest.js +3 -6
- package/dist/services/github/v3/createPullRequest.js +2 -5
- package/dist/services/github/v3/createStatusComment.js +1 -1
- package/dist/services/github/v4/FetchPullRequestId.js +5 -1
- package/dist/services/github/v4/apiRequestV4.d.ts +7 -4
- package/dist/services/github/v4/apiRequestV4.js +22 -21
- package/dist/services/github/v4/disablePullRequestAutoMerge.js +5 -1
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +4 -3
- package/dist/services/github/v4/fetchAuthorId.js +5 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +24 -13
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +24 -13
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +20 -10
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.js +20 -9
- package/dist/services/github/v4/fetchExistingPullRequest.js +5 -1
- package/dist/services/github/v4/fetchPullRequestAutoMergeMethod.js +5 -1
- package/dist/services/github/v4/fetchRemoteProjectConfig.d.ts +1 -1
- package/dist/services/github/v4/fetchRemoteProjectConfig.js +13 -20
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -5
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +12 -66
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +3 -16
- package/dist/services/github/v4/getOptionsFromGithub/query.js +9 -19
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +5 -1
- package/dist/services/github/v4/throwOnInvalidAccessToken.js +6 -6
- package/dist/services/logger.d.ts +5 -5
- package/dist/services/logger.js +24 -23
- package/dist/services/remoteConfig.d.ts +20 -0
- package/dist/services/remoteConfig.js +52 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.d.ts +4 -1
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.js +5 -1
- package/dist/services/sourceCommit/getMockSourceCommit.d.ts +4 -0
- package/dist/services/sourceCommit/getMockSourceCommit.js +21 -6
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +3 -4
- package/dist/services/sourceCommit/parseSourceCommit.js +73 -77
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +16 -22
- package/dist/ui/getCommits.js +8 -6
- package/dist/ui/maybeSetupRepo.js +7 -14
- package/dist/ui/ora.d.ts +9 -0
- package/dist/ui/ora.js +21 -0
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +10 -10
- 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 -319
- 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 -386
- package/dist/runSequentially.test.d.ts +0 -1
- package/dist/runSequentially.test.js +0 -218
- 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 -267
- package/dist/services/git.test.d.ts +0 -1
- package/dist/services/git.test.js +0 -518
- 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/v3/index.d.ts +0 -1
- package/dist/services/github/v3/index.js +0 -61
- package/dist/services/github/v4/apiRequestV4.test.d.ts +0 -1
- package/dist/services/github/v4/apiRequestV4.test.js +0 -82
- 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 -96
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +0 -143
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +0 -124
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +0 -200
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +0 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +0 -153
- 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 -136
- 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 -154
- 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 -235
- 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 -32
- 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 -455
- 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,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const nock_1 = __importDefault(require("nock"));
|
|
7
|
-
const nockHelpers_1 = require("../../../../test/nockHelpers");
|
|
8
|
-
const commitsByAuthorMock_1 = require("../mocks/commitsByAuthorMock");
|
|
9
|
-
const fetchCommitsByAuthor_1 = require("./fetchCommitsByAuthor");
|
|
10
|
-
const defaultOptions = {
|
|
11
|
-
accessToken: 'myAccessToken',
|
|
12
|
-
author: 'sqren',
|
|
13
|
-
githubApiBaseUrlV4: 'http://localhost/graphql',
|
|
14
|
-
historicalBranchLabelMappings: [],
|
|
15
|
-
maxNumber: 10,
|
|
16
|
-
repoName: 'kibana',
|
|
17
|
-
repoOwner: 'elastic',
|
|
18
|
-
sourceBranch: 'source-branch-from-options',
|
|
19
|
-
dateSince: null,
|
|
20
|
-
dateUntil: null,
|
|
21
|
-
};
|
|
22
|
-
const authorIdMockData = { user: { id: 'myUserId' } };
|
|
23
|
-
describe('fetchCommitsByAuthor', () => {
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
jest.clearAllMocks();
|
|
26
|
-
});
|
|
27
|
-
afterEach(() => {
|
|
28
|
-
nock_1.default.cleanAll();
|
|
29
|
-
});
|
|
30
|
-
describe('when commit has an associated pull request', () => {
|
|
31
|
-
let res;
|
|
32
|
-
let authorIdCalls;
|
|
33
|
-
let commitsByAuthorCalls;
|
|
34
|
-
beforeEach(async () => {
|
|
35
|
-
authorIdCalls = (0, nockHelpers_1.mockGqlRequest)({
|
|
36
|
-
name: 'AuthorId',
|
|
37
|
-
statusCode: 200,
|
|
38
|
-
body: { data: authorIdMockData },
|
|
39
|
-
});
|
|
40
|
-
commitsByAuthorCalls = (0, nockHelpers_1.mockGqlRequest)({
|
|
41
|
-
name: 'CommitsByAuthor',
|
|
42
|
-
statusCode: 200,
|
|
43
|
-
body: { data: commitsByAuthorMock_1.commitsByAuthorMock },
|
|
44
|
-
});
|
|
45
|
-
res = await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)(defaultOptions);
|
|
46
|
-
});
|
|
47
|
-
it('should return a list of commits with pullNumber and existing backports', () => {
|
|
48
|
-
const expectedCommits = [
|
|
49
|
-
{
|
|
50
|
-
sourceCommit: {
|
|
51
|
-
committedDate: '2021-12-24T00:00:00Z',
|
|
52
|
-
sha: '2e63475c483f7844b0f2833bc57fdee32095bacb',
|
|
53
|
-
message: 'Add 👻',
|
|
54
|
-
},
|
|
55
|
-
expectedTargetPullRequests: [],
|
|
56
|
-
sourceBranch: 'source-branch-from-options',
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
sourceCommit: {
|
|
60
|
-
committedDate: '2021-12-23T00:00:00Z',
|
|
61
|
-
sha: 'f3b618b9421fdecdb36862f907afbdd6344b361d',
|
|
62
|
-
message: 'Add witch (#85)',
|
|
63
|
-
},
|
|
64
|
-
sourcePullRequest: {
|
|
65
|
-
number: 85,
|
|
66
|
-
url: 'https://github.com/elastic/kibana/pull/85',
|
|
67
|
-
mergeCommit: {
|
|
68
|
-
sha: 'f3b618b9421fdecdb36862f907afbdd6344b361d',
|
|
69
|
-
message: 'Add witch (#85)',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
expectedTargetPullRequests: [],
|
|
73
|
-
sourceBranch: 'master',
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
sourceCommit: {
|
|
77
|
-
committedDate: '2021-12-22T00:00:00Z',
|
|
78
|
-
sha: '79cf18453ec32a4677009dcbab1c9c8c73fc14fe',
|
|
79
|
-
message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
|
|
80
|
-
},
|
|
81
|
-
sourcePullRequest: {
|
|
82
|
-
number: 80,
|
|
83
|
-
url: 'https://github.com/elastic/kibana/pull/80',
|
|
84
|
-
mergeCommit: {
|
|
85
|
-
sha: '79cf18453ec32a4677009dcbab1c9c8c73fc14fe',
|
|
86
|
-
message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
expectedTargetPullRequests: [
|
|
90
|
-
{
|
|
91
|
-
branch: '6.3',
|
|
92
|
-
state: 'MERGED',
|
|
93
|
-
number: 99,
|
|
94
|
-
url: 'https://github.com/elastic/kibana/pull/99',
|
|
95
|
-
mergeCommit: {
|
|
96
|
-
message: 'Add SF mention (#80)\n\n* Add SF mention\r\n\r\n* Add several emojis!',
|
|
97
|
-
sha: 'target-merge-commit-sha',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
sourceBranch: 'master',
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
sourceCommit: {
|
|
105
|
-
committedDate: '2021-12-21T00:00:00Z',
|
|
106
|
-
sha: '3827bbbaf39914eda4f02f6940189844375fd097',
|
|
107
|
-
message: 'Add backport config',
|
|
108
|
-
},
|
|
109
|
-
expectedTargetPullRequests: [],
|
|
110
|
-
sourceBranch: 'source-branch-from-options',
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
sourceCommit: {
|
|
114
|
-
committedDate: '2021-12-20T00:00:00Z',
|
|
115
|
-
sha: '5ea0da550ac191029459289d67f99ad7d310812b',
|
|
116
|
-
message: 'Initial commit',
|
|
117
|
-
},
|
|
118
|
-
expectedTargetPullRequests: [],
|
|
119
|
-
sourceBranch: 'source-branch-from-options',
|
|
120
|
-
},
|
|
121
|
-
];
|
|
122
|
-
expect(res).toEqual(expectedCommits);
|
|
123
|
-
});
|
|
124
|
-
it('should call with correct args to fetch author id', () => {
|
|
125
|
-
expect(authorIdCalls).toMatchSnapshot();
|
|
126
|
-
});
|
|
127
|
-
it('should call with correct args to fetch commits', () => {
|
|
128
|
-
expect(commitsByAuthorCalls).toMatchSnapshot();
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
describe('when a custom github api hostname is supplied', () => {
|
|
132
|
-
it('should be used in gql requests', async () => {
|
|
133
|
-
const authorIdCalls = (0, nockHelpers_1.mockGqlRequest)({
|
|
134
|
-
name: 'AuthorId',
|
|
135
|
-
statusCode: 200,
|
|
136
|
-
body: { data: authorIdMockData },
|
|
137
|
-
apiBaseUrl: 'http://localhost/my-custom-api',
|
|
138
|
-
});
|
|
139
|
-
const commitsByAuthorCalls = (0, nockHelpers_1.mockGqlRequest)({
|
|
140
|
-
name: 'CommitsByAuthor',
|
|
141
|
-
statusCode: 200,
|
|
142
|
-
body: { data: commitsByAuthorMock_1.commitsByAuthorMock },
|
|
143
|
-
apiBaseUrl: 'http://localhost/my-custom-api',
|
|
144
|
-
});
|
|
145
|
-
await (0, fetchCommitsByAuthor_1.fetchCommitsByAuthor)({
|
|
146
|
-
...defaultOptions,
|
|
147
|
-
githubApiBaseUrlV4: 'http://localhost/my-custom-api',
|
|
148
|
-
});
|
|
149
|
-
expect(authorIdCalls.length).toBe(1);
|
|
150
|
-
expect(commitsByAuthorCalls.length).toBe(1);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
});
|
package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
4
|
-
const fetchPullRequestBySearchQuery_1 = require("./fetchPullRequestBySearchQuery");
|
|
5
|
-
describe('fetchPullRequestBySearchQuery', () => {
|
|
6
|
-
let devAccessToken;
|
|
7
|
-
beforeAll(() => {
|
|
8
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
|
-
});
|
|
10
|
-
describe('when filter does not match any PRs', () => {
|
|
11
|
-
it('throws an error', async () => {
|
|
12
|
-
const options = {
|
|
13
|
-
accessToken: devAccessToken,
|
|
14
|
-
maxNumber: 10,
|
|
15
|
-
prFilter: 'label:non-existing',
|
|
16
|
-
repoName: 'backport-e2e',
|
|
17
|
-
repoOwner: 'backport-org',
|
|
18
|
-
sourceBranch: 'master',
|
|
19
|
-
author: 'sqren',
|
|
20
|
-
};
|
|
21
|
-
await expect((0, fetchPullRequestBySearchQuery_1.fetchPullRequestBySearchQuery)(options)).rejects.toThrowError('There are no commits by "sqren" matching the filter "label:non-existing". Try with `--all` for commits by all users or `--author=<username>` for commits from a specific user');
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
describe('when filter matches PRs', () => {
|
|
25
|
-
it('returns the merge commits for those PRs', async () => {
|
|
26
|
-
const options = {
|
|
27
|
-
accessToken: devAccessToken,
|
|
28
|
-
maxNumber: 10,
|
|
29
|
-
prFilter: 'label:v7.8.0',
|
|
30
|
-
repoName: 'backport-e2e',
|
|
31
|
-
repoOwner: 'backport-org',
|
|
32
|
-
sourceBranch: 'master',
|
|
33
|
-
author: 'sqren',
|
|
34
|
-
};
|
|
35
|
-
const expectedCommits = [
|
|
36
|
-
{
|
|
37
|
-
sourceCommit: {
|
|
38
|
-
committedDate: '2020-08-16T21:44:28Z',
|
|
39
|
-
message: 'Add sheep emoji (#9)',
|
|
40
|
-
sha: 'eebf165c82a4b718d95c11b3877e365b1949ff28',
|
|
41
|
-
},
|
|
42
|
-
sourcePullRequest: {
|
|
43
|
-
number: 9,
|
|
44
|
-
url: 'https://github.com/backport-org/backport-e2e/pull/9',
|
|
45
|
-
mergeCommit: {
|
|
46
|
-
message: 'Add sheep emoji (#9)',
|
|
47
|
-
sha: 'eebf165c82a4b718d95c11b3877e365b1949ff28',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
sourceBranch: 'master',
|
|
51
|
-
expectedTargetPullRequests: [
|
|
52
|
-
{
|
|
53
|
-
branch: '7.8',
|
|
54
|
-
state: 'OPEN',
|
|
55
|
-
number: 10,
|
|
56
|
-
url: 'https://github.com/backport-org/backport-e2e/pull/10',
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
sourceCommit: {
|
|
62
|
-
committedDate: '2020-08-15T12:40:19Z',
|
|
63
|
-
message: 'Add 🍏 emoji (#5)',
|
|
64
|
-
sha: 'ee8c492334cef1ca077a56addb79a26f79821d2f',
|
|
65
|
-
},
|
|
66
|
-
sourcePullRequest: {
|
|
67
|
-
number: 5,
|
|
68
|
-
url: 'https://github.com/backport-org/backport-e2e/pull/5',
|
|
69
|
-
mergeCommit: {
|
|
70
|
-
message: 'Add 🍏 emoji (#5)',
|
|
71
|
-
sha: 'ee8c492334cef1ca077a56addb79a26f79821d2f',
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
sourceBranch: 'master',
|
|
75
|
-
expectedTargetPullRequests: [
|
|
76
|
-
{
|
|
77
|
-
branch: '7.x',
|
|
78
|
-
state: 'MERGED',
|
|
79
|
-
number: 6,
|
|
80
|
-
url: 'https://github.com/backport-org/backport-e2e/pull/6',
|
|
81
|
-
mergeCommit: {
|
|
82
|
-
message: 'Add 🍏 emoji (#5) (#6)',
|
|
83
|
-
sha: '4bcd876d4ceaa73cf437bfc89b74d1a4e704c0a6',
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
branch: '7.8',
|
|
88
|
-
state: 'MERGED',
|
|
89
|
-
number: 7,
|
|
90
|
-
url: 'https://github.com/backport-org/backport-e2e/pull/7',
|
|
91
|
-
mergeCommit: {
|
|
92
|
-
message: 'Add 🍏 emoji (#5) (#7)',
|
|
93
|
-
sha: '46cd6f9999effdf894a36dbc7db90e890f4be840',
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
];
|
|
99
|
-
expect(await (0, fetchPullRequestBySearchQuery_1.fetchPullRequestBySearchQuery)(options)).toEqual(expectedCommits);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
4
|
-
const fetchExistingPullRequest_1 = require("./fetchExistingPullRequest");
|
|
5
|
-
describe('fetchExistingPullRequest', () => {
|
|
6
|
-
let devAccessToken;
|
|
7
|
-
beforeAll(() => {
|
|
8
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
|
-
});
|
|
10
|
-
describe('when PR does not exist', () => {
|
|
11
|
-
it('returns undefined', async () => {
|
|
12
|
-
const options = {
|
|
13
|
-
accessToken: devAccessToken,
|
|
14
|
-
};
|
|
15
|
-
const prPayload = {
|
|
16
|
-
owner: 'backport-org',
|
|
17
|
-
repo: 'backport-e2e',
|
|
18
|
-
title: 'My PR title',
|
|
19
|
-
body: 'My PR body',
|
|
20
|
-
head: 'sqren:backport/7.8/pr-foo',
|
|
21
|
-
base: '7.8',
|
|
22
|
-
};
|
|
23
|
-
const res = await (0, fetchExistingPullRequest_1.fetchExistingPullRequest)({ options, prPayload });
|
|
24
|
-
expect(res).toBe(undefined);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe('when PR exists', () => {
|
|
28
|
-
it('returns the PR number and url', async () => {
|
|
29
|
-
const options = {
|
|
30
|
-
accessToken: devAccessToken,
|
|
31
|
-
};
|
|
32
|
-
const prPayload = {
|
|
33
|
-
owner: 'backport-org',
|
|
34
|
-
repo: 'backport-e2e',
|
|
35
|
-
title: 'My PR title',
|
|
36
|
-
body: 'My PR body',
|
|
37
|
-
head: 'sqren:backport/7.8/pr-9',
|
|
38
|
-
base: '7.8',
|
|
39
|
-
};
|
|
40
|
-
const res = await (0, fetchExistingPullRequest_1.fetchExistingPullRequest)({ options, prPayload });
|
|
41
|
-
expect(res).toEqual({
|
|
42
|
-
url: 'https://github.com/backport-org/backport-e2e/pull/10',
|
|
43
|
-
number: 10,
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
4
|
-
const fetchRemoteProjectConfig_1 = require("./fetchRemoteProjectConfig");
|
|
5
|
-
describe('fetchRemoteProjectConfig', () => {
|
|
6
|
-
let devAccessToken;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
9
|
-
});
|
|
10
|
-
it('returns the backport config from "main" branch', async () => {
|
|
11
|
-
const projectConfig = await (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
12
|
-
repoOwner: 'backport-org',
|
|
13
|
-
repoName: 'repo-with-project-config',
|
|
14
|
-
accessToken: devAccessToken,
|
|
15
|
-
sourceBranch: 'main',
|
|
16
|
-
});
|
|
17
|
-
expect(projectConfig).toEqual({
|
|
18
|
-
autoMerge: true,
|
|
19
|
-
autoMergeMethod: 'squash',
|
|
20
|
-
branchLabelMapping: {
|
|
21
|
-
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
22
|
-
'^v8.1.0$': 'main',
|
|
23
|
-
},
|
|
24
|
-
targetBranchChoices: ['main', '8.0', '7.17', '7.16'],
|
|
25
|
-
targetPRLabels: ['backport'],
|
|
26
|
-
repoOwner: 'backport-org',
|
|
27
|
-
repoName: 'repo-with-project-config',
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
it('returns the backport config from "branch-with-legacy-config" branch', async () => {
|
|
31
|
-
const projectConfig = await (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
32
|
-
repoOwner: 'backport-org',
|
|
33
|
-
repoName: 'repo-with-project-config',
|
|
34
|
-
accessToken: devAccessToken,
|
|
35
|
-
sourceBranch: 'branch-with-legacy-config',
|
|
36
|
-
});
|
|
37
|
-
expect(projectConfig).toEqual({
|
|
38
|
-
targetBranchChoices: ['main', '8.0', '7.17', '7.16'],
|
|
39
|
-
repoOwner: 'backport-org',
|
|
40
|
-
repoName: 'repo-with-project-config',
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
it('throws an error if config does not exist', async () => {
|
|
44
|
-
const promise = (0, fetchRemoteProjectConfig_1.fetchRemoteProjectConfig)({
|
|
45
|
-
repoOwner: 'backport-org',
|
|
46
|
-
repoName: 'repo-with-project-config',
|
|
47
|
-
accessToken: devAccessToken,
|
|
48
|
-
sourceBranch: 'branch-with-no-config',
|
|
49
|
-
});
|
|
50
|
-
await expect(promise).rejects.toThrowError('Project config does not exist');
|
|
51
|
-
});
|
|
52
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const os_1 = __importDefault(require("os"));
|
|
7
|
-
const getDevAccessToken_1 = require("../../../../test/private/getDevAccessToken");
|
|
8
|
-
const getOptionsFromGithub_1 = require("./getOptionsFromGithub");
|
|
9
|
-
describe('getOptionsFromGithub', () => {
|
|
10
|
-
let devAccessToken;
|
|
11
|
-
beforeAll(async () => {
|
|
12
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
13
|
-
jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
|
|
14
|
-
});
|
|
15
|
-
describe('access token', () => {
|
|
16
|
-
describe('is invalid', () => {
|
|
17
|
-
it('throws an error', async () => {
|
|
18
|
-
const combinedOptions = {
|
|
19
|
-
author: 'sqren',
|
|
20
|
-
accessToken: 'foo',
|
|
21
|
-
repoOwner: 'backport-org',
|
|
22
|
-
repoName: 'backport-e2e',
|
|
23
|
-
cwd: process.cwd(),
|
|
24
|
-
};
|
|
25
|
-
await expect((0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions)).rejects.toThrowError('Please check your access token and make sure it is valid.\nConfig: /myHomeDir/.backport/config.json');
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
describe('is valid', () => {
|
|
29
|
-
it('returns the options', async () => {
|
|
30
|
-
const combinedOptions = {
|
|
31
|
-
author: 'sqren',
|
|
32
|
-
accessToken: devAccessToken,
|
|
33
|
-
repoOwner: 'backport-org',
|
|
34
|
-
repoName: 'backport-e2e',
|
|
35
|
-
cwd: process.cwd(),
|
|
36
|
-
};
|
|
37
|
-
expect(await (0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions)).toEqual({
|
|
38
|
-
authenticatedUsername: 'sqren',
|
|
39
|
-
branchLabelMapping: {
|
|
40
|
-
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
41
|
-
'^v7.9.0$': '7.x',
|
|
42
|
-
'^v8.0.0$': 'master',
|
|
43
|
-
},
|
|
44
|
-
historicalBranchLabelMappings: [
|
|
45
|
-
{
|
|
46
|
-
branchLabelMapping: {
|
|
47
|
-
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
48
|
-
'^v7.9.0$': '7.x',
|
|
49
|
-
'^v8.0.0$': 'master',
|
|
50
|
-
},
|
|
51
|
-
committedDate: '2020-08-15T10:33:06Z',
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
branchLabelMapping: { '6.1': '6.1', '6.3': '6.3' },
|
|
55
|
-
committedDate: '2020-08-15T10:20:23Z',
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
branchLabelMapping: { '6.1': '6.1', '6.3': '6.3' },
|
|
59
|
-
committedDate: '2020-08-15T10:17:57Z',
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
sourceBranch: 'master',
|
|
63
|
-
targetBranchChoices: [
|
|
64
|
-
{ checked: true, name: 'master' },
|
|
65
|
-
{ checked: true, name: '7.x' },
|
|
66
|
-
'7.8',
|
|
67
|
-
],
|
|
68
|
-
targetPRLabels: ['backport'],
|
|
69
|
-
repoOwner: 'backport-org',
|
|
70
|
-
repoName: 'backport-e2e',
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
describe('when `repoOwner` is fork', () => {
|
|
76
|
-
it('returns original repoOwner', async () => {
|
|
77
|
-
const combinedOptions = {
|
|
78
|
-
author: 'sqren',
|
|
79
|
-
accessToken: devAccessToken,
|
|
80
|
-
repoOwner: 'sqren',
|
|
81
|
-
repoName: 'backport-e2e',
|
|
82
|
-
cwd: process.cwd(),
|
|
83
|
-
};
|
|
84
|
-
const options = await (0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions);
|
|
85
|
-
await expect(options.repoOwner).toEqual('backport-org');
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
describe('sourceBranch', () => {
|
|
89
|
-
describe('when no sourceBranch is specified', () => {
|
|
90
|
-
it('uses the default branch of the repo', async () => {
|
|
91
|
-
const combinedOptions = {
|
|
92
|
-
author: 'sqren',
|
|
93
|
-
accessToken: devAccessToken,
|
|
94
|
-
repoOwner: 'backport-org',
|
|
95
|
-
repoName: 'repo-with-non-standard-main-branch',
|
|
96
|
-
cwd: process.cwd(),
|
|
97
|
-
};
|
|
98
|
-
const options = await (0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions);
|
|
99
|
-
await expect(options.sourceBranch).toEqual('my-custom-default-branch');
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
describe('when a branch named "backport"', () => {
|
|
104
|
-
describe('exists', () => {
|
|
105
|
-
it('shows a warning', async () => {
|
|
106
|
-
const combinedOptions = {
|
|
107
|
-
author: 'sqren',
|
|
108
|
-
accessToken: devAccessToken,
|
|
109
|
-
repoOwner: 'backport-org',
|
|
110
|
-
repoName: 'repo-with-branch-named-backport',
|
|
111
|
-
cwd: process.cwd(),
|
|
112
|
-
};
|
|
113
|
-
await expect(async () => {
|
|
114
|
-
await (0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions);
|
|
115
|
-
}).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
describe('when a backportrc.json config was deleted from repo', () => {
|
|
120
|
-
it('does not throw', async () => {
|
|
121
|
-
const combinedOptions = {
|
|
122
|
-
author: 'sqren',
|
|
123
|
-
accessToken: devAccessToken,
|
|
124
|
-
repoOwner: 'backport-org',
|
|
125
|
-
repoName: 'repo-with-backportrc-removed',
|
|
126
|
-
cwd: process.cwd(),
|
|
127
|
-
};
|
|
128
|
-
const options = await (0, getOptionsFromGithub_1.getOptionsFromGithub)(combinedOptions);
|
|
129
|
-
expect(options).toEqual({
|
|
130
|
-
authenticatedUsername: 'sqren',
|
|
131
|
-
sourceBranch: 'main',
|
|
132
|
-
historicalBranchLabelMappings: [],
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,71 +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 getDevAccessToken_1 = require("../../../test/private/getDevAccessToken");
|
|
23
|
-
const sandbox_1 = require("../../../test/sandbox");
|
|
24
|
-
const childProcess = __importStar(require("../../child-process-promisified"));
|
|
25
|
-
const getRepoOwnerAndNameFromGitRemotes_1 = require("./getRepoOwnerAndNameFromGitRemotes");
|
|
26
|
-
const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
27
|
-
describe('fetchRemoteProjectConfig', () => {
|
|
28
|
-
let devAccessToken;
|
|
29
|
-
beforeEach(() => {
|
|
30
|
-
devAccessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
31
|
-
});
|
|
32
|
-
describe('when the remote is a fork', () => {
|
|
33
|
-
it('retrives the original owner from github', async () => {
|
|
34
|
-
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
35
|
-
const execOpts = { cwd: sandboxPath };
|
|
36
|
-
await childProcess.exec(`git init`, execOpts);
|
|
37
|
-
await childProcess.exec(`git remote add sqren git@github.com:sqren/kibana.git`, execOpts);
|
|
38
|
-
expect(await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
|
|
39
|
-
accessToken: devAccessToken,
|
|
40
|
-
cwd: sandboxPath,
|
|
41
|
-
})).toEqual({
|
|
42
|
-
repoName: 'kibana',
|
|
43
|
-
repoOwner: 'elastic',
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
describe('when none of the git remotes are found', () => {
|
|
48
|
-
it('swallows the error and returns empty', async () => {
|
|
49
|
-
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
50
|
-
const execOpts = { cwd: sandboxPath };
|
|
51
|
-
await childProcess.exec(`git init`, execOpts);
|
|
52
|
-
await childProcess.exec(`git remote add foo git@github.com:foo/kibana.git`, execOpts);
|
|
53
|
-
await childProcess.exec(`git remote add bar git@github.com:bar/kibana.git`, execOpts);
|
|
54
|
-
expect(await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
|
|
55
|
-
accessToken: devAccessToken,
|
|
56
|
-
cwd: sandboxPath,
|
|
57
|
-
})).toEqual({});
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
describe('when there are no git remotes', () => {
|
|
61
|
-
it('returns empty', async () => {
|
|
62
|
-
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
63
|
-
const execOpts = { cwd: sandboxPath };
|
|
64
|
-
await childProcess.exec(`git init`, execOpts);
|
|
65
|
-
expect(await (0, getRepoOwnerAndNameFromGitRemotes_1.getRepoOwnerAndNameFromGitRemotes)({
|
|
66
|
-
accessToken: devAccessToken,
|
|
67
|
-
cwd: sandboxPath,
|
|
68
|
-
})).toEqual({});
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
});
|