backport 7.2.0 → 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.js +1 -0
- package/dist/options/ConfigOptions.d.ts +2 -0
- package/dist/options/config/config.d.ts +2 -0
- package/dist/options/config/readConfigFile.d.ts +2 -0
- package/dist/options/options.d.ts +2 -0
- package/dist/runSequentially.js +2 -2
- package/dist/services/git.d.ts +11 -2
- package/dist/services/git.integration.test.js +12 -46
- package/dist/services/git.js +31 -15
- package/dist/services/git.test.js +12 -1
- package/dist/services/github/v3/createPullRequest.test.js +52 -0
- package/dist/services/github/v3/createStatusComment.test.js +12 -2
- package/dist/services/github/v4/fetchCommits/allFetchers.private.test.js +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitByPullNumber.private.test.js +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitBySha.private.test.js +1 -0
- package/dist/services/github/v4/fetchCommits/fetchCommitsByAuthor.test.js +5 -0
- package/dist/services/github/v4/fetchCommits/fetchPullRequestBySearchQuery.private.test.js +2 -0
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +2 -0
- package/dist/services/github/v4/getRepoOwnerAndNameFromGitRemotes.js +1 -0
- package/dist/services/github/v4/mocks/commitsByAuthorMock.js +20 -0
- package/dist/services/prompt.test.js +5 -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.js +1 -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/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.js +6 -0
- package/dist/test/handleUnbackportedPullRequests.private.test.js +1 -0
- package/dist/ui/cherrypickAndCreateTargetPullRequest.js +3 -3
- package/dist/ui/cherrypickAndCreateTargetPullRequest.test.js +24 -14
- package/dist/ui/getCommitsWithoutBackports.test.js +20 -0
- package/dist/ui/getTargetBranches.test.js +2 -0
- 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/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +6 -6
- package/yarn.lock +3 -3
|
@@ -39,6 +39,7 @@ describe('getTargetBranches', () => {
|
|
|
39
39
|
};
|
|
40
40
|
const commits = [
|
|
41
41
|
{
|
|
42
|
+
author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
|
|
42
43
|
sourceCommit: {
|
|
43
44
|
committedDate: 'aaa',
|
|
44
45
|
message: 'hey',
|
|
@@ -126,6 +127,7 @@ describe('getTargetBranches', () => {
|
|
|
126
127
|
};
|
|
127
128
|
const commits = [
|
|
128
129
|
{
|
|
130
|
+
author: { email: 'soren.louv@elastic.co', name: 'Søren Louv-Jansen' },
|
|
129
131
|
sourceCommit: {
|
|
130
132
|
committedDate: 'bbb',
|
|
131
133
|
message: '[backport] Bump to 5.1.3 (#62286)',
|
|
@@ -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
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "7.
|
|
1
|
+
export declare const PACKAGE_VERSION = "7.3.0-beta.1";
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"branches",
|
|
15
15
|
"branching"
|
|
16
16
|
],
|
|
17
|
-
"version": "7.
|
|
17
|
+
"version": "7.3.0-beta.1",
|
|
18
18
|
"main": "./dist/entrypoint.module.js",
|
|
19
19
|
"types": "dist/entrypoint.module.d.ts",
|
|
20
20
|
"bin": {
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"scripts": {
|
|
25
25
|
"postinstall": "test -f ./dist/scripts/runPostinstall.js && node ./dist/scripts/runPostinstall.js || echo 'Dist folder missing'",
|
|
26
|
-
"version": "echo \"Bumping version\" && yarn extractPackageVersion && git add src/utils/packageVersion.ts && yarn
|
|
26
|
+
"version": "echo \"Bumping version\" && yarn extractPackageVersion && git add src/utils/packageVersion.ts && yarn tsc",
|
|
27
27
|
"prepare": "husky install",
|
|
28
|
-
"prepublishOnly": "yarn lint",
|
|
29
|
-
"build": "tsc --project ./tsconfig.prod.json",
|
|
28
|
+
"prepublishOnly": "yarn lint && yarn tsc",
|
|
30
29
|
"extractPackageVersion": "node -p \"'export const PACKAGE_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" | prettier > src/utils/packageVersion.ts",
|
|
31
|
-
"lint": "
|
|
30
|
+
"lint-and-test": "yarn tsc && yarn lint && yarn test-all",
|
|
31
|
+
"lint": "echo \"Running lint\" && eslint './**/*.{ts,js}'",
|
|
32
32
|
"start": "ts-node --transpile-only ./src/entrypoint.cli.ts",
|
|
33
|
-
"test-all": "
|
|
33
|
+
"test-all": "jest --config ./jest.config.all.js",
|
|
34
34
|
"test-mutation": "jest --config ./jest.config.mutation.js",
|
|
35
35
|
"test-private": "jest --config ./jest.config.private.js",
|
|
36
36
|
"test": "jest"
|
package/yarn.lock
CHANGED
|
@@ -2534,9 +2534,9 @@ fn.name@1.x.x:
|
|
|
2534
2534
|
integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==
|
|
2535
2535
|
|
|
2536
2536
|
follow-redirects@^1.14.7:
|
|
2537
|
-
version "1.14.
|
|
2538
|
-
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.
|
|
2539
|
-
integrity sha512
|
|
2537
|
+
version "1.14.9"
|
|
2538
|
+
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.9.tgz#dd4ea157de7bfaf9ea9b3fbd85aa16951f78d8d7"
|
|
2539
|
+
integrity sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==
|
|
2540
2540
|
|
|
2541
2541
|
form-data-encoder@^1.7.1:
|
|
2542
2542
|
version "1.7.1"
|