GitLab's documentations say that a merge request can be updated to add one or more reviewers via the reviewer_ids property: https://docs.gitlab.com/ee/api/merge_requests.html#update-mr
What seems strange to me is that certain projects or merge requests or users seem to have the ability to add more than one reviewer to a merge request, while others can only have one reviewer. This is viewable in the UI at gitlab.com, with some merge requests having more than 1 reviewer (see screenshot below), while my free account only seems to allow 1 reviewer on a merge request.
Via the GitLab api, how can I detect whether a given merge request can support more than 1 reviewer? If not at the merge request level, is this something at the project or user level?
For some additional context, I'm working on building a VSCode extension for CodeStream to enable support for GitLab merge requests, and the ability to add reviewers is part of its functionality.
Related
I am using this endpoint /api/v4/groups/::group_id/merge_requests to fetch merge requests in a group.
However what I need is the number of times changes were requested on a particular merge request, and the content of those requests if possible.
While working with GitHub, fetching count of review comments is possible with repos/{orgName}/{repoName}/pulls/{pullNumber}, which returns a field
{"review_comments": 0} as the number of review comments on the pull request.
Is the same possible with the available GitLab REST endpoints?
There is a thread in the GitLab forum on this that could help.
https://forum.gitlab.com/t/gitlab-rest-api-endpoint-for-changes-requested-on-merge-requests/77164/4
I am trying to implement git flow with GitLab.
The flow of merge requests should be restricted. For example, it should not be allowed to create a merge request from a feature branch to main.
Can I solve this with git server side hooks?
Considering you can require everyone to submit merge requests for a protected branch, you can try and:
protect the target branch
from the Allowed to merge list, select a group which does not include Developers.
from the Allowed to push list, select No one.
That way, merge request to that branch should not be possible from developers.
I'm trying to replicate the ability to add reviews to GitLab merge requests in my app and I don't see anything in the api documentation related to merge request reviews or merge request draft notes.
On the web version of GitLab, when I create a comment on a line of code in a commit and I select 'Start a review', I can see a POST to http://<myInstance>/<myProject/-/merge_requests/<id>/drafts. If I execute a GET on that, I can see my pending review comment (note) in the response.
Is there anyway to create / read / update / delete merge request reviews with the GitLab api?
Currently, as of Gitlab 13.9, there is no support for this. The closest it gets for an API for Merge Request Reviews is this issue/feature request asking for an API to retrieve Review comments: https://gitlab.com/gitlab-org/gitlab/-/issues/12297
If you're a paid user, contacting support/sales is a good option since they tend to add features themselves when paid users request it, but tend to let the community add an Open Source contribution otherwise.
I have GitLab Starter which seems to mean that I am unable to restrict code approvers on a directory basis as everyone needs developer level access.
This is causing slight headaches.
Is there a way in GitLab that I can review who approved groups of merge requests? This way I can at least check after the fact that no one has approved code who should not have.
Is there a way to query the backend database or a way of gaining this information in some GUI screen somewhere?
There will be a way, with the upcoming GitLab 13.5 to clearly see the status of the approval process and who has approved a MR.
In the meantime, you still have the GitLab Merge Request approval API and the merge request API, with a call like GET /merge_requests does include paramters like approver_ids
Returns merge requests which have specified all the users with the given ids as individual approvers.
None returns merge requests without approvers.
Any returns merge requests with an approver.
That could help checking who has approved a MR.
Users on GitLab Starter, Bronze, or higher will also see the approvals_before_merge parameter.
I'd like to see all the pending merge requests where I am listed as an approver. How do I find them? Currently, I can only see how to filter for merge requests by assignee or author, not approver. Outside of e-mail, how do you figure out which merge requests you need to respond to and review?
Currently, you can't.
However, there is work in progress to be able to list MRs by approver.