Skip to content

Instantly share code, notes, and snippets.

@michaellihs michaellihs/gitlab_site.md
Last active Aug 29, 2015

Embed
What would you like to do?
Opens a Gitlab site for the current directory

Gitlab Helper for opening Gitlab project site of current git repository

Setup

(On a Mac) create the following ruby script in /usr/bin/gitlab_site

#!/usr/bin/ruby

git_remote = `git remote -v`.scan(/git@(.+?).git/)
if git_remote.is_a? Array
  git_remote = git_remote[0][0]
else
  fail 'No git remote detectable for current directory!'
end
remote_url = 'https://' + git_remote.gsub(/:/, '/')
 `open #{remote_url}`

make it executable

chmod u+x /usr/bin/gitlab_site

Usage

You can now run

gitlab_site

in any directory containing a git repository with a remote to your Gitlab Server...

That's it - have fun!

P.S. any suggestions on improving the script are highly appreciated :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.