mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
parent
dbe9fd9dec
commit
ec14bf0e92
2 changed files with 38 additions and 2 deletions
|
@ -489,6 +489,15 @@ function getPrFiles() {
|
|||
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) {
|
||||
await get.put(`projects/${config.repository}/merge_requests/${iid}`, {
|
||||
body: {
|
||||
|
@ -575,9 +584,18 @@ async function commitFilesToBranch(
|
|||
opts.body.actions.push(action);
|
||||
}
|
||||
if (await branchExists(branchName)) {
|
||||
logger.debug('Deleting existing branch');
|
||||
await deleteBranch(branchName);
|
||||
}
|
||||
logger.debug('Adding commits');
|
||||
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
|
||||
|
|
|
@ -686,6 +686,11 @@ describe('platform/gitlab', () => {
|
|||
statusCode: 404,
|
||||
})
|
||||
); // branch exists
|
||||
get.mockImplementationOnce(() =>
|
||||
Promise.reject({
|
||||
statusCode: 404,
|
||||
})
|
||||
); // branch exists
|
||||
const file = {
|
||||
name: 'some-new-file',
|
||||
contents: 'some new-contents',
|
||||
|
@ -712,6 +717,11 @@ describe('platform/gitlab', () => {
|
|||
});
|
||||
// branch exists
|
||||
get.mockImplementationOnce(() => ({ statusCode: 200 }));
|
||||
get.mockImplementationOnce(() =>
|
||||
Promise.reject({
|
||||
statusCode: 404,
|
||||
})
|
||||
); // branch exists
|
||||
const files = [
|
||||
{
|
||||
name: 'some-existing-file',
|
||||
|
@ -730,7 +740,6 @@ describe('platform/gitlab', () => {
|
|||
expect(get.post.mock.calls).toMatchSnapshot();
|
||||
expect(get.post.mock.calls).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('should parse valid gitAuthor', async () => {
|
||||
get.mockImplementationOnce(() => Promise.reject({ statusCode: 404 })); // file exists
|
||||
get.mockImplementationOnce(() =>
|
||||
|
@ -738,6 +747,11 @@ describe('platform/gitlab', () => {
|
|||
statusCode: 404,
|
||||
})
|
||||
); // branch exists
|
||||
get.mockImplementationOnce(() =>
|
||||
Promise.reject({
|
||||
statusCode: 404,
|
||||
})
|
||||
); // branch exists
|
||||
const file = {
|
||||
name: 'some-new-file',
|
||||
contents: 'some new-contents',
|
||||
|
@ -758,7 +772,6 @@ describe('platform/gitlab', () => {
|
|||
'bot@renovateapp.com'
|
||||
);
|
||||
});
|
||||
|
||||
it('should skip invalid gitAuthor', async () => {
|
||||
get.mockImplementationOnce(() => Promise.reject({ statusCode: 404 })); // file exists
|
||||
get.mockImplementationOnce(() =>
|
||||
|
@ -766,6 +779,11 @@ describe('platform/gitlab', () => {
|
|||
statusCode: 404,
|
||||
})
|
||||
); // branch exists
|
||||
get.mockImplementationOnce(() =>
|
||||
Promise.reject({
|
||||
statusCode: 404,
|
||||
})
|
||||
); // branch exists
|
||||
const file = {
|
||||
name: 'some-new-file',
|
||||
contents: 'some new-contents',
|
||||
|
|
Loading…
Reference in a new issue