Skip to content

Commit

Permalink
Fixed compare URL for both git@ and https repos
Browse files Browse the repository at this point in the history
  • Loading branch information
hdennison committed Mar 12, 2013
1 parent 955f971 commit 09fd601
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions push
Expand Up @@ -44,10 +44,18 @@ fi

# Parse output into a sexy GitHub compare URL!
remote_url=$(git remote show $remote -n | grep Push | awk '{ print $3 }')

if [[ "$remote_url" =~ "github.com" ]]; then

repo_name=$(echo $remote_url | sed 's/.*\:\(.*\)\.git/\1/')
github_url="https://github.com/$repo_name/compare/$refs"
if [[ ${remote_url:0:4} == "git@" ]]; then
regEx='s/.*\:\(.*\)\.git/\1/'
url='https://github.com/'
else
regEx='s/\(.*\)\.git/\1/'
fi

repo_name=$(echo $remote_url | sed $regEx)
github_url="$url$repo_name/compare/$refs"
copied="Compare URL copied to clipboard!"
which pbcopy >& /dev/null && echo $github_url | pbcopy && echo $copied
which xclip >& /dev/null && echo $github_url | xclip -selection clipboard && echo $copied
Expand Down

0 comments on commit 09fd601

Please sign in to comment.