microplane
microplane copied to clipboard
It should be possible to merge only if an explicit approval is given
On GitLab enterprise, mp merge
currently merges if it is possible to merge. If a repo is not configured with any merge rules requiring an approval, this means merges will occur potentially with no review. I would like the option to merge only if an explicit approval was given by a reviewer regardless of how the project is configured.
In addition, mp status
should independently report the approval status of a pending MR.
It looks like this should be possible using the GitLab Approvals API. Maybe:
GET /projects/:id/merge_requests/:merge_request_iid/approvals
{
"id": 5,
"iid": 5,
"project_id": 1,
"title": "Approvals API",
"description": "Test",
"state": "opened",
"created_at": "2016-06-08T00:19:52.638Z",
"updated_at": "2016-06-08T21:20:42.470Z",
"merge_status": "cannot_be_merged",
"approvals_required": 2,
"approvals_left": 1,
"approved_by": [
{
"user": {
"name": "Administrator",
"username": "root",
"id": 1,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon",
"web_url": "http://localhost:3000/root"
}
}
]
}
If approvals_left > 0
that implies the MR is missing approvals and we can signal that in mp status
output. If approvals_left == 0
but len(approved_by) > 0
that implies an explicit approval was given and we can merge even when --require-approval
. GitLab projects may have complex approval rules, though, and I don't know how best to handle that.