mirror of
https://github.com/paulirish/git-open.git
synced 2026-09-10 07:26:15 -04:00
code comments.
This commit is contained in:
parent
ed88ae5cf3
commit
26d6f093ae
12
git-open
12
git-open
|
|
@ -1,9 +1,11 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
|
||||
# Opens the github page for a repo/branch in your browser.
|
||||
#
|
||||
# gh [remote] [branch]
|
||||
|
||||
|
||||
# are we in a git repo?
|
||||
git rev-parse --is-inside-work-tree 2>/dev/null
|
||||
|
||||
if [[ $? != 0 ]]
|
||||
|
|
@ -12,6 +14,9 @@ then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# assume origin if not provided
|
||||
# fallback to upstream if neither is present.
|
||||
remote="origin"
|
||||
if [ ! -z "$1" ]
|
||||
then
|
||||
|
|
@ -27,9 +32,13 @@ then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# URL normalization
|
||||
giturl=${giturl/git\@github\.com\:/https://github.com/}
|
||||
giturl=${giturl%\.git}
|
||||
|
||||
|
||||
# get current branch
|
||||
if [ -z "$2" ]
|
||||
then
|
||||
branch=`git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||'`
|
||||
|
|
@ -45,5 +54,6 @@ fi
|
|||
# simplify URL for master
|
||||
giturl=${giturl/tree\/master/}
|
||||
|
||||
# open it in a browser
|
||||
open $giturl
|
||||
exit 0
|
||||
|
|
|
|||
Loading…
Reference in a new issue