backport 7.2.0-beta.2 → 7.3.0-beta.1
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 +10 -5
- package/dist/entrypoint.cli.d.ts +0 -1
- package/dist/entrypoint.cli.js +0 -1
- package/dist/entrypoint.cli.private.test.d.ts +1 -0
- package/dist/entrypoint.cli.private.test.js +47 -0
- package/dist/options/ConfigOptions.d.ts +2 -0
- package/dist/options/cliArgs.test.d.ts +1 -0
- package/dist/options/cliArgs.test.js +182 -0
- package/dist/options/config/config.d.ts +2 -0
- package/dist/options/config/config.test.d.ts +1 -0
- package/dist/options/config/config.test.js +32 -0
- package/dist/options/config/globalConfig.test.d.ts +1 -0
- package/dist/options/config/globalConfig.test.js +61 -0
- package/dist/options/config/projectConfig.test.d.ts +1 -0
- package/dist/options/config/projectConfig.test.js +109 -0
- package/dist/options/config/readConfigFile.d.ts +2 -0
- package/dist/options/options.d.ts +2 -0
- package/dist/options/options.test.d.ts +1 -0
- package/dist/options/options.test.js +384 -0
- package/dist/runSequentially.js +2 -2
- package/dist/runSequentially.test.d.ts +1 -0
- package/dist/runSequentially.test.js +243 -0
- package/dist/scripts/postinstall.test.d.ts +1 -0
- package/dist/scripts/postinstall.test.js +53 -0
- package/dist/services/env.test.d.ts +1 -0
- package/dist/services/env.test.js +21 -0
- package/dist/services/git.d.ts +11 -4
- package/dist/services/git.integration.test.d.ts +1 -0
- package/dist/services/git.integration.test.js +286 -0
- package/dist/services/git.js +34 -16
- package/dist/services/git.test.d.ts +1 -0
- package/dist/services/git.test.js +543 -0
- package/dist/services/github/commitFormatters.test.d.ts +1 -0
- package/dist/services/github/commitFormatters.test.js +11 -0
- package/dist/services/github/v3/addAssigneesToPullRequest.test.d.ts +1 -0
- package/dist/services/github/v3/addAssigneesToPullRequest.test.js +27 -0
- package/dist/services/github/v3/createPullRequest.test.d.ts +1 -0
- package/dist/services/github/v3/createPullRequest.test.js +377 -0
- package/dist/services/github/v3/createStatusComment.test.d.ts +1 -0
- package/dist/services/github/v3/createStatusComment.test.js +396 -0
- package/dist/services/github/v4/apiRequestV4.test.d.ts +1 -0
- package/dist/services/github/v4/apiRequestV4.test.js +109 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.d.ts +1 -0
- package/dist/services/github/v4/enablePullRequestAutoMerge.private.test.js +112 -0
- package/dist/services/github/v4/fetchAuthorId.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchAuthorId.private.test.js +28 -0
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +94 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +135 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +117 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +195 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +157 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +104 -0
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchExistingPullRequest.private.test.js +47 -0
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.d.ts +1 -0
- package/dist/services/github/v4/fetchRemoteProjectConfig.private.test.js +52 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +2 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.d.ts +1 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.private.test.js +117 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +1 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.d.ts +1 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +71 -0
- package/dist/services/github/v4/mocks/commitsByAuthorMock.d.ts +2 -0
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +176 -0
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.d.ts +1 -0
- package/dist/services/github/v4/throwOnInvalidAccessToken.test.js +87 -0
- package/dist/services/prompt.test.d.ts +1 -0
- package/dist/services/prompt.test.js +139 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.d.ts +1 -0
- package/dist/services/sourceCommit/getExpectedTargetPullRequests.test.js +467 -0
- package/dist/services/sourceCommit/getMockSourceCommit.js +1 -0
- package/dist/services/sourceCommit/parseSourceCommit.d.ts +5 -0
- package/dist/services/sourceCommit/parseSourceCommit.js +6 -0
- package/dist/services/sourceCommit/parseSourceCommit.test.d.ts +1 -0
- package/dist/services/sourceCommit/parseSourceCommit.test.js +226 -0
- package/dist/test/ExecError.d.ts +16 -0
- package/dist/test/ExecError.js +15 -0
- package/dist/test/e2e/cli/cli.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/cli.private.test.js +215 -0
- package/dist/test/e2e/cli/different-merge-strategies.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/different-merge-strategies.private.test.js +108 -0
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +49 -0
- package/dist/test/e2e/cli/runBackportViaCli.d.ts +5 -0
- package/dist/test/e2e/cli/runBackportViaCli.js +53 -0
- package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.d.ts +1 -0
- package/dist/test/e2e/cli/test-that-repo-can-be-cloned.private.test.js +73 -0
- package/dist/test/e2e/cli.e2e.private.test.d.ts +1 -0
- package/dist/test/e2e/cli.e2e.private.test.js +433 -0
- package/dist/test/e2e/module.e2e.mutation.test.d.ts +1 -0
- package/dist/test/e2e/module.e2e.mutation.test.js +369 -0
- package/dist/test/e2e/module.e2e.private.test.d.ts +1 -0
- package/dist/test/e2e/module.e2e.private.test.js +369 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.d.ts +1 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.js +56 -0
- package/dist/test/mockConfigFiles.d.ts +5 -0
- package/dist/test/mockConfigFiles.js +21 -0
- package/dist/test/mocks.d.ts +10 -0
- package/dist/test/mocks.js +23 -0
- package/dist/test/nockHelpers.d.ts +16 -0
- package/dist/test/nockHelpers.js +36 -0
- package/dist/test/private/getDevAccessToken.d.ts +2 -0
- package/dist/test/private/getDevAccessToken.js +12 -0
- package/dist/test/sandbox.d.ts +5 -0
- package/dist/test/sandbox.js +43 -0
- package/dist/test/setupFiles/automatic-mocks.d.ts +1 -0
- package/dist/test/setupFiles/automatic-mocks.js +63 -0
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +3 -3
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.d.ts +1 -0
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +469 -0
- package/dist/ui/getCommitsWithoutBackports.test.d.ts +1 -0
- package/dist/ui/getCommitsWithoutBackports.test.js +331 -0
- package/dist/ui/getTargetBranches.test.d.ts +1 -0
- package/dist/ui/getTargetBranches.test.js +200 -0
- package/dist/ui/maybeSetupRepo.js +7 -3
- package/dist/ui/maybeSetupRepo.test.d.ts +1 -0
- package/dist/ui/maybeSetupRepo.test.js +238 -0
- package/dist/ui/ora.d.ts +1 -1
- package/dist/ui/ora.js +2 -2
- package/dist/ui/setupRepo.d.ts +3 -0
- package/dist/ui/setupRepo.js +88 -0
- package/dist/ui/setupRepo.test.d.ts +1 -0
- package/dist/ui/setupRepo.test.js +288 -0
- package/dist/utils/excludeUndefined.test.d.ts +1 -0
- package/dist/utils/excludeUndefined.test.js +24 -0
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +6 -6
- package/yarn.lock +3 -3
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getMockSourceCommit_1 = require("./getMockSourceCommit");
|
|
4
|
+
const parseSourceCommit_1 = require("./parseSourceCommit");
|
|
5
|
+
describe('parseSourceCommit', () => {
|
|
6
|
+
describe('pullNumber', () => {
|
|
7
|
+
it('receives `pullNumber` from the associated pull request', () => {
|
|
8
|
+
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
9
|
+
sourceCommit: { message: 'My commit message (#1234)' },
|
|
10
|
+
sourcePullRequest: { number: 55 },
|
|
11
|
+
});
|
|
12
|
+
const commit = (0, parseSourceCommit_1.parseSourceCommit)({
|
|
13
|
+
sourceCommit: mockSourceCommit,
|
|
14
|
+
options: {},
|
|
15
|
+
});
|
|
16
|
+
expect(commit.sourcePullRequest?.number).toBe(55);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
describe('sourceBranch', () => {
|
|
20
|
+
it('sets sourceBranch based on `baseRefName` from associated PR', () => {
|
|
21
|
+
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
22
|
+
sourceCommit: { message: 'My commit message (#66)' },
|
|
23
|
+
sourcePullRequest: { number: 55, sourceBranch: 'a sourcebranch' },
|
|
24
|
+
});
|
|
25
|
+
const commit = (0, parseSourceCommit_1.parseSourceCommit)({
|
|
26
|
+
sourceCommit: mockSourceCommit,
|
|
27
|
+
options: {},
|
|
28
|
+
});
|
|
29
|
+
expect(commit.sourceBranch).toBe('a sourcebranch');
|
|
30
|
+
});
|
|
31
|
+
it('sets uses options.sourceBranch as fallback', () => {
|
|
32
|
+
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
33
|
+
sourceCommit: { message: 'My commit message (#66)' },
|
|
34
|
+
sourcePullRequest: null,
|
|
35
|
+
});
|
|
36
|
+
const commit = (0, parseSourceCommit_1.parseSourceCommit)({
|
|
37
|
+
sourceCommit: mockSourceCommit,
|
|
38
|
+
options: {
|
|
39
|
+
sourceBranch: 'sourcebranch-from-options',
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
expect(commit.sourceBranch).toBe('sourcebranch-from-options');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
describe('expectedTargetPullRequests', () => {
|
|
46
|
+
it('uses options.branchLabelMapping when historicalBranchLabelMappings is empty', () => {
|
|
47
|
+
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
48
|
+
sourceCommit: {
|
|
49
|
+
message: 'My commit message (#66)',
|
|
50
|
+
commitedDate: '2021-03-03T00:00:00Z',
|
|
51
|
+
},
|
|
52
|
+
sourcePullRequest: {
|
|
53
|
+
sourceBranch: 'main',
|
|
54
|
+
number: 55,
|
|
55
|
+
labels: ['v6.4.0', 'v6.3.0', 'v6.2.0', 'v6.1.0'],
|
|
56
|
+
},
|
|
57
|
+
timelineItems: [
|
|
58
|
+
{
|
|
59
|
+
state: 'MERGED',
|
|
60
|
+
targetBranch: '6.3',
|
|
61
|
+
commitMessages: ['My commit message (#66)'],
|
|
62
|
+
number: 5678,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
state: 'OPEN',
|
|
66
|
+
targetBranch: '6.2',
|
|
67
|
+
commitMessages: ['My commit message (#66)'],
|
|
68
|
+
number: 9876,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
});
|
|
72
|
+
const commit = (0, parseSourceCommit_1.parseSourceCommit)({
|
|
73
|
+
sourceCommit: mockSourceCommit,
|
|
74
|
+
options: {
|
|
75
|
+
branchLabelMapping: {
|
|
76
|
+
'^v6.4.0$': 'main',
|
|
77
|
+
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
expect(commit.expectedTargetPullRequests).toEqual([
|
|
82
|
+
{
|
|
83
|
+
branch: '6.3',
|
|
84
|
+
number: 5678,
|
|
85
|
+
state: 'MERGED',
|
|
86
|
+
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
87
|
+
mergeCommit: {
|
|
88
|
+
message: 'My commit message (#66)',
|
|
89
|
+
sha: 'target-merge-commit-sha',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
branch: '6.2',
|
|
94
|
+
number: 9876,
|
|
95
|
+
state: 'OPEN',
|
|
96
|
+
url: 'https://github.com/elastic/kibana/pull/9876',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
branch: '6.1',
|
|
100
|
+
state: 'MISSING',
|
|
101
|
+
},
|
|
102
|
+
]);
|
|
103
|
+
});
|
|
104
|
+
it('uses the historical branchLabelMapping from 2021-02-02', () => {
|
|
105
|
+
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
106
|
+
sourceCommit: {
|
|
107
|
+
remoteConfig: {
|
|
108
|
+
branchLabelMapping: {
|
|
109
|
+
'^v6.3.0$': 'main',
|
|
110
|
+
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
111
|
+
},
|
|
112
|
+
committedDate: '2021-02-02T00:00:00Z',
|
|
113
|
+
},
|
|
114
|
+
message: 'My commit message (#66)',
|
|
115
|
+
commitedDate: '2021-03-03T00:00:00Z',
|
|
116
|
+
},
|
|
117
|
+
sourcePullRequest: {
|
|
118
|
+
sourceBranch: 'main',
|
|
119
|
+
number: 55,
|
|
120
|
+
labels: ['v6.3.0', 'v6.2.0', 'v6.1.0'],
|
|
121
|
+
},
|
|
122
|
+
timelineItems: [
|
|
123
|
+
{
|
|
124
|
+
state: 'OPEN',
|
|
125
|
+
targetBranch: '6.2',
|
|
126
|
+
commitMessages: ['My commit message (#66)'],
|
|
127
|
+
number: 9876,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
});
|
|
131
|
+
const commit = (0, parseSourceCommit_1.parseSourceCommit)({
|
|
132
|
+
sourceCommit: mockSourceCommit,
|
|
133
|
+
options: {
|
|
134
|
+
branchLabelMapping: {
|
|
135
|
+
'^v6.4.0$': 'main',
|
|
136
|
+
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
expect(commit.expectedTargetPullRequests).toEqual([
|
|
141
|
+
{
|
|
142
|
+
branch: '6.2',
|
|
143
|
+
number: 9876,
|
|
144
|
+
state: 'OPEN',
|
|
145
|
+
url: 'https://github.com/elastic/kibana/pull/9876',
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
branch: '6.1',
|
|
149
|
+
state: 'MISSING',
|
|
150
|
+
},
|
|
151
|
+
]);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
it('returns the correct source commit', () => {
|
|
155
|
+
const mockSourceCommit = (0, getMockSourceCommit_1.getMockSourceCommit)({
|
|
156
|
+
sourceCommit: { message: 'My commit message (#1234)', sha: 'my-sha' },
|
|
157
|
+
sourcePullRequest: {
|
|
158
|
+
number: 1234,
|
|
159
|
+
labels: ['v6.3.0', 'v6.2.0', 'v6.1.0'],
|
|
160
|
+
},
|
|
161
|
+
timelineItems: [
|
|
162
|
+
{
|
|
163
|
+
state: 'MERGED',
|
|
164
|
+
targetBranch: '6.x',
|
|
165
|
+
commitMessages: ['My commit message (#1234)'],
|
|
166
|
+
number: 5678,
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
state: 'OPEN',
|
|
170
|
+
targetBranch: '6.2',
|
|
171
|
+
commitMessages: ['My commit message (#1234)'],
|
|
172
|
+
number: 9876,
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
});
|
|
176
|
+
const commit = (0, parseSourceCommit_1.parseSourceCommit)({
|
|
177
|
+
sourceCommit: mockSourceCommit,
|
|
178
|
+
options: {
|
|
179
|
+
branchLabelMapping: {
|
|
180
|
+
'^v6.3.0$': '6.x',
|
|
181
|
+
'^v(\\d+).(\\d+).\\d+$': '$1.$2',
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
const expectedCommit = {
|
|
186
|
+
author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
|
|
187
|
+
sourceCommit: {
|
|
188
|
+
committedDate: '2021-12-22T00:00:00Z',
|
|
189
|
+
message: 'My commit message (#1234)',
|
|
190
|
+
sha: 'my-sha',
|
|
191
|
+
},
|
|
192
|
+
sourcePullRequest: {
|
|
193
|
+
number: 1234,
|
|
194
|
+
url: 'https://github.com/elastic/kibana/pull/1234',
|
|
195
|
+
mergeCommit: {
|
|
196
|
+
message: 'My commit message (#1234)',
|
|
197
|
+
sha: 'my-sha',
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
sourceBranch: 'source-branch-from-associated-pull-request',
|
|
201
|
+
expectedTargetPullRequests: [
|
|
202
|
+
{
|
|
203
|
+
branch: '6.x',
|
|
204
|
+
number: 5678,
|
|
205
|
+
state: 'MERGED',
|
|
206
|
+
url: 'https://github.com/elastic/kibana/pull/5678',
|
|
207
|
+
mergeCommit: {
|
|
208
|
+
message: 'My commit message (#1234)',
|
|
209
|
+
sha: 'target-merge-commit-sha',
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
branch: '6.2',
|
|
214
|
+
number: 9876,
|
|
215
|
+
state: 'OPEN',
|
|
216
|
+
url: 'https://github.com/elastic/kibana/pull/9876',
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
branch: '6.1',
|
|
220
|
+
state: 'MISSING',
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
};
|
|
224
|
+
expect(commit).toEqual(expectedCommit);
|
|
225
|
+
});
|
|
226
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SignalConstants } from 'os';
|
|
3
|
+
export declare class ExecError extends Error {
|
|
4
|
+
code: number | undefined;
|
|
5
|
+
cmd: string | undefined;
|
|
6
|
+
stdout: string | undefined;
|
|
7
|
+
stderr: string | undefined;
|
|
8
|
+
constructor(error: {
|
|
9
|
+
cmd?: string;
|
|
10
|
+
killed?: boolean;
|
|
11
|
+
code?: number;
|
|
12
|
+
signal?: SignalConstants | null;
|
|
13
|
+
stdout?: string;
|
|
14
|
+
stderr?: string;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecError = void 0;
|
|
4
|
+
class ExecError extends Error {
|
|
5
|
+
constructor(error) {
|
|
6
|
+
super(error.stderr);
|
|
7
|
+
this.name = 'ExecError';
|
|
8
|
+
this.code = error.code;
|
|
9
|
+
this.cmd = error.cmd;
|
|
10
|
+
this.stdout = error.stdout;
|
|
11
|
+
this.stderr = error.stderr;
|
|
12
|
+
Error.captureStackTrace(this, ExecError);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.ExecError = ExecError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,215 @@
|
|
|
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 child_process_promisified_1 = require("../../../services/child-process-promisified");
|
|
23
|
+
const packageVersion = __importStar(require("../../../utils/packageVersion"));
|
|
24
|
+
const getDevAccessToken_1 = require("../../private/getDevAccessToken");
|
|
25
|
+
const sandbox_1 = require("../../sandbox");
|
|
26
|
+
const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
27
|
+
const TIMEOUT_IN_SECONDS = 15;
|
|
28
|
+
jest.setTimeout(TIMEOUT_IN_SECONDS * 1000);
|
|
29
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
30
|
+
describe('backport cli', () => {
|
|
31
|
+
it('--version', async () => {
|
|
32
|
+
const res = await (0, runBackportViaCli_1.runBackportViaCli)([`--version`], {
|
|
33
|
+
showOra: true,
|
|
34
|
+
});
|
|
35
|
+
expect(res).toEqual(process.env.npm_package_version);
|
|
36
|
+
});
|
|
37
|
+
it('-v', async () => {
|
|
38
|
+
const res = await (0, runBackportViaCli_1.runBackportViaCli)([`-v`], {
|
|
39
|
+
showOra: true,
|
|
40
|
+
});
|
|
41
|
+
expect(res).toEqual(process.env.npm_package_version);
|
|
42
|
+
});
|
|
43
|
+
it('PACKAGE_VERSION should match', async () => {
|
|
44
|
+
// @ts-expect-error
|
|
45
|
+
expect(packageVersion.UNMOCKED_PACKAGE_VERSION).toBe(process.env.npm_package_version);
|
|
46
|
+
});
|
|
47
|
+
it('--help', async () => {
|
|
48
|
+
const res = await (0, runBackportViaCli_1.runBackportViaCli)([`--help`]);
|
|
49
|
+
expect(res).toMatchInlineSnapshot(`
|
|
50
|
+
"entrypoint.cli.ts [args]
|
|
51
|
+
Options:
|
|
52
|
+
-v, -V, --version Show version number [boolean]
|
|
53
|
+
--accessToken, --accesstoken Github access token [string]
|
|
54
|
+
-a, --all List all commits [boolean]
|
|
55
|
+
--assignee, --assign Add assignees to the target pull request [array]
|
|
56
|
+
--autoAssign Auto assign the target pull request to yourself [boolean]
|
|
57
|
+
--autoMerge Enable auto-merge for created pull requests [boolean]
|
|
58
|
+
--autoMergeMethod Sets auto-merge method when using --auto-merge. Default:
|
|
59
|
+
merge [string] [choices: \\"merge\\", \\"rebase\\", \\"squash\\"]
|
|
60
|
+
--ci Disable interactive prompts [boolean]
|
|
61
|
+
--cherrypickRef Append commit message with \\"(cherry picked from commit...)
|
|
62
|
+
[boolean]
|
|
63
|
+
--configFile, --config Path to project config [string]
|
|
64
|
+
--since ISO-8601 date for filtering commits [string]
|
|
65
|
+
--until ISO-8601 date for filtering commits [string]
|
|
66
|
+
--dir Location where the temporary repository will be stored
|
|
67
|
+
[string]
|
|
68
|
+
--details Show details about each commit [boolean]
|
|
69
|
+
--dryRun Run backport locally without pushing to Github [boolean]
|
|
70
|
+
--editor Editor to be opened during conflict resolution [string]
|
|
71
|
+
--skipRemoteConfig Use local .backportrc.json config instead of loading from
|
|
72
|
+
Github [boolean]
|
|
73
|
+
--fork Create backports in fork or origin repo [boolean]
|
|
74
|
+
--mainline Parent id of merge commit. Defaults to 1 when supplied
|
|
75
|
+
without arguments [number]
|
|
76
|
+
-n, --maxNumber, --number Number of commits to choose from [number]
|
|
77
|
+
--multiple Select multiple branches/commits [boolean]
|
|
78
|
+
--multipleBranches Backport to multiple branches [boolean]
|
|
79
|
+
--multipleCommits Backport multiple commits [boolean]
|
|
80
|
+
--noCherrypickRef Do not append commit message with \\"(cherry picked from
|
|
81
|
+
commit...)\\" [boolean]
|
|
82
|
+
--noStatusComment Don't publish status comment to Github [boolean]
|
|
83
|
+
--noVerify Bypass the pre-commit and commit-msg hooks [boolean]
|
|
84
|
+
--noFork Create backports in the origin repo [boolean]
|
|
85
|
+
-p, --path Only list commits touching files under the specified path
|
|
86
|
+
[array]
|
|
87
|
+
--prDescription, --description Description to be added to pull request [string]
|
|
88
|
+
--prTitle, --title Title of pull request [string]
|
|
89
|
+
--prFilter Filter source pull requests by a query [string]
|
|
90
|
+
--pullNumber, --pr Pull request to backport [number]
|
|
91
|
+
--resetAuthor Set yourself as commit author [boolean]
|
|
92
|
+
--reviewer Add reviewer to the target PR [array]
|
|
93
|
+
--repoOwner Repository owner [string]
|
|
94
|
+
--repoName Repository name [string]
|
|
95
|
+
--repo Repo owner and name [string]
|
|
96
|
+
--sha, --commit Commit sha to backport [string]
|
|
97
|
+
--sourceBranch Specify a non-default branch (normally \\"master\\") to backport
|
|
98
|
+
from [string]
|
|
99
|
+
--sourcePRLabel, --sourcePrLabel Add labels to the source (original) PR [array]
|
|
100
|
+
-b, --targetBranch, --branch Branch(es) to backport to [array]
|
|
101
|
+
--targetBranchChoice List branches to backport to [array]
|
|
102
|
+
-l, --targetPRLabel, --label Add labels to the target (backport) PR [array]
|
|
103
|
+
--username Defaults to the authenticated user [string]
|
|
104
|
+
--verbose Show additional debug information [boolean]
|
|
105
|
+
--verify Opposite of no-verify [boolean]
|
|
106
|
+
--help Show help [boolean]
|
|
107
|
+
For bugs, feature requests or questions: https://github.com/sqren/backport/issues
|
|
108
|
+
Or contact me directly: https://twitter.com/sorenlouv"
|
|
109
|
+
`);
|
|
110
|
+
});
|
|
111
|
+
it('should return error when branch is missing', async () => {
|
|
112
|
+
const res = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
113
|
+
'--skip-remote-config',
|
|
114
|
+
'--repo=backport-org/backport-e2e',
|
|
115
|
+
`--accessToken=${accessToken}`,
|
|
116
|
+
]);
|
|
117
|
+
expect(res).toMatchInlineSnapshot(`
|
|
118
|
+
"Please specify a target branch: \\"--branch 6.1\\".
|
|
119
|
+
Read more: https://github.com/sqren/backport/blob/main/docs/configuration.md#project-config-backportrcjson"
|
|
120
|
+
`);
|
|
121
|
+
});
|
|
122
|
+
it('should list commits based on .git/config when `repoOwner`/`repoName` is missing', async () => {
|
|
123
|
+
const sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
124
|
+
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
125
|
+
await (0, child_process_promisified_1.exec)(`git init`, { cwd: sandboxPath });
|
|
126
|
+
await (0, child_process_promisified_1.exec)(`git remote add origin git@github.com:backport-org/backport-e2e.git`, { cwd: sandboxPath });
|
|
127
|
+
const res = await (0, runBackportViaCli_1.runBackportViaCli)([`--accessToken=${accessToken}`], {
|
|
128
|
+
cwd: sandboxPath,
|
|
129
|
+
waitForString: 'Select commit',
|
|
130
|
+
});
|
|
131
|
+
expect(res).toMatchInlineSnapshot(`
|
|
132
|
+
"? Select commit (Use arrow keys)
|
|
133
|
+
❯ 1. Add sheep emoji (#9) 7.8
|
|
134
|
+
2. Change Ulysses to Gretha (conflict) (#8) 7.x
|
|
135
|
+
3. Add 🍏 emoji (#5) 7.x, 7.8
|
|
136
|
+
4. Add family emoji (#2) 7.x
|
|
137
|
+
5. Add \`backport\` dep
|
|
138
|
+
6. Merge pull request #1 from backport-org/add-heart-emoji
|
|
139
|
+
7. Add ❤️ emoji
|
|
140
|
+
8. Update .backportrc.json
|
|
141
|
+
9. Bump to 8.0.0
|
|
142
|
+
10.Add package.json"
|
|
143
|
+
`);
|
|
144
|
+
});
|
|
145
|
+
it('should return error when access token is invalid', async () => {
|
|
146
|
+
const res = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
147
|
+
'--branch=foo',
|
|
148
|
+
'--repo=foo/bar',
|
|
149
|
+
'--accessToken=some-token',
|
|
150
|
+
]);
|
|
151
|
+
expect(res).toContain('Please check your access token and make sure it is valid');
|
|
152
|
+
});
|
|
153
|
+
it(`should return error when repo doesn't exist`, async () => {
|
|
154
|
+
const res = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
155
|
+
'--branch=foo',
|
|
156
|
+
'--repo=foo/bar',
|
|
157
|
+
'--author=sqren',
|
|
158
|
+
`--accessToken=${accessToken}`,
|
|
159
|
+
]);
|
|
160
|
+
expect(res).toMatchInlineSnapshot(`"The repository \\"foo/bar\\" doesn't exist"`);
|
|
161
|
+
});
|
|
162
|
+
it(`should list commits from master`, async () => {
|
|
163
|
+
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
164
|
+
'--branch=foo',
|
|
165
|
+
'--repo=backport-org/backport-e2e',
|
|
166
|
+
'--author=sqren',
|
|
167
|
+
`--accessToken=${accessToken}`,
|
|
168
|
+
'--max-number=6',
|
|
169
|
+
], { waitForString: 'Select commit' });
|
|
170
|
+
expect(output).toMatchInlineSnapshot(`
|
|
171
|
+
"? Select commit (Use arrow keys)
|
|
172
|
+
❯ 1. Add sheep emoji (#9) 7.8
|
|
173
|
+
2. Change Ulysses to Gretha (conflict) (#8) 7.x
|
|
174
|
+
3. Add 🍏 emoji (#5) 7.x, 7.8
|
|
175
|
+
4. Add family emoji (#2) 7.x
|
|
176
|
+
5. Add \`backport\` dep
|
|
177
|
+
6. Merge pull request #1 from backport-org/add-heart-emoji"
|
|
178
|
+
`);
|
|
179
|
+
});
|
|
180
|
+
it(`should filter commits by "since" and "until"`, async () => {
|
|
181
|
+
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
182
|
+
'--branch=foo',
|
|
183
|
+
'--repo=backport-org/backport-e2e',
|
|
184
|
+
`--accessToken=${accessToken}`,
|
|
185
|
+
'--since=2020-08-15T10:00:00.000Z',
|
|
186
|
+
'--until=2020-08-15T10:30:00.000Z',
|
|
187
|
+
], { waitForString: 'Select commit' });
|
|
188
|
+
expect(output).toMatchInlineSnapshot(`
|
|
189
|
+
"? Select commit (Use arrow keys)
|
|
190
|
+
❯ 1. Bump to 8.0.0
|
|
191
|
+
2. Add package.json
|
|
192
|
+
3. Update .backportrc.json
|
|
193
|
+
4. Create .backportrc.json"
|
|
194
|
+
`);
|
|
195
|
+
});
|
|
196
|
+
it(`should list commits from 7.x`, async () => {
|
|
197
|
+
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
198
|
+
'--branch=foo',
|
|
199
|
+
'--repo=backport-org/backport-e2e',
|
|
200
|
+
'--author=sqren',
|
|
201
|
+
`--accessToken=${accessToken}`,
|
|
202
|
+
'--max-number=6',
|
|
203
|
+
'--source-branch=7.x',
|
|
204
|
+
], { waitForString: 'Select commit' });
|
|
205
|
+
expect(output).toMatchInlineSnapshot(`
|
|
206
|
+
"? Select commit (Use arrow keys)
|
|
207
|
+
❯ 1. Add 🍏 emoji (#5) (#6)
|
|
208
|
+
2. Change Ulysses to Carol
|
|
209
|
+
3. Add family emoji (#2) (#4)
|
|
210
|
+
4. Update .backportrc.json
|
|
211
|
+
5. Branch off: 7.9.0 (7.x)
|
|
212
|
+
6. Bump to 8.0.0"
|
|
213
|
+
`);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const child_process_promisified_1 = require("../../../services/child-process-promisified");
|
|
4
|
+
const getDevAccessToken_1 = require("../../private/getDevAccessToken");
|
|
5
|
+
const sandbox_1 = require("../../sandbox");
|
|
6
|
+
const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
7
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
8
|
+
describe('different-merge-strategies', () => {
|
|
9
|
+
it('list all commits regardless how they were merged', async () => {
|
|
10
|
+
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
11
|
+
'--branch=foo',
|
|
12
|
+
'--repo=backport-org/different-merge-strategies',
|
|
13
|
+
`--accessToken=${accessToken}`,
|
|
14
|
+
'-n=20',
|
|
15
|
+
], { waitForString: 'Select commit' });
|
|
16
|
+
expect(output).toMatchInlineSnapshot(`
|
|
17
|
+
"? Select commit (Use arrow keys)
|
|
18
|
+
❯ 1. Merge pull request #9 from backport-org/many-merge-commits
|
|
19
|
+
2. Merge strategy: Eighth of many merges
|
|
20
|
+
3. Merge strategy: Seventh of many merges
|
|
21
|
+
4. Merge strategy: Sixth of many merges
|
|
22
|
+
5. Merge strategy: Fifth of many merges
|
|
23
|
+
6. Merge strategy: Fourth of many merges
|
|
24
|
+
7. Merge strategy: Third of many merges
|
|
25
|
+
8. Merge strategy: Second of many merges
|
|
26
|
+
9. Merge strategy: First of many merges
|
|
27
|
+
10.Using squash to merge commits (#3) 7.x
|
|
28
|
+
11.Rebase strategy: Second commit 7.x
|
|
29
|
+
12.Rebase strategy: First commit
|
|
30
|
+
13.Merge pull request #1 from backport-org/merge-strategy
|
|
31
|
+
14.Merge strategy: Second commit
|
|
32
|
+
15.Merge strategy: First commit
|
|
33
|
+
16.Initial commit"
|
|
34
|
+
`);
|
|
35
|
+
});
|
|
36
|
+
describe('when selecting a merge commit', () => {
|
|
37
|
+
let output;
|
|
38
|
+
let sandboxPath;
|
|
39
|
+
beforeAll(async () => {
|
|
40
|
+
sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
41
|
+
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
42
|
+
output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
43
|
+
'--branch=7.x',
|
|
44
|
+
'--repo=backport-org/different-merge-strategies',
|
|
45
|
+
`--accessToken=${accessToken}`,
|
|
46
|
+
`--dir=${sandboxPath}`,
|
|
47
|
+
'--pr=9',
|
|
48
|
+
'--dry-run',
|
|
49
|
+
], { waitForString: 'Dry run complete', showOra: true });
|
|
50
|
+
});
|
|
51
|
+
it('runs to completion without errors', () => {
|
|
52
|
+
expect(output).toMatchInlineSnapshot(`
|
|
53
|
+
"- Initializing...
|
|
54
|
+
? Select pull request Merge pull request #9 from backport-org/many-merge-commits
|
|
55
|
+
✔ 100% Cloning repository from github.com (one-time operation)
|
|
56
|
+
Backporting to 7.x:
|
|
57
|
+
- Pulling latest changes
|
|
58
|
+
✔ Pulling latest changes
|
|
59
|
+
- Cherry-picking: Merge pull request #9 from backport-org/many-merge-commits
|
|
60
|
+
✔ Cherry-picking: Merge pull request #9 from backport-org/many-merge-commits
|
|
61
|
+
✔ Dry run complete"
|
|
62
|
+
`);
|
|
63
|
+
});
|
|
64
|
+
it('backports all immediate children of the merge commit', async () => {
|
|
65
|
+
const commits = await listCommits(sandboxPath);
|
|
66
|
+
expect(commits).toEqual([
|
|
67
|
+
'Merge strategy: Eighth of many merges',
|
|
68
|
+
'Merge strategy: Seventh of many merges',
|
|
69
|
+
'Merge strategy: Sixth of many merges',
|
|
70
|
+
'Merge strategy: Fifth of many merges',
|
|
71
|
+
'Merge strategy: Fourth of many merges',
|
|
72
|
+
'Merge strategy: Third of many merges',
|
|
73
|
+
'Merge strategy: Second of many merges',
|
|
74
|
+
'Merge strategy: First of many merges',
|
|
75
|
+
'Initial commit',
|
|
76
|
+
]);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
describe('when selecting anoter merge commit', () => {
|
|
80
|
+
let sandboxPath;
|
|
81
|
+
beforeAll(async () => {
|
|
82
|
+
sandboxPath = (0, sandbox_1.getSandboxPath)({ filename: __filename });
|
|
83
|
+
await (0, sandbox_1.resetSandbox)(sandboxPath);
|
|
84
|
+
await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
85
|
+
'--branch=7.x',
|
|
86
|
+
'--repo=backport-org/different-merge-strategies',
|
|
87
|
+
`--accessToken=${accessToken}`,
|
|
88
|
+
`--dir=${sandboxPath}`,
|
|
89
|
+
'--pr=1',
|
|
90
|
+
'--dry-run',
|
|
91
|
+
], { waitForString: 'Dry run complete', showOra: true });
|
|
92
|
+
});
|
|
93
|
+
it('backports all immediate children of the merge commit', async () => {
|
|
94
|
+
const commits = await listCommits(sandboxPath);
|
|
95
|
+
expect(commits).toEqual([
|
|
96
|
+
'Merge strategy: Second commit',
|
|
97
|
+
'Merge strategy: First commit',
|
|
98
|
+
'Initial commit',
|
|
99
|
+
]);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
async function listCommits(sandboxPath) {
|
|
104
|
+
const { stdout } = await (0, child_process_promisified_1.exec)('git --no-pager log --pretty=format:%s', {
|
|
105
|
+
cwd: sandboxPath,
|
|
106
|
+
});
|
|
107
|
+
return stdout.split('\n');
|
|
108
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getDevAccessToken_1 = require("../../private/getDevAccessToken");
|
|
4
|
+
const runBackportViaCli_1 = require("./runBackportViaCli");
|
|
5
|
+
const accessToken = (0, getDevAccessToken_1.getDevAccessToken)();
|
|
6
|
+
describe('repo-with-backportrc-removed (missing .backportrc.json config file)', () => {
|
|
7
|
+
it('should list commits', async () => {
|
|
8
|
+
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
9
|
+
'--branch=foo',
|
|
10
|
+
'--repo=backport-org/repo-with-backportrc-removed',
|
|
11
|
+
`--accessToken=${accessToken}`,
|
|
12
|
+
], { waitForString: 'Select commit' });
|
|
13
|
+
expect(output).toMatchInlineSnapshot(`
|
|
14
|
+
"? Select commit (Use arrow keys)
|
|
15
|
+
❯ 1. Rename README.me to README.md
|
|
16
|
+
2. Merge pull request #1 from backport-org/add-readme
|
|
17
|
+
3. Create README.me
|
|
18
|
+
4. Delete .backportrc.json
|
|
19
|
+
5. Create .backportrc.json
|
|
20
|
+
6. Delete .backportrc.json
|
|
21
|
+
7. Create .backportrc.json"
|
|
22
|
+
`);
|
|
23
|
+
});
|
|
24
|
+
it('should attempt to backport by PR', async () => {
|
|
25
|
+
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
26
|
+
'--branch=foo',
|
|
27
|
+
'--repo=backport-org/repo-with-backportrc-removed',
|
|
28
|
+
'--pr=1',
|
|
29
|
+
`--accessToken=${accessToken}`,
|
|
30
|
+
], { waitForString: "is invalid or doesn't exist" });
|
|
31
|
+
expect(output).toMatchInlineSnapshot(`
|
|
32
|
+
"
|
|
33
|
+
Backporting to foo:
|
|
34
|
+
The branch \\"foo\\" is invalid or doesn't exist"
|
|
35
|
+
`);
|
|
36
|
+
});
|
|
37
|
+
it('should attempt to backport by commit sha', async () => {
|
|
38
|
+
const output = await (0, runBackportViaCli_1.runBackportViaCli)([
|
|
39
|
+
'--branch=foo',
|
|
40
|
+
'--repo=backport-org/repo-with-backportrc-removed',
|
|
41
|
+
'--sha=be59df6912a550c8cb49ba3e18be3e512f3d608c',
|
|
42
|
+
`--accessToken=${accessToken}`,
|
|
43
|
+
], { waitForString: `Backporting to foo:` });
|
|
44
|
+
expect(output).toMatchInlineSnapshot(`
|
|
45
|
+
"
|
|
46
|
+
Backporting to foo:"
|
|
47
|
+
`);
|
|
48
|
+
});
|
|
49
|
+
});
|