This is a handy script to open the Merge Request on which a commit was merged on GitLab, for example when you find out in what commit a certain piece of code was added via git blame
and you don't know why this code was introduced from the commit message. You can then open the related merge request to find discussions, who reviewed the code and so on.
The script looks through the merge commits for the provided commit sha1 and looks for something like See merge request !42
. GitLab puts this into merge commit messages by default. It will also parse your origin
remote to find out where your GitLab repository is at. I then opens the merge request's URL (if found) using the open
command, unless you configure it otherwise.
To install simply run:
curl -L https://git.io/gitlab-openmr-install | bash
Or manually put this script into ~/bin
and run chmod +x ~/bin/gitlab-openmr.sh
. You'll also need git-when-merged
by Michael Haggerty, you can install it like this:
brew update
brew install git-when-merged
Run gitlab-openmr.sh
it like this:
~/my-git-repo> gitlab-openmr.sh 4174ee6
You can optionally supply a branch name as a second argument, if the branch merged into is not named development
like this:
~/my-git-repo> gitlab-openmr.sh 4174ee6 master
Enjoy! :)