0

Is there a git command that can show all the opened merge requests for a repository? I've found how I can see all the branches that were merged into master using: git log --merges --first-parent master \ --pretty=format:"%h %<(10,trunc)%aN %C(white)%<(15)%ar%Creset %C(red bold)%<(15)%D%Creset %s", but this is not what I'm looking for.

phd
  • 82,685
  • 13
  • 120
  • 165
  • AFAIK it cannot be done through the CLI, so you should use either the web interface or Gitlab API. – djuarezg Dec 06 '18 at 11:07
  • Gitlab API certainly can be called from the command line. – phd Dec 06 '18 at 11:40
  • [This is an example of how to call an API with curl](https://stackoverflow.com/a/36755216/7976758) and [here is the API to list merge requests](https://docs.gitlab.com/ce/api/merge_requests.html#list-merge-requests). – phd Dec 06 '18 at 11:47

1 Answers1

1

Using the tips phd gave me, I've found this command that helped me see all the opened merge request for a single branch that I want:

curl -k --header "PRIVATE-TOKEN: TOKEN" "https://gitlabhost.com/api/v4/merge_requests?scope=all&state=opened&source_branch=source_branch" > ROOTDIR/opened_merge_requests.txt

Considering TOKEN, source_branch and ROOTDIR to be string variables.