From 8d137e7623abed04c8e4cbe6fa70be1abc61709a Mon Sep 17 00:00:00 2001 From: Brent Beardsley Date: Thu, 5 Feb 2015 13:06:27 -0700 Subject: [PATCH 1/2] Add support for self-hosted Gitlab. Fixes #8. --- README.md | 20 ++++++++++++++++++++ git-open | 14 ++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/README.md b/README.md index 0018f33..8328dae 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,26 @@ curl -o ~/bin/git-open https://raw.githubusercontent.com/paulirish/git-open/mast chmod +x ~/bin/git-open ``` + +## Gitlab support +To configure gitlab support you need to set gitopen.gitlab.domain: + +``` +git config --global gitopen.gitlab.domain [yourdomain.here] +``` + +or + +``` +git config gitopen.gitlab.domain [yourdomain.here] in your local repository +``` + +By default it goes to the tree view but can be changed to go to the commits view like so: + +``` +git config gitopen.gitlab.urldifference commits +``` + ## Thx @jasonmccreary did [all the hard work](https://github.com/jasonmccreary/gh) diff --git a/git-open b/git-open index eba7572..c8c7a43 100755 --- a/git-open +++ b/git-open @@ -44,6 +44,20 @@ if grep -q github <<<$giturl; then elif grep -q bitbucket <<<$giturl; then giturl=${giturl/git\@bitbucket\.org\:/https://bitbucket.org/} providerUrlDifference=branch +else + gitlab_domain=$(git config --get gitopen.gitlab.domain) + if [ ! -z "$gitlab_domain" ]; then + if grep -q $gitlab_domain <<<$giturl; then + giturl=${giturl/git\@${gitlab_domain}:/https://${gitlab_domain}/} + + gitlab_urldifference=$(git config --get gitopen.gitlab.urldifference) + if [ -z "$gitlab_urldifference" ]; then + providerUrlDifference=tree + else + providerUrlDifference=$gitlab_urldifference + fi + fi + fi fi giturl=${giturl%\.git} From 9aa854b039a5ae128fcd041d1fb7e9aebb22f55c Mon Sep 17 00:00:00 2001 From: Brent Beardsley Date: Sun, 8 Feb 2015 11:30:10 -0700 Subject: [PATCH 2/2] simplified the open command by using a case stmt --- git-open | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/git-open b/git-open index c8c7a43..440dbc0 100755 --- a/git-open +++ b/git-open @@ -79,20 +79,12 @@ fi giturl=${giturl/tree\/master/} # get current open browser command -if [ $(uname -s) == "Darwin" ] -then - open=open -elif [ "$TERM" == "cygwin" ] -then - if [ "$MSYSTEM" == "MINGW32" ] - then - open=start - else - open=cygstart - fi -else - open=xdg-open -fi +case $( uname -s ) in +Darwin) open=open;; +MINGW*) open=start;; +CYGWIN*) open=cygstart;; +*) open=xdg-open;; +esac # open it in a browser $open $giturl &> /dev/null