backport 7.4.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -13
- package/dist/backportRun.d.ts +8 -3
- package/dist/backportRun.js +54 -42
- package/dist/entrypoint.cli.js +1 -1
- package/dist/entrypoint.module.d.ts +8 -3
- package/dist/entrypoint.module.js +3 -11
- package/dist/entrypoint.module.private.test.js +47 -346
- package/dist/options/cliArgs.d.ts +9 -4
- package/dist/options/cliArgs.js +28 -15
- package/dist/options/cliArgs.test.js +3 -3
- package/dist/options/config/globalConfig.d.ts +2 -2
- package/dist/options/config/globalConfig.js +13 -10
- package/dist/options/config/readConfigFile.d.ts +2 -2
- package/dist/options/options.d.ts +3 -3
- package/dist/options/options.test.js +5 -1
- package/dist/runSequentially.d.ts +6 -2
- package/dist/runSequentially.js +23 -7
- package/dist/scripts/postinstall.js +1 -0
- package/dist/scripts/postinstall.test.js +5 -1
- package/dist/services/HandledError.d.ts +1 -1
- package/dist/services/HandledError.js +2 -2
- package/dist/services/child-process-promisified.d.ts +19 -3
- package/dist/services/child-process-promisified.js +46 -17
- package/dist/services/git.d.ts +6 -7
- package/dist/services/git.integration.test.js +381 -65
- package/dist/services/git.js +188 -122
- package/dist/services/git.private.test.d.ts +1 -0
- package/dist/services/git.private.test.js +618 -0
- package/dist/services/git.test.js +167 -124
- package/dist/services/github/v3/addAssigneesToPullRequest.js +1 -1
- package/dist/services/github/v3/addLabelsToPullRequest.js +1 -1
- package/dist/services/github/v3/addReviewersToPullRequest.js +2 -1
- package/dist/services/github/v3/createPullRequest.js +3 -1
- package/dist/services/github/v3/createStatusComment.js +14 -15
- package/dist/services/github/v3/createStatusComment.test.js +15 -5
- package/dist/services/github/v4/enablePullRequestAutoMerge.js +2 -4
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.js +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +5 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.js +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +5 -1
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.js +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.private.test.js +5 -1
- package/dist/services/github/v4/fetchCommits/fetchPullRequestsBySearchQuery.js +1 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.private.test.js +5 -1
- package/dist/services/logger.js +5 -1
- package/dist/services/test.d.ts +1 -0
- package/dist/services/test.js +23 -0
- package/dist/test/e2e/cli/entrypoint.cli.private.test.js +194 -12
- package/dist/test/e2e/cli/repo-with-backportrc-removed.private.test.js +17 -16
- package/dist/test/e2e/cli/runBackportViaCli.d.ts +2 -1
- package/dist/test/e2e/cli/runBackportViaCli.js +10 -2
- package/dist/test/e2e/module/entrypoint.module.mutation.test.js +26 -19
- package/dist/test/handleUnbackportedPullRequests.private.test.js +10 -8
- package/dist/test/sandbox.js +5 -1
- package/dist/test/setupFiles/automatic-mocks.js +5 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +1 -1
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +7 -159
- package/dist/ui/getCommitsWithoutBackports.test.js +5 -1
- package/dist/ui/getGitConfigAuthor.js +1 -1
- package/dist/ui/getTargetBranches.test.js +5 -1
- package/dist/ui/ora.d.ts +1 -8
- package/dist/ui/setupRepo.js +1 -1
- package/dist/ui/setupRepo.test.js +98 -61
- package/dist/utils/isErrnoError.d.ts +2 -0
- package/dist/utils/isErrnoError.js +7 -0
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +13 -13
- package/yarn.lock +414 -695
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -29,12 +33,12 @@ const gitModule = __importStar(require("../services/git"));
|
|
|
29
33
|
const mocks_1 = require("../test/mocks");
|
|
30
34
|
const setupRepo_1 = require("./setupRepo");
|
|
31
35
|
describe('setupRepo', () => {
|
|
32
|
-
let
|
|
36
|
+
let spawnSpy;
|
|
33
37
|
beforeEach(() => {
|
|
34
38
|
jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
|
|
35
|
-
|
|
36
|
-
.spyOn(childProcess, '
|
|
37
|
-
.mockResolvedValue({ stderr: '', stdout: '' });
|
|
39
|
+
spawnSpy = jest
|
|
40
|
+
.spyOn(childProcess, 'spawnPromise')
|
|
41
|
+
.mockResolvedValue({ stderr: '', stdout: '', code: 0, cmdArgs: [] });
|
|
38
42
|
});
|
|
39
43
|
afterEach(() => {
|
|
40
44
|
jest.restoreAllMocks();
|
|
@@ -42,10 +46,10 @@ describe('setupRepo', () => {
|
|
|
42
46
|
describe('if an error occurs while cloning', () => {
|
|
43
47
|
it('should delete repo', async () => {
|
|
44
48
|
expect.assertions(2);
|
|
45
|
-
|
|
46
|
-
.spyOn(childProcess, '
|
|
47
|
-
.mockImplementation((cmd) => {
|
|
48
|
-
if (
|
|
49
|
+
jest
|
|
50
|
+
.spyOn(childProcess, 'spawnOriginal')
|
|
51
|
+
.mockImplementation((cmd, cmdArgs) => {
|
|
52
|
+
if (cmdArgs.includes('clone')) {
|
|
49
53
|
throw new Error('Simulated git clone failure');
|
|
50
54
|
}
|
|
51
55
|
throw new Error('unknown error');
|
|
@@ -60,39 +64,43 @@ describe('setupRepo', () => {
|
|
|
60
64
|
});
|
|
61
65
|
describe('while cloning the repo', () => {
|
|
62
66
|
it('updates the progress', async () => {
|
|
63
|
-
let
|
|
64
|
-
let
|
|
67
|
+
let onClose;
|
|
68
|
+
let onData;
|
|
65
69
|
const oraMock = (0, mocks_1.getOraMock)();
|
|
66
70
|
const spinnerTextSpy = jest.spyOn(oraMock, 'text', 'set');
|
|
67
71
|
const spinnerSuccessSpy = jest.spyOn(oraMock, 'succeed');
|
|
68
|
-
jest.spyOn(gitModule, 'getLocalRepoPath').mockResolvedValue(undefined);
|
|
69
72
|
jest
|
|
70
|
-
.spyOn(
|
|
73
|
+
.spyOn(gitModule, 'getLocalSourceRepoPath')
|
|
74
|
+
.mockResolvedValue(undefined);
|
|
75
|
+
jest
|
|
76
|
+
.spyOn(childProcess, 'spawnOriginal')
|
|
71
77
|
//@ts-expect-error
|
|
72
|
-
.mockImplementation((
|
|
73
|
-
// callback should be called to finalize the operation
|
|
74
|
-
if (onComplete) {
|
|
75
|
-
//@ts-expect-error
|
|
76
|
-
onCloneComplete = onComplete;
|
|
77
|
-
}
|
|
78
|
+
.mockImplementation(() => {
|
|
78
79
|
return {
|
|
80
|
+
on: (name, cb) => {
|
|
81
|
+
if (name === 'close') {
|
|
82
|
+
onClose = cb;
|
|
83
|
+
}
|
|
84
|
+
},
|
|
79
85
|
stderr: {
|
|
80
86
|
on: (name, handler) => {
|
|
81
|
-
|
|
87
|
+
if (name === 'data') {
|
|
88
|
+
onData = handler;
|
|
89
|
+
}
|
|
82
90
|
},
|
|
83
91
|
},
|
|
84
92
|
};
|
|
85
93
|
});
|
|
86
94
|
setTimeout(() => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
onData('Receiving objects: 1%');
|
|
96
|
+
onData('Receiving objects: 10%');
|
|
97
|
+
onData('Receiving objects: 20%');
|
|
98
|
+
onData('Receiving objects: 100%');
|
|
99
|
+
onData('Updating files: 1%');
|
|
100
|
+
onData('Updating files: 10%');
|
|
101
|
+
onData('Updating files: 20%');
|
|
102
|
+
onData('Updating files: 100%');
|
|
103
|
+
onClose(0);
|
|
96
104
|
}, 50);
|
|
97
105
|
await (0, setupRepo_1.setupRepo)({
|
|
98
106
|
repoName: 'kibana',
|
|
@@ -117,18 +125,23 @@ describe('setupRepo', () => {
|
|
|
117
125
|
expect(spinnerSuccessSpy).toHaveBeenCalledWith('100% Cloning repository from github.com (one-time operation)');
|
|
118
126
|
});
|
|
119
127
|
});
|
|
120
|
-
describe('if repo already
|
|
121
|
-
|
|
122
|
-
jest
|
|
123
|
-
.spyOn(childProcess, '
|
|
124
|
-
//@ts-expect-error
|
|
125
|
-
.mockImplementation((cmdString, cmdOptions, callback) => {
|
|
128
|
+
describe('if repo is already cloned', () => {
|
|
129
|
+
function mockGitProjectRootPath(value) {
|
|
130
|
+
return (jest
|
|
131
|
+
.spyOn(childProcess, 'spawnPromise')
|
|
126
132
|
//@ts-expect-error
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
.mockImplementationOnce(async (cmd, cmdArgs) => {
|
|
134
|
+
if (cmdArgs.includes('rev-parse')) {
|
|
135
|
+
return {
|
|
136
|
+
stdout: value,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
beforeEach(async () => {
|
|
142
|
+
jest.clearAllMocks();
|
|
143
|
+
mockGitProjectRootPath('/myHomeDir/.backport/repositories/elastic/kibana');
|
|
144
|
+
jest.spyOn(gitModule, 'cloneRepo');
|
|
132
145
|
await (0, setupRepo_1.setupRepo)({
|
|
133
146
|
accessToken: 'myAccessToken',
|
|
134
147
|
authenticatedUsername: 'sqren_authenticated',
|
|
@@ -138,12 +151,22 @@ describe('setupRepo', () => {
|
|
|
138
151
|
repoName: 'kibana',
|
|
139
152
|
repoOwner: 'elastic',
|
|
140
153
|
});
|
|
141
|
-
|
|
154
|
+
});
|
|
155
|
+
it('should not delete the existing repo', () => {
|
|
156
|
+
expect(del_1.default).not.toHaveBeenCalled();
|
|
157
|
+
});
|
|
158
|
+
it('should not clone repo', () => {
|
|
159
|
+
expect(gitModule.cloneRepo).not.toHaveBeenCalled();
|
|
160
|
+
});
|
|
161
|
+
it('should re-create remotes for both source repo and fork', () => {
|
|
162
|
+
expect(spawnSpy.mock.calls.map(([cmd, cmdArgs, cwd]) => ({
|
|
163
|
+
cmd: `${cmd} ${cmdArgs.join(' ')}`,
|
|
164
|
+
cwd,
|
|
165
|
+
}))).toEqual([
|
|
142
166
|
{
|
|
143
167
|
cmd: 'git rev-parse --show-toplevel',
|
|
144
168
|
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
145
169
|
},
|
|
146
|
-
{ cmd: 'git remote --verbose', cwd: '/path/to/source/repo' },
|
|
147
170
|
{
|
|
148
171
|
cmd: 'git remote rm origin',
|
|
149
172
|
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
@@ -167,19 +190,30 @@ describe('setupRepo', () => {
|
|
|
167
190
|
]);
|
|
168
191
|
});
|
|
169
192
|
});
|
|
193
|
+
function mockGitClone() {
|
|
194
|
+
jest
|
|
195
|
+
.spyOn(childProcess, 'spawnOriginal')
|
|
196
|
+
//@ts-expect-error
|
|
197
|
+
.mockImplementation((cmd, cmdArgs) => {
|
|
198
|
+
if (cmdArgs.includes('clone')) {
|
|
199
|
+
return {
|
|
200
|
+
on: (name, cb) => {
|
|
201
|
+
if (name === 'close') {
|
|
202
|
+
//@ts-expect-error
|
|
203
|
+
cb(0);
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
stderr: { on: () => null },
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
170
211
|
describe('if repo does not exists locally', () => {
|
|
171
212
|
let spinnerSuccessSpy;
|
|
172
213
|
beforeEach(async () => {
|
|
173
214
|
const oraMock = (0, mocks_1.getOraMock)();
|
|
174
215
|
spinnerSuccessSpy = jest.spyOn(oraMock, 'succeed');
|
|
175
|
-
|
|
176
|
-
.spyOn(childProcess, 'execAsCallback')
|
|
177
|
-
//@ts-expect-error
|
|
178
|
-
.mockImplementation((cmdString, cmdOptions, callback) => {
|
|
179
|
-
//@ts-expect-error
|
|
180
|
-
callback();
|
|
181
|
-
return { stderr: { on: () => null } };
|
|
182
|
-
});
|
|
216
|
+
mockGitClone();
|
|
183
217
|
await (0, setupRepo_1.setupRepo)({
|
|
184
218
|
accessToken: 'myAccessToken',
|
|
185
219
|
gitHostname: 'github.com',
|
|
@@ -190,7 +224,12 @@ describe('setupRepo', () => {
|
|
|
190
224
|
});
|
|
191
225
|
it('should clone it from github.com', async () => {
|
|
192
226
|
expect(spinnerSuccessSpy).toHaveBeenCalledWith('100% Cloning repository from github.com (one-time operation)');
|
|
193
|
-
expect(childProcess.
|
|
227
|
+
expect(childProcess.spawnOriginal).toHaveBeenCalledWith('git', [
|
|
228
|
+
'clone',
|
|
229
|
+
'https://x-access-token:myAccessToken@github.com/elastic/kibana.git',
|
|
230
|
+
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
231
|
+
'--progress',
|
|
232
|
+
]);
|
|
194
233
|
});
|
|
195
234
|
});
|
|
196
235
|
describe('if repo exists locally', () => {
|
|
@@ -199,19 +238,12 @@ describe('setupRepo', () => {
|
|
|
199
238
|
const oraMock = (0, mocks_1.getOraMock)();
|
|
200
239
|
spinnerSuccessSpy = jest.spyOn(oraMock, 'succeed');
|
|
201
240
|
jest
|
|
202
|
-
.spyOn(gitModule, '
|
|
241
|
+
.spyOn(gitModule, 'getLocalSourceRepoPath')
|
|
203
242
|
.mockResolvedValue('/path/to/source/repo');
|
|
204
243
|
jest
|
|
205
244
|
.spyOn(gitModule, 'getGitConfig')
|
|
206
245
|
.mockResolvedValue('email-or-username');
|
|
207
|
-
|
|
208
|
-
.spyOn(childProcess, 'execAsCallback')
|
|
209
|
-
//@ts-expect-error
|
|
210
|
-
.mockImplementation((cmdString, cmdOptions, callback) => {
|
|
211
|
-
//@ts-expect-error
|
|
212
|
-
callback();
|
|
213
|
-
return { stderr: { on: () => null } };
|
|
214
|
-
});
|
|
246
|
+
mockGitClone();
|
|
215
247
|
await (0, setupRepo_1.setupRepo)({
|
|
216
248
|
repoName: 'kibana',
|
|
217
249
|
repoOwner: 'elastic',
|
|
@@ -220,7 +252,12 @@ describe('setupRepo', () => {
|
|
|
220
252
|
});
|
|
221
253
|
it('should clone it from local folder', async () => {
|
|
222
254
|
expect(spinnerSuccessSpy).toHaveBeenCalledWith('100% Cloning repository from /path/to/source/repo (one-time operation)');
|
|
223
|
-
expect(childProcess.
|
|
255
|
+
expect(childProcess.spawnOriginal).toHaveBeenCalledWith('git', [
|
|
256
|
+
'clone',
|
|
257
|
+
'/path/to/source/repo',
|
|
258
|
+
'/myHomeDir/.backport/repositories/elastic/kibana',
|
|
259
|
+
'--progress',
|
|
260
|
+
]);
|
|
224
261
|
});
|
|
225
262
|
});
|
|
226
263
|
describe('if `repoPath` is a parent of current working directory (cwd)', () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "
|
|
1
|
+
export declare const PACKAGE_VERSION = "8.0.0";
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"branches",
|
|
15
15
|
"branching"
|
|
16
16
|
],
|
|
17
|
-
"version": "
|
|
17
|
+
"version": "8.0.0",
|
|
18
18
|
"main": "./dist/entrypoint.module.js",
|
|
19
19
|
"types": "dist/entrypoint.module.d.ts",
|
|
20
20
|
"bin": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@octokit/rest": "^18.12.0",
|
|
68
|
-
"axios": "^0.
|
|
68
|
+
"axios": "^0.26.0",
|
|
69
69
|
"dedent": "^0.7.0",
|
|
70
70
|
"del": "^6.0.0",
|
|
71
71
|
"dotenv": "^16.0.0",
|
|
@@ -82,22 +82,22 @@
|
|
|
82
82
|
"utility-types": "^3.10.0",
|
|
83
83
|
"winston": "^3.6.0",
|
|
84
84
|
"yargs": "^17.3.1",
|
|
85
|
-
"yargs-parser": "^21.0.
|
|
85
|
+
"yargs-parser": "^21.0.1"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@types/core-js": "^2.5.5",
|
|
89
89
|
"@types/dedent": "^0.7.0",
|
|
90
90
|
"@types/inquirer": "^8.2.0",
|
|
91
91
|
"@types/jest": "^27.4.1",
|
|
92
|
-
"@types/lodash": "^4.14.
|
|
92
|
+
"@types/lodash": "^4.14.179",
|
|
93
93
|
"@types/node": "^17.0.21",
|
|
94
94
|
"@types/safe-json-stringify": "^1.1.2",
|
|
95
|
-
"@types/yargs": "^17.0.
|
|
96
|
-
"@types/yargs-parser": "^
|
|
97
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
98
|
-
"@typescript-eslint/parser": "^5.
|
|
99
|
-
"eslint": "^8.
|
|
100
|
-
"eslint-config-prettier": "^8.
|
|
95
|
+
"@types/yargs": "^17.0.9",
|
|
96
|
+
"@types/yargs-parser": "^21.0.0",
|
|
97
|
+
"@typescript-eslint/eslint-plugin": "^5.14.0",
|
|
98
|
+
"@typescript-eslint/parser": "^5.14.0",
|
|
99
|
+
"eslint": "^8.10.0",
|
|
100
|
+
"eslint-config-prettier": "^8.5.0",
|
|
101
101
|
"eslint-plugin-import": "^2.25.4",
|
|
102
102
|
"eslint-plugin-jest": "^26.1.1",
|
|
103
103
|
"eslint-plugin-prettier": "^4.0.0",
|
|
@@ -105,12 +105,12 @@
|
|
|
105
105
|
"husky": "^7.0.4",
|
|
106
106
|
"jest": "^27.5.1",
|
|
107
107
|
"jest-snapshot-serializer-ansi": "^1.0.0",
|
|
108
|
-
"lint-staged": "^12.3.
|
|
108
|
+
"lint-staged": "^12.3.5",
|
|
109
109
|
"nock": "^13.2.4",
|
|
110
110
|
"prettier": "^2.5.1",
|
|
111
111
|
"strip-ansi": "^6.0.1",
|
|
112
112
|
"ts-jest": "^27.1.3",
|
|
113
|
-
"ts-node": "^10.
|
|
114
|
-
"typescript": "^4.
|
|
113
|
+
"ts-node": "^10.7.0",
|
|
114
|
+
"typescript": "^4.6.2"
|
|
115
115
|
}
|
|
116
116
|
}
|