-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gitlab,azure): try approving before auto-merge
- Loading branch information
Showing
6 changed files
with
168 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1900,6 +1900,7 @@ describe('modules/platform/gitlab/index', () => { | |
.get('/api/v4/user') | ||
.reply(200, { | ||
email: '[email protected]', | ||
id: 1, | ||
name: 'Renovate Bot', | ||
}) | ||
.get('/api/v4/version') | ||
|
@@ -2778,6 +2779,10 @@ describe('modules/platform/gitlab/index', () => { | |
target_branch: 'master', | ||
description: 'the-body', | ||
}) | ||
.get('/api/v4/projects/undefined/merge_requests/12345/approvals') | ||
.reply(200, { | ||
approved_by: [], | ||
}) | ||
.post('/api/v4/projects/undefined/merge_requests/12345/approve') | ||
.reply(200); | ||
expect( | ||
|
@@ -2811,6 +2816,8 @@ describe('modules/platform/gitlab/index', () => { | |
target_branch: 'master', | ||
description: 'the-body', | ||
}) | ||
.get('/api/v4/projects/undefined/merge_requests/12345/approvals') | ||
.replyWithError('some error') | ||
.post('/api/v4/projects/undefined/merge_requests/12345/approve') | ||
.replyWithError('some error'); | ||
await expect( | ||
|
@@ -3139,6 +3146,10 @@ describe('modules/platform/gitlab/index', () => { | |
description: 'body', | ||
state: 'opened', | ||
}) | ||
.get('/api/v4/projects/undefined/merge_requests/1/approvals') | ||
.reply(200, { | ||
approved_by: [], | ||
}) | ||
.post('/api/v4/projects/undefined/merge_requests/1/approve') | ||
.reply(200); | ||
await expect( | ||
|
@@ -3153,6 +3164,52 @@ describe('modules/platform/gitlab/index', () => { | |
).toResolve(); | ||
}); | ||
|
||
it('does not auto-approve if already approved', async () => { | ||
await initPlatform('13.3.6-ee'); | ||
httpMock | ||
.scope(gitlabApiHost) | ||
.get( | ||
'/api/v4/projects/undefined/merge_requests?per_page=100&scope=created_by_me', | ||
) | ||
.reply(200, [ | ||
{ | ||
iid: 1, | ||
source_branch: 'branch-a', | ||
title: 'branch a pr', | ||
description: 'a merge request', | ||
state: 'opened', | ||
}, | ||
]) | ||
.put('/api/v4/projects/undefined/merge_requests/1') | ||
.reply(200, { | ||
iid: 1, | ||
source_branch: 'branch-a', | ||
title: 'title', | ||
description: 'body', | ||
state: 'opened', | ||
}) | ||
.get('/api/v4/projects/undefined/merge_requests/1/approvals') | ||
.reply(200, { | ||
approved_by: [ | ||
{ | ||
user: { | ||
id: 1, | ||
}, | ||
}, | ||
], | ||
}); | ||
await expect( | ||
gitlab.updatePr({ | ||
number: 1, | ||
prTitle: 'title', | ||
prBody: 'body', | ||
platformPrOptions: { | ||
autoApprove: true, | ||
}, | ||
}), | ||
).toResolve(); | ||
}); | ||
|
||
it('closes the PR', async () => { | ||
await initPlatform('13.3.6-ee'); | ||
httpMock | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters