mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
parent
dbe9fd9dec
commit
ec14bf0e92
2 changed files with 38 additions and 2 deletions
|
@ -489,6 +489,15 @@ function getPrFiles() {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// istanbul ignore next
|
||||||
|
async function reopenPr(iid) {
|
||||||
|
await get.put(`projects/${config.repository}/merge_requests/${iid}`, {
|
||||||
|
body: {
|
||||||
|
state_event: 'reopen',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function updatePr(iid, title, description) {
|
async function updatePr(iid, title, description) {
|
||||||
await get.put(`projects/${config.repository}/merge_requests/${iid}`, {
|
await get.put(`projects/${config.repository}/merge_requests/${iid}`, {
|
||||||
body: {
|
body: {
|
||||||
|
@ -575,9 +584,18 @@ async function commitFilesToBranch(
|
||||||
opts.body.actions.push(action);
|
opts.body.actions.push(action);
|
||||||
}
|
}
|
||||||
if (await branchExists(branchName)) {
|
if (await branchExists(branchName)) {
|
||||||
|
logger.debug('Deleting existing branch');
|
||||||
await deleteBranch(branchName);
|
await deleteBranch(branchName);
|
||||||
}
|
}
|
||||||
|
logger.debug('Adding commits');
|
||||||
await get.post(`projects/${config.repository}/repository/commits`, opts);
|
await get.post(`projects/${config.repository}/repository/commits`, opts);
|
||||||
|
// Reopen PR if it previousluy existed and was closed by GitLab when we deleted branch
|
||||||
|
const pr = await getBranchPr(branchName);
|
||||||
|
// istanbul ignore if
|
||||||
|
if (pr) {
|
||||||
|
logger.debug('Reopening PR');
|
||||||
|
await reopenPr(pr.number);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET /projects/:id/repository/commits
|
// GET /projects/:id/repository/commits
|
||||||
|
|
|
@ -686,6 +686,11 @@ describe('platform/gitlab', () => {
|
||||||
statusCode: 404,
|
statusCode: 404,
|
||||||
})
|
})
|
||||||
); // branch exists
|
); // branch exists
|
||||||
|
get.mockImplementationOnce(() =>
|
||||||
|
Promise.reject({
|
||||||
|
statusCode: 404,
|
||||||
|
})
|
||||||
|
); // branch exists
|
||||||
const file = {
|
const file = {
|
||||||
name: 'some-new-file',
|
name: 'some-new-file',
|
||||||
contents: 'some new-contents',
|
contents: 'some new-contents',
|
||||||
|
@ -712,6 +717,11 @@ describe('platform/gitlab', () => {
|
||||||
});
|
});
|
||||||
// branch exists
|
// branch exists
|
||||||
get.mockImplementationOnce(() => ({ statusCode: 200 }));
|
get.mockImplementationOnce(() => ({ statusCode: 200 }));
|
||||||
|
get.mockImplementationOnce(() =>
|
||||||
|
Promise.reject({
|
||||||
|
statusCode: 404,
|
||||||
|
})
|
||||||
|
); // branch exists
|
||||||
const files = [
|
const files = [
|
||||||
{
|
{
|
||||||
name: 'some-existing-file',
|
name: 'some-existing-file',
|
||||||
|
@ -730,7 +740,6 @@ describe('platform/gitlab', () => {
|
||||||
expect(get.post.mock.calls).toMatchSnapshot();
|
expect(get.post.mock.calls).toMatchSnapshot();
|
||||||
expect(get.post.mock.calls).toHaveLength(1);
|
expect(get.post.mock.calls).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should parse valid gitAuthor', async () => {
|
it('should parse valid gitAuthor', async () => {
|
||||||
get.mockImplementationOnce(() => Promise.reject({ statusCode: 404 })); // file exists
|
get.mockImplementationOnce(() => Promise.reject({ statusCode: 404 })); // file exists
|
||||||
get.mockImplementationOnce(() =>
|
get.mockImplementationOnce(() =>
|
||||||
|
@ -738,6 +747,11 @@ describe('platform/gitlab', () => {
|
||||||
statusCode: 404,
|
statusCode: 404,
|
||||||
})
|
})
|
||||||
); // branch exists
|
); // branch exists
|
||||||
|
get.mockImplementationOnce(() =>
|
||||||
|
Promise.reject({
|
||||||
|
statusCode: 404,
|
||||||
|
})
|
||||||
|
); // branch exists
|
||||||
const file = {
|
const file = {
|
||||||
name: 'some-new-file',
|
name: 'some-new-file',
|
||||||
contents: 'some new-contents',
|
contents: 'some new-contents',
|
||||||
|
@ -758,7 +772,6 @@ describe('platform/gitlab', () => {
|
||||||
'bot@renovateapp.com'
|
'bot@renovateapp.com'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should skip invalid gitAuthor', async () => {
|
it('should skip invalid gitAuthor', async () => {
|
||||||
get.mockImplementationOnce(() => Promise.reject({ statusCode: 404 })); // file exists
|
get.mockImplementationOnce(() => Promise.reject({ statusCode: 404 })); // file exists
|
||||||
get.mockImplementationOnce(() =>
|
get.mockImplementationOnce(() =>
|
||||||
|
@ -766,6 +779,11 @@ describe('platform/gitlab', () => {
|
||||||
statusCode: 404,
|
statusCode: 404,
|
||||||
})
|
})
|
||||||
); // branch exists
|
); // branch exists
|
||||||
|
get.mockImplementationOnce(() =>
|
||||||
|
Promise.reject({
|
||||||
|
statusCode: 404,
|
||||||
|
})
|
||||||
|
); // branch exists
|
||||||
const file = {
|
const file = {
|
||||||
name: 'some-new-file',
|
name: 'some-new-file',
|
||||||
contents: 'some new-contents',
|
contents: 'some new-contents',
|
||||||
|
|
Loading…
Reference in a new issue