Skip to content

Instantly share code, notes, and snippets.

@michaellihs
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaellihs/eb65d4f32cb203764ad9 to your computer and use it in GitHub Desktop.
Save michaellihs/eb65d4f32cb203764ad9 to your computer and use it in GitHub Desktop.
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