Merge pull request #15 from nwinkler/stash

Added support for Atlassian Stash.
This commit is contained in:
Paul Irish 2015-02-13 22:57:02 +03:00
commit e04edf75b1

View file

@ -34,6 +34,13 @@ then
exit 1
fi
# get current branch
if [ -z "$2" ]
then
branch=`git symbolic-ref -q --short HEAD`
else
branch="$2"
fi
# URL normalization
# Github support
@ -44,18 +51,19 @@ if grep -q github <<<$giturl; then
elif grep -q bitbucket <<<$giturl; then
giturl=${giturl/git\@bitbucket\.org\:/https://bitbucket.org/}
providerUrlDifference=branch
# Atlassian Stash support - Stash URLs always contain the /scm/ part
elif grep -q "/scm/" <<<$giturl; then
re='(.*)/scm/(.*)/(.*)\.git'
if [[ $giturl =~ $re ]]
then
giturl=${BASH_REMATCH[1]}/projects/${BASH_REMATCH[2]}/repos/${BASH_REMATCH[3]}
providerUrlDifference=browse
branch="?at=refs%2Fheads%2F${branch}"
fi
fi
giturl=${giturl%\.git}
# get current branch
if [ -z "$2" ]
then
branch=`git symbolic-ref -q --short HEAD`
else
branch="$2"
fi
if [ ! -z "$branch" ]
then
giturl="${giturl}/${providerUrlDifference}/${branch}"