kyb
kyb

Reputation: 8141

Fetch opened merge requests from git remote, especially from GitLab

In GitLab Documentation described a nice way to fetch merge requests from gitlab remote. (i guess others work near to this).

How is it possible fetch only requests not merged yet? (Fetch only opened merge requests).

Upvotes: 1

Views: 762

Answers (1)

Andy Theos
Andy Theos

Reputation: 3346

I have searched for a way to get only opened MRs too, that is what i came up with:

  • There is no way to distinguish opened MRs apart from others inside git. Opened, merged and closed MRs have no markers or comments. Therefore you cannot fetch opened MRs using only git commands.
  • There is Gitlab API that can be used to get list of opened MRs.
  • When opened MR become closed or merged you will not get a notification about these to trigger this MR deletion from your local repo or whatever.

Therefore i will offer you to write shell snippet (optionally place this script in .gitconfig or add to git hooks), that will do the following:

  1. Using Gitlab API methods obtain opened MRs list with branch names (optionally clear previous opened MRs list and prune previous references).
  2. Fetch (or add to .git/config) all MR branches from this list.

This approach can be used as a more dynamic alias than in the Gitlab Docs link you mentioned.

Upvotes: 2

Related Questions