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,238 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const os_1 = __importDefault(require("os"));
|
|
26
|
+
const del_1 = __importDefault(require("del"));
|
|
27
|
+
const childProcess = __importStar(require("../services/child-process-promisified"));
|
|
28
|
+
const git = __importStar(require("../services/git"));
|
|
29
|
+
const mocks_1 = require("../test/mocks");
|
|
30
|
+
const maybeSetupRepo_1 = require("./maybeSetupRepo");
|
|
31
|
+
describe('maybeSetupRepo', () => {
|
|
32
|
+
let execSpy;
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
|
|
35
|
+
execSpy = jest
|
|
36
|
+
.spyOn(childProcess, 'exec')
|
|
37
|
+
.mockResolvedValue({ stderr: '', stdout: '' });
|
|
38
|
+
});
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
jest.restoreAllMocks();
|
|
41
|
+
});
|
|
42
|
+
describe('if an error occurs while cloning', () => {
|
|
43
|
+
it('should delete repo', async () => {
|
|
44
|
+
expect.assertions(2);
|
|
45
|
+
execSpy = jest
|
|
46
|
+
.spyOn(childProcess, 'execAsCallback')
|
|
47
|
+
.mockImplementation((cmd) => {
|
|
48
|
+
if (cmd.startsWith('git clone')) {
|
|
49
|
+
throw new Error('Simulated git clone failure');
|
|
50
|
+
}
|
|
51
|
+
throw new Error('unknown error');
|
|
52
|
+
});
|
|
53
|
+
await expect((0, maybeSetupRepo_1.maybeSetupRepo)({
|
|
54
|
+
repoName: 'kibana',
|
|
55
|
+
repoOwner: 'elastic',
|
|
56
|
+
cwd: '/path/to/source/repo',
|
|
57
|
+
})).rejects.toThrowError('Simulated git clone failure');
|
|
58
|
+
expect(del_1.default).toHaveBeenCalledWith('/myHomeDir/.backport/repositories/elastic/kibana', { force: true });
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
describe('while cloning the repo', () => {
|
|
62
|
+
it('updates the progress', async () => {
|
|
63
|
+
let onCloneComplete;
|
|
64
|
+
let dataHandler;
|
|
65
|
+
const oraMock = (0, mocks_1.getOraMock)();
|
|
66
|
+
const spinnerTextSpy = jest.spyOn(oraMock, 'text', 'set');
|
|
67
|
+
const spinnerSuccessSpy = jest.spyOn(oraMock, 'succeed');
|
|
68
|
+
jest
|
|
69
|
+
.spyOn(git, 'getSourceRepoPath')
|
|
70
|
+
.mockResolvedValue('/path/to/source/repo');
|
|
71
|
+
jest
|
|
72
|
+
.spyOn(childProcess, 'execAsCallback')
|
|
73
|
+
//@ts-expect-error
|
|
74
|
+
.mockImplementation((cmdString, cmdOptions, onComplete) => {
|
|
75
|
+
// callback should be called to finalize the operation
|
|
76
|
+
if (onComplete) {
|
|
77
|
+
//@ts-expect-error
|
|
78
|
+
onCloneComplete = onComplete;
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
stderr: {
|
|
82
|
+
on: (name, handler) => {
|
|
83
|
+
dataHandler = handler;
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
dataHandler('Receiving objects: 1%');
|
|
90
|
+
dataHandler('Receiving objects: 10%');
|
|
91
|
+
dataHandler('Receiving objects: 20%');
|
|
92
|
+
dataHandler('Receiving objects: 100%');
|
|
93
|
+
dataHandler('Updating files: 1%');
|
|
94
|
+
dataHandler('Updating files: 10%');
|
|
95
|
+
dataHandler('Updating files: 20%');
|
|
96
|
+
dataHandler('Updating files: 100%');
|
|
97
|
+
onCloneComplete();
|
|
98
|
+
}, 50);
|
|
99
|
+
await (0, maybeSetupRepo_1.maybeSetupRepo)({
|
|
100
|
+
repoName: 'kibana',
|
|
101
|
+
repoOwner: 'elastic',
|
|
102
|
+
cwd: '/path/to/source/repo',
|
|
103
|
+
});
|
|
104
|
+
expect(spinnerTextSpy.mock.calls.map((call) => call[0]))
|
|
105
|
+
.toMatchInlineSnapshot(`
|
|
106
|
+
Array [
|
|
107
|
+
"0% Cloning repository from /path/to/source/repo (one-time operation)",
|
|
108
|
+
"1% Cloning repository from /path/to/source/repo (one-time operation)",
|
|
109
|
+
"9% Cloning repository from /path/to/source/repo (one-time operation)",
|
|
110
|
+
"18% Cloning repository from /path/to/source/repo (one-time operation)",
|
|
111
|
+
"90% Cloning repository from /path/to/source/repo (one-time operation)",
|
|
112
|
+
"90% Cloning repository from /path/to/source/repo (one-time operation)",
|
|
113
|
+
"91% Cloning repository from /path/to/source/repo (one-time operation)",
|
|
114
|
+
"92% Cloning repository from /path/to/source/repo (one-time operation)",
|
|
115
|
+
"100% Cloning repository from /path/to/source/repo (one-time operation)",
|
|
116
|
+
]
|
|
117
|
+
`);
|
|
118
|
+
expect(spinnerSuccessSpy).toHaveBeenCalledWith('100% Cloning repository from /path/to/source/repo (one-time operation)');
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
describe('if repo already exists', () => {
|
|
122
|
+
beforeEach(() => {
|
|
123
|
+
jest
|
|
124
|
+
.spyOn(childProcess, 'execAsCallback')
|
|
125
|
+
//@ts-expect-error
|
|
126
|
+
.mockImplementation((cmdString, cmdOptions, callback) => {
|
|
127
|
+
//@ts-expect-error
|
|
128
|
+
callback();
|
|
129
|
+
return {
|
|
130
|
+
stderr: { on: () => null },
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
it('should re-create remotes for both source repo and fork', async () => {
|
|
135
|
+
await (0, maybeSetupRepo_1.maybeSetupRepo)({
|
|
136
|
+
accessToken: 'myAccessToken',
|
|
137
|
+
authenticatedUsername: 'sqren_authenticated',
|
|
138
|
+
repoName: 'kibana',
|
|
139
|
+
repoOwner: 'elastic',
|
|
140
|
+
cwd: '/path/to/source/repo',
|
|
141
|
+
});
|
|
142
|
+
expect(execSpy.mock.calls.map(([cmd, { cwd }]) => ({ cmd, cwd }))).toEqual([
|
|
143
|
+
{
|
|
144
|
+
cmd: 'git rev-parse --show-toplevel',
|
|
145
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
cmd: 'git remote --verbose',
|
|
149
|
+
cwd: '/path/to/source/repo',
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
cmd: 'git remote rm origin',
|
|
153
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
cmd: 'git remote rm sqren_authenticated',
|
|
157
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
cmd: 'git remote add sqren_authenticated https://x-access-token:myAccessToken@github.com/sqren_authenticated/kibana.git',
|
|
161
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
cmd: 'git remote rm elastic',
|
|
165
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
cmd: 'git remote add elastic https://x-access-token:myAccessToken@github.com/elastic/kibana.git',
|
|
169
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
170
|
+
},
|
|
171
|
+
]);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
describe('if repo does not exists locally', () => {
|
|
175
|
+
beforeEach(() => {
|
|
176
|
+
jest
|
|
177
|
+
.spyOn(childProcess, 'execAsCallback')
|
|
178
|
+
//@ts-expect-error
|
|
179
|
+
.mockImplementation((cmdString, cmdOptions, callback) => {
|
|
180
|
+
//@ts-expect-error
|
|
181
|
+
callback();
|
|
182
|
+
return {
|
|
183
|
+
stderr: { on: () => null },
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
it('should clone it from github.com', async () => {
|
|
188
|
+
await (0, maybeSetupRepo_1.maybeSetupRepo)({
|
|
189
|
+
accessToken: 'myAccessToken',
|
|
190
|
+
gitHostname: 'github.com',
|
|
191
|
+
repoName: 'kibana',
|
|
192
|
+
repoOwner: 'elastic',
|
|
193
|
+
cwd: '/path/to/source/repo',
|
|
194
|
+
});
|
|
195
|
+
expect(childProcess.execAsCallback).toHaveBeenCalledWith('git clone https://x-access-token:myAccessToken@github.com/elastic/kibana.git /myHomeDir/.backport/repositories/elastic/kibana --progress', expect.any(Object), expect.any(Function));
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
describe('if repo does exist locally', () => {
|
|
199
|
+
beforeEach(() => {
|
|
200
|
+
jest
|
|
201
|
+
.spyOn(git, 'getSourceRepoPath')
|
|
202
|
+
.mockResolvedValue('/path/to/source/repo');
|
|
203
|
+
jest
|
|
204
|
+
.spyOn(childProcess, 'execAsCallback')
|
|
205
|
+
//@ts-expect-error
|
|
206
|
+
.mockImplementation((cmdString, cmdOptions, callback) => {
|
|
207
|
+
//@ts-expect-error
|
|
208
|
+
callback();
|
|
209
|
+
return {
|
|
210
|
+
stderr: { on: () => null },
|
|
211
|
+
};
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
it('should clone it from local folder', async () => {
|
|
215
|
+
await (0, maybeSetupRepo_1.maybeSetupRepo)({
|
|
216
|
+
repoName: 'kibana',
|
|
217
|
+
repoOwner: 'elastic',
|
|
218
|
+
cwd: '/path/to/source/repo',
|
|
219
|
+
});
|
|
220
|
+
expect(childProcess.execAsCallback).toHaveBeenCalledWith('git clone /path/to/source/repo /myHomeDir/.backport/repositories/elastic/kibana --progress', expect.any(Object), expect.any(Function));
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
describe('if `repoPath` is a parent of current working directory (cwd)', () => {
|
|
224
|
+
beforeEach(() => {
|
|
225
|
+
jest
|
|
226
|
+
.spyOn(git, 'getSourceRepoPath')
|
|
227
|
+
.mockResolvedValue('/path/to/source/repo');
|
|
228
|
+
jest.spyOn(childProcess, 'execAsCallback');
|
|
229
|
+
});
|
|
230
|
+
it('should clone it from local folder', async () => {
|
|
231
|
+
await expect(() => (0, maybeSetupRepo_1.maybeSetupRepo)({
|
|
232
|
+
repoName: 'kibana',
|
|
233
|
+
repoOwner: 'elastic',
|
|
234
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana/foo',
|
|
235
|
+
})).rejects.toThrowError('Refusing to clone repo into "/myHomeDir/.backport/repositories/elastic/kibana" when current working directory is "/myHomeDir/.backport/repositories/elastic/kibana/foo". Please change backport directory via `--dir` option or run backport from another location');
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
});
|
package/dist/ui/ora.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import oraOriginal from 'ora';
|
|
2
|
-
export declare function ora(ci: boolean | undefined,
|
|
2
|
+
export declare function ora(ci: boolean | undefined, text?: string | undefined): oraOriginal.Ora | {
|
|
3
3
|
start: (text?: string | undefined) => any;
|
|
4
4
|
succeed: () => void;
|
|
5
5
|
stop: () => void;
|
package/dist/ui/ora.js
CHANGED
|
@@ -15,7 +15,7 @@ const oraMock = {
|
|
|
15
15
|
stopAndPersist: () => { },
|
|
16
16
|
set text(value) { },
|
|
17
17
|
};
|
|
18
|
-
function ora(ci,
|
|
19
|
-
return ci ? oraMock : (0, ora_1.default)(
|
|
18
|
+
function ora(ci, text) {
|
|
19
|
+
return ci ? oraMock : (0, ora_1.default)({ text });
|
|
20
20
|
}
|
|
21
21
|
exports.ora = ora;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setupRepo = void 0;
|
|
4
|
+
const del = require("del");
|
|
5
|
+
const HandledError_1 = require("../services/HandledError");
|
|
6
|
+
const env_1 = require("../services/env");
|
|
7
|
+
const git_1 = require("../services/git");
|
|
8
|
+
const ora_1 = require("./ora");
|
|
9
|
+
async function setupRepo(options, commits) {
|
|
10
|
+
const repoPath = (0, env_1.getRepoPath)(options);
|
|
11
|
+
const isAlreadyCloned = await getIsRepoCloned(options);
|
|
12
|
+
if (options.cwd.includes(repoPath)) {
|
|
13
|
+
throw new HandledError_1.HandledError(`Refusing to clone repo into "${repoPath}" when current working directory is "${options.cwd}". Please change backport directory via \`--dir\` option or run backport from another location`);
|
|
14
|
+
}
|
|
15
|
+
// clone repo if folder does not already exists
|
|
16
|
+
if (!isAlreadyCloned) {
|
|
17
|
+
const spinner = (0, ora_1.ora)(options.ci).start();
|
|
18
|
+
try {
|
|
19
|
+
const localRepoPath = await (0, git_1.getLocalRepoPath)(options);
|
|
20
|
+
const remoteRepoPath = (0, git_1.getRemoteUrl)(options, options.repoOwner);
|
|
21
|
+
const sourcePath = localRepoPath ? localRepoPath : remoteRepoPath;
|
|
22
|
+
// show the full path for local repos, but only the host name for remote repos (to avoid showing the access token)
|
|
23
|
+
const sourcePathHumanReadable = !localRepoPath
|
|
24
|
+
? options.gitHostname
|
|
25
|
+
: sourcePath;
|
|
26
|
+
const spinnerCloneText = `Cloning repository from ${sourcePathHumanReadable} (one-time operation)`;
|
|
27
|
+
spinner.text = `0% ${spinnerCloneText}`;
|
|
28
|
+
await del(repoPath, { force: true });
|
|
29
|
+
await (0, git_1.cloneRepo)({ sourcePath, targetPath: repoPath }, (progress) => {
|
|
30
|
+
spinner.text = `${progress}% ${spinnerCloneText}`;
|
|
31
|
+
});
|
|
32
|
+
spinner.succeed(`100% ${spinnerCloneText}`);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
spinner.fail();
|
|
36
|
+
await del(repoPath, { force: true });
|
|
37
|
+
throw e;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
await setupGitUsernameAndEmail(options, commits);
|
|
41
|
+
// delete default "origin" remote to avoid confusion
|
|
42
|
+
await (0, git_1.deleteRemote)(options, 'origin');
|
|
43
|
+
// ensure remote are setup with latest accessToken
|
|
44
|
+
await (0, git_1.deleteRemote)(options, options.authenticatedUsername);
|
|
45
|
+
await (0, git_1.addRemote)(options, options.authenticatedUsername);
|
|
46
|
+
// add remote for non-fork repo (if the above is a fork)
|
|
47
|
+
if (options.authenticatedUsername !== options.repoOwner) {
|
|
48
|
+
await (0, git_1.deleteRemote)(options, options.repoOwner);
|
|
49
|
+
await (0, git_1.addRemote)(options, options.repoOwner);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.setupRepo = setupRepo;
|
|
53
|
+
async function getIsRepoCloned(options) {
|
|
54
|
+
const repoPath = (0, env_1.getRepoPath)(options);
|
|
55
|
+
const projectRoot = await (0, git_1.getGitProjectRootPath)(repoPath);
|
|
56
|
+
return repoPath === projectRoot;
|
|
57
|
+
}
|
|
58
|
+
async function setupGitUsernameAndEmail(options, commits) {
|
|
59
|
+
const repoPath = (0, env_1.getRepoPath)(options);
|
|
60
|
+
const userName = await (0, git_1.getGitConfig)({ dir: repoPath, key: 'user.name' });
|
|
61
|
+
const userEmail = await (0, git_1.getGitConfig)({ dir: repoPath, key: 'user.email' });
|
|
62
|
+
// return early if user.email and user.name is already set
|
|
63
|
+
if (userName && userEmail) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const commitAuthor = commits[0].author;
|
|
67
|
+
const localRepoPath = await (0, git_1.getLocalRepoPath)(options);
|
|
68
|
+
if (!userName) {
|
|
69
|
+
const gitConfigUsername = localRepoPath
|
|
70
|
+
? await (0, git_1.getGitConfig)({ dir: localRepoPath, key: 'user.name' })
|
|
71
|
+
: undefined;
|
|
72
|
+
await (0, git_1.setGitConfig)({
|
|
73
|
+
dir: repoPath,
|
|
74
|
+
key: 'user.name',
|
|
75
|
+
value: gitConfigUsername ?? options.gitUserName ?? commitAuthor.name,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (!userEmail) {
|
|
79
|
+
const gitConfigEmail = localRepoPath
|
|
80
|
+
? await (0, git_1.getGitConfig)({ dir: localRepoPath, key: 'user.email' })
|
|
81
|
+
: undefined;
|
|
82
|
+
await (0, git_1.setGitConfig)({
|
|
83
|
+
dir: repoPath,
|
|
84
|
+
key: 'user.email',
|
|
85
|
+
value: gitConfigEmail ?? options.gitUserEmail ?? commitAuthor.email,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,288 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const os_1 = __importDefault(require("os"));
|
|
26
|
+
const del_1 = __importDefault(require("del"));
|
|
27
|
+
const childProcess = __importStar(require("../services/child-process-promisified"));
|
|
28
|
+
const gitModule = __importStar(require("../services/git"));
|
|
29
|
+
const mocks_1 = require("../test/mocks");
|
|
30
|
+
const setupRepo_1 = require("./setupRepo");
|
|
31
|
+
describe('setupRepo', () => {
|
|
32
|
+
let execSpy;
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
jest.spyOn(os_1.default, 'homedir').mockReturnValue('/myHomeDir');
|
|
35
|
+
execSpy = jest
|
|
36
|
+
.spyOn(childProcess, 'exec')
|
|
37
|
+
.mockResolvedValue({ stderr: '', stdout: '' });
|
|
38
|
+
});
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
jest.restoreAllMocks();
|
|
41
|
+
});
|
|
42
|
+
describe('if an error occurs while cloning', () => {
|
|
43
|
+
it('should delete repo', async () => {
|
|
44
|
+
expect.assertions(2);
|
|
45
|
+
execSpy = jest
|
|
46
|
+
.spyOn(childProcess, 'execAsCallback')
|
|
47
|
+
.mockImplementation((cmd) => {
|
|
48
|
+
if (cmd.startsWith('git clone')) {
|
|
49
|
+
throw new Error('Simulated git clone failure');
|
|
50
|
+
}
|
|
51
|
+
throw new Error('unknown error');
|
|
52
|
+
});
|
|
53
|
+
await expect((0, setupRepo_1.setupRepo)({
|
|
54
|
+
repoName: 'kibana',
|
|
55
|
+
repoOwner: 'elastic',
|
|
56
|
+
cwd: '/path/to/source/repo',
|
|
57
|
+
}, [getMockCommit()])).rejects.toThrowError('Simulated git clone failure');
|
|
58
|
+
expect(del_1.default).toHaveBeenCalledWith('/myHomeDir/.backport/repositories/elastic/kibana', { force: true });
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
describe('while cloning the repo', () => {
|
|
62
|
+
it('updates the progress', async () => {
|
|
63
|
+
let onCloneComplete;
|
|
64
|
+
let dataHandler;
|
|
65
|
+
const oraMock = (0, mocks_1.getOraMock)();
|
|
66
|
+
const spinnerTextSpy = jest.spyOn(oraMock, 'text', 'set');
|
|
67
|
+
const spinnerSuccessSpy = jest.spyOn(oraMock, 'succeed');
|
|
68
|
+
jest.spyOn(gitModule, 'getLocalRepoPath').mockResolvedValue(undefined);
|
|
69
|
+
jest
|
|
70
|
+
.spyOn(childProcess, 'execAsCallback')
|
|
71
|
+
//@ts-expect-error
|
|
72
|
+
.mockImplementation((cmdString, cmdOptions, onComplete) => {
|
|
73
|
+
// callback should be called to finalize the operation
|
|
74
|
+
if (onComplete) {
|
|
75
|
+
//@ts-expect-error
|
|
76
|
+
onCloneComplete = onComplete;
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
stderr: {
|
|
80
|
+
on: (name, handler) => {
|
|
81
|
+
dataHandler = handler;
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
dataHandler('Receiving objects: 1%');
|
|
88
|
+
dataHandler('Receiving objects: 10%');
|
|
89
|
+
dataHandler('Receiving objects: 20%');
|
|
90
|
+
dataHandler('Receiving objects: 100%');
|
|
91
|
+
dataHandler('Updating files: 1%');
|
|
92
|
+
dataHandler('Updating files: 10%');
|
|
93
|
+
dataHandler('Updating files: 20%');
|
|
94
|
+
dataHandler('Updating files: 100%');
|
|
95
|
+
onCloneComplete();
|
|
96
|
+
}, 50);
|
|
97
|
+
await (0, setupRepo_1.setupRepo)({
|
|
98
|
+
repoName: 'kibana',
|
|
99
|
+
repoOwner: 'elastic',
|
|
100
|
+
gitUserEmail: 'my-email',
|
|
101
|
+
gitUserName: 'my-username',
|
|
102
|
+
gitHostname: 'github.com',
|
|
103
|
+
cwd: '/path/to/source/repo',
|
|
104
|
+
}, [getMockCommit()]);
|
|
105
|
+
expect(spinnerTextSpy.mock.calls.map((call) => call[0]))
|
|
106
|
+
.toMatchInlineSnapshot(`
|
|
107
|
+
Array [
|
|
108
|
+
"0% Cloning repository from github.com (one-time operation)",
|
|
109
|
+
"1% Cloning repository from github.com (one-time operation)",
|
|
110
|
+
"9% Cloning repository from github.com (one-time operation)",
|
|
111
|
+
"18% Cloning repository from github.com (one-time operation)",
|
|
112
|
+
"90% Cloning repository from github.com (one-time operation)",
|
|
113
|
+
"90% Cloning repository from github.com (one-time operation)",
|
|
114
|
+
"91% Cloning repository from github.com (one-time operation)",
|
|
115
|
+
"92% Cloning repository from github.com (one-time operation)",
|
|
116
|
+
"100% Cloning repository from github.com (one-time operation)",
|
|
117
|
+
]
|
|
118
|
+
`);
|
|
119
|
+
expect(spinnerSuccessSpy).toHaveBeenCalledWith('100% Cloning repository from github.com (one-time operation)');
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
describe('if repo already exists', () => {
|
|
123
|
+
beforeEach(() => {
|
|
124
|
+
jest
|
|
125
|
+
.spyOn(childProcess, 'execAsCallback')
|
|
126
|
+
//@ts-expect-error
|
|
127
|
+
.mockImplementation((cmdString, cmdOptions, callback) => {
|
|
128
|
+
//@ts-expect-error
|
|
129
|
+
callback();
|
|
130
|
+
return { stderr: { on: () => null } };
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
it('should re-create remotes for both source repo and fork', async () => {
|
|
134
|
+
await (0, setupRepo_1.setupRepo)({
|
|
135
|
+
accessToken: 'myAccessToken',
|
|
136
|
+
authenticatedUsername: 'sqren_authenticated',
|
|
137
|
+
repoName: 'kibana',
|
|
138
|
+
repoOwner: 'elastic',
|
|
139
|
+
gitUserEmail: 'my-email',
|
|
140
|
+
gitUserName: 'my-username',
|
|
141
|
+
cwd: '/path/to/source/repo',
|
|
142
|
+
}, [getMockCommit()]);
|
|
143
|
+
expect(execSpy.mock.calls.map(([cmd, { cwd }]) => ({ cmd, cwd }))).toEqual([
|
|
144
|
+
{
|
|
145
|
+
cmd: 'git rev-parse --show-toplevel',
|
|
146
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
147
|
+
},
|
|
148
|
+
{ cmd: 'git remote --verbose', cwd: '/path/to/source/repo' },
|
|
149
|
+
{
|
|
150
|
+
cmd: 'git config user.name',
|
|
151
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
cmd: 'git config user.email',
|
|
155
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
156
|
+
},
|
|
157
|
+
{ cmd: 'git remote --verbose', cwd: '/path/to/source/repo' },
|
|
158
|
+
{
|
|
159
|
+
cmd: 'git config user.name my-username',
|
|
160
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
cmd: 'git config user.email my-email',
|
|
164
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
cmd: 'git remote rm origin',
|
|
168
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
cmd: 'git remote rm sqren_authenticated',
|
|
172
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
cmd: 'git remote add sqren_authenticated https://x-access-token:myAccessToken@github.com/sqren_authenticated/kibana.git',
|
|
176
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
cmd: 'git remote rm elastic',
|
|
180
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
cmd: 'git remote add elastic https://x-access-token:myAccessToken@github.com/elastic/kibana.git',
|
|
184
|
+
cwd: '/myHomeDir/.backport/repositories/elastic/kibana',
|
|
185
|
+
},
|
|
186
|
+
]);
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
describe('if repo does not exists locally', () => {
|
|
190
|
+
let spinnerSuccessSpy;
|
|
191
|
+
beforeEach(async () => {
|
|
192
|
+
const oraMock = (0, mocks_1.getOraMock)();
|
|
193
|
+
spinnerSuccessSpy = jest.spyOn(oraMock, 'succeed');
|
|
194
|
+
jest
|
|
195
|
+
.spyOn(childProcess, 'execAsCallback')
|
|
196
|
+
//@ts-expect-error
|
|
197
|
+
.mockImplementation((cmdString, cmdOptions, callback) => {
|
|
198
|
+
//@ts-expect-error
|
|
199
|
+
callback();
|
|
200
|
+
return { stderr: { on: () => null } };
|
|
201
|
+
});
|
|
202
|
+
await (0, setupRepo_1.setupRepo)({
|
|
203
|
+
accessToken: 'myAccessToken',
|
|
204
|
+
gitUserEmail: 'my-email',
|
|
205
|
+
gitUserName: 'my-username',
|
|
206
|
+
gitHostname: 'github.com',
|
|
207
|
+
repoName: 'kibana',
|
|
208
|
+
repoOwner: 'elastic',
|
|
209
|
+
cwd: '/path/to/source/repo',
|
|
210
|
+
}, [getMockCommit()]);
|
|
211
|
+
});
|
|
212
|
+
it('should clone it from github.com', async () => {
|
|
213
|
+
expect(spinnerSuccessSpy).toHaveBeenCalledWith('100% Cloning repository from github.com (one-time operation)');
|
|
214
|
+
expect(childProcess.execAsCallback).toHaveBeenCalledWith('git clone https://x-access-token:myAccessToken@github.com/elastic/kibana.git /myHomeDir/.backport/repositories/elastic/kibana --progress', expect.any(Object), expect.any(Function));
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
describe('if repo exists locally', () => {
|
|
218
|
+
let spinnerSuccessSpy;
|
|
219
|
+
beforeEach(async () => {
|
|
220
|
+
const oraMock = (0, mocks_1.getOraMock)();
|
|
221
|
+
spinnerSuccessSpy = jest.spyOn(oraMock, 'succeed');
|
|
222
|
+
jest
|
|
223
|
+
.spyOn(gitModule, 'getLocalRepoPath')
|
|
224
|
+
.mockResolvedValue('/path/to/source/repo');
|
|
225
|
+
jest
|
|
226
|
+
.spyOn(gitModule, 'getGitConfig')
|
|
227
|
+
.mockResolvedValue('email-or-username');
|
|
228
|
+
jest
|
|
229
|
+
.spyOn(childProcess, 'execAsCallback')
|
|
230
|
+
//@ts-expect-error
|
|
231
|
+
.mockImplementation((cmdString, cmdOptions, callback) => {
|
|
232
|
+
//@ts-expect-error
|
|
233
|
+
callback();
|
|
234
|
+
return { stderr: { on: () => null } };
|
|
235
|
+
});
|
|
236
|
+
await (0, setupRepo_1.setupRepo)({
|
|
237
|
+
repoName: 'kibana',
|
|
238
|
+
repoOwner: 'elastic',
|
|
239
|
+
cwd: '/path/to/source/repo',
|
|
240
|
+
}, [getMockCommit()]);
|
|
241
|
+
});
|
|
242
|
+
it('should clone it from local folder', async () => {
|
|
243
|
+
expect(spinnerSuccessSpy).toHaveBeenCalledWith('100% Cloning repository from /path/to/source/repo (one-time operation)');
|
|
244
|
+
expect(childProcess.execAsCallback).toHaveBeenCalledWith('git clone /path/to/source/repo /myHomeDir/.backport/repositories/elastic/kibana --progress', expect.any(Object), expect.any(Function));
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
describe('if `repoPath` is a parent of current working directory (cwd)', () => {
|
|
248
|
+
it('should clone it from local folder', async () => {
|
|
249
|
+
await expect(() => (0, setupRepo_1.setupRepo)({
|
|
250
|
+
repoName: 'kibana',
|
|
251
|
+
repoOwner: 'elastic',
|
|
252
|
+
cwd: '/myHomeDir/.backport/repositories/owner/repo/foo',
|
|
253
|
+
dir: '/myHomeDir/.backport/repositories/owner/repo',
|
|
254
|
+
}, [getMockCommit()])).rejects.toThrowError('Refusing to clone repo into "/myHomeDir/.backport/repositories/owner/repo" when current working directory is "/myHomeDir/.backport/repositories/owner/repo/foo". Please change backport directory via `--dir` option or run backport from another location');
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
function getMockCommit() {
|
|
259
|
+
return {
|
|
260
|
+
author: { email: 'sorenlouv@gmail.com', name: 'Søren Louv-Jansen' },
|
|
261
|
+
sourceCommit: {
|
|
262
|
+
committedDate: '2020-08-15T10:44:04Z',
|
|
263
|
+
message: 'Add family emoji (#2)',
|
|
264
|
+
sha: '59d6ff1ca90a4ce210c0a4f0e159214875c19d60',
|
|
265
|
+
},
|
|
266
|
+
sourcePullRequest: {
|
|
267
|
+
number: 2,
|
|
268
|
+
url: 'https://github.com/backport-org/backport-e2e/pull/2',
|
|
269
|
+
mergeCommit: {
|
|
270
|
+
message: 'Add family emoji (#2)',
|
|
271
|
+
sha: '59d6ff1ca90a4ce210c0a4f0e159214875c19d60',
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
sourceBranch: 'master',
|
|
275
|
+
expectedTargetPullRequests: [
|
|
276
|
+
{
|
|
277
|
+
branch: '7.x',
|
|
278
|
+
number: 4,
|
|
279
|
+
state: 'MERGED',
|
|
280
|
+
url: 'https://github.com/backport-org/backport-e2e/pull/4',
|
|
281
|
+
mergeCommit: {
|
|
282
|
+
message: 'Add family emoji (#2) (#4)',
|
|
283
|
+
sha: 'f8b4f6ae7ffaf2732fa5e33e98b3ea772bdfff1d',
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
};
|
|
288
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const excludeUndefined_1 = require("./excludeUndefined");
|
|
4
|
+
describe('excludeUndefined', () => {
|
|
5
|
+
it('removes undefined values', () => {
|
|
6
|
+
expect((0, excludeUndefined_1.excludeUndefined)({
|
|
7
|
+
foo: 'foo',
|
|
8
|
+
bar: undefined,
|
|
9
|
+
baz: null,
|
|
10
|
+
})).toEqual({ foo: 'foo', baz: null });
|
|
11
|
+
});
|
|
12
|
+
it('has the correct types after merging', () => {
|
|
13
|
+
const obj = (0, excludeUndefined_1.excludeUndefined)({
|
|
14
|
+
foo: 'foo',
|
|
15
|
+
bar: undefined,
|
|
16
|
+
baz: null,
|
|
17
|
+
});
|
|
18
|
+
const res = {
|
|
19
|
+
bar: 'bar',
|
|
20
|
+
...obj,
|
|
21
|
+
};
|
|
22
|
+
expect(res).toEqual({ bar: 'bar', foo: 'foo', baz: null });
|
|
23
|
+
});
|
|
24
|
+
});
|