Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

feature: Update MR reviewer #562

Closed
zemzale opened this issue Jan 12, 2021 · 6 comments · Fixed by #694
Closed

feature: Update MR reviewer #562

zemzale opened this issue Jan 12, 2021 · 6 comments · Fixed by #694
Labels
cmd: mr Issue is related to merge request management enhancement New feature or request priority: nice to have status: open-for-PRs Pull request can be opened for this issue

Comments

@zemzale
Copy link
Collaborator

zemzale commented Jan 12, 2021

Describe the feature or problem you'd like to solve

In GitLab 13.7 there is MR reviewers field https://about.gitlab.com/blog/2020/10/13/merge-request-reviewers/

Currently there is no way how to interact with this from glab.

Propose a Solution

Add a new flag to --reviewers to allow updating that from glab

Additional context

I actually have not found any API documentation about this. Maybe it's missing, but I didn't dig for too long or just missed it.

@profclems
Copy link
Owner

This feature is relatively new and I believe most self-hosted instances haven't made the upgrade yet.

Also, I don't know if there's any endpoint available to get the reviewers (Let me know if you find any).

The only endpoint quite close is the Project level Rules under Merge Request approvals API, then we use the eligible approvers list.
This will definately come with a lot of limitations.

Do you have any suggestion on what we can do?

@zemzale
Copy link
Collaborator Author

zemzale commented Jan 13, 2021

Also, I don't know if there's any endpoint available to get the reviewers (Let me know if you find any).

It's possible from the MR get endpoint it's just not documented. It's basically the same thing as assignees on a different key.
Example :

{
   ...
    "reviewers": [
        {
            "id": 2182404,
            "name": "Alberts Zemzale",
            "username": "zemzale",
            "state": "active",
            "avatar_url": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/2182404/avatar.png",
            "web_url": "https://gitlab.com/zemzale"
        }
    ],
    ...
}

It seems like updating is not yet possible via API https://gitlab.com/gitlab-org/gitlab/-/issues/292714 . The milestone for that is 13.8 so that is a blocker for updating.

Also it doesn't seem like xanzy/go-gitlab has support for reviewer attribute, but I have opend an issue about it xanzy/go-gitlab#1030

@zemzale zemzale added cmd: mr Issue is related to merge request management enhancement New feature or request waiting Waiting on an external issue to be resolved priority: nice to have labels Jan 13, 2021
@profclems
Copy link
Owner

profclems commented Jan 13, 2021

It's possible from the MR get endpoint it's just not documented. It's basically the same thing as assignees on a different key.

Seems the reviewers returned are those who have left a review on the MR or those that reviews have been requested from.
I had expected it to return a list of users who are eligible to review, approve or merge the merge request.

I tried this on gitlab-org/gitlab repo:

→ glab api /projects/gitlab-org%2Fgitlab/merge_requests/51578

The response comes with an empty reviewers array because no review has been left on the merge request and no review requested

{
   ...
   "assignees": [
    {
      "id": 1758950,
      "name": "Erick Bajao",
      "username": "iamricecake",
      "state": "active",
      "avatar_url": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/1758950/avatar.png",
      "web_url": "https://gitlab.com/iamricecake"
    }, 
    {
      "id": 4155490,
      "name": "Marcel Amirault",
      "username": "marcel.amirault",
      "state": "active",
      "avatar_url": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/4155490/avatar.png",
      "web_url": "https://gitlab.com/marcel.amirault"
    }
  ],
  "assignee": {
    "id": 1758950,
    "name": "Erick Bajao",
    "username": "iamricecake",
    "state": "active",
    "avatar_url": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/1758950/avatar.png",
    "web_url": "https://gitlab.com/iamricecake"
  },
  "reviewers": [],
  ...
}

@profclems
Copy link
Owner

This merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51186 has been reviewed:

→ gl api /projects/gitlab-org%2Fgitlab/merge_requests/51186
{
...
"reviewers": [
    {
      "id": 142752,
      "name": "Gary Holtz",
      "username": "garyh",
      "state": "active",
      "avatar_url": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/142752/avatar.png",
      "web_url": "https://gitlab.com/garyh"
    }, 
    {
      "id": 236961,
      "name": "Marcia Ramos",
      "username": "marcia",
      "state": "active",
      "avatar_url": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/236961/avatar.png",
      "web_url": "https://gitlab.com/marcia"
    }, 
    {
      "id": 1884221,
      "name": "Patrick Bajao",
      "username": "patrickbajao",
      "state": "active",
      "avatar_url": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/1884221/avatar.png",
      "web_url": "https://gitlab.com/patrickbajao"
    }
  ],
...
}

@kousikmitra
Copy link
Contributor

Would like to work on this one if anyone else haven't pick it yet. :)

@zemzale
Copy link
Collaborator Author

zemzale commented Apr 27, 2021

@kousikmitra sure thing. Go ahead and just open a PR.

@zemzale zemzale added status: open-for-PRs Pull request can be opened for this issue and removed waiting Waiting on an external issue to be resolved labels Apr 27, 2021
kousikmitra added a commit to kousikmitra/glab that referenced this issue Apr 27, 2021
It allowes `mr update` to update reviewers with a new flag --reviewers
Delivers profclems#562
kousikmitra added a commit to kousikmitra/glab that referenced this issue Apr 28, 2021
It allowes `mr update` to update reviewers with a new flag --reviewers
Delivers profclems#562
profclems pushed a commit to olearycrew/glab that referenced this issue Jun 12, 2021
It allowes `mr update` to update reviewers with a new flag --reviewers
Delivers profclems#562
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cmd: mr Issue is related to merge request management enhancement New feature or request priority: nice to have status: open-for-PRs Pull request can be opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants