Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It should be possible to merge only if an explicit approval is given #147

Open
dnesting opened this issue Apr 7, 2022 · 1 comment
Open

Comments

@dnesting
Copy link

dnesting commented Apr 7, 2022

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.

@dnesting
Copy link
Author

dnesting commented Apr 7, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants