Easily track and open the relevant github issue via branch naming convention (#46)

* Open issue using ‘git open issue’
* Update doc to reflect new functionality
This commit is contained in:
kangaroo5383 2016-08-05 15:38:03 -07:00 committed by Paul Irish
parent 0b414e8b1d
commit c5ec7264a8
2 changed files with 23 additions and 2 deletions

View file

@ -6,6 +6,9 @@ browser.
## Usage
git open [remote-name] [branch-name]
git open issue
(only implemented github support, feel free to fix the other ones.)
### Examples
@ -18,6 +21,10 @@ browser.
$ git open upstream master
> open https://github.com/REMOTE_UPSTREAM_USER/CURRENT_REPO/tree/master
On a branch with the naming convention of issues/#123
$ git open issue
> open https://github.com/REMOTE_UPSTREAM_USER/CURRENT_REPO/issues/123
![git open2015-01-24 13_51_18](https://cloud.githubusercontent.com/assets/39191/5889192/244a0b72-a3d0-11e4-8ab9-55fc64228aaa.gif)
### Installation
@ -32,6 +39,7 @@ You can use also `npm` to install this package:
npm install --global git-open
#### Using Windows Powershell
Save git-open anywhere, say as ~/Documents/Scripts/git-open.sh and define

View file

@ -20,7 +20,18 @@ fi
# fallback to upstream if neither is present.
remote="origin"
if [ -n "$1" ]; then
remote="$1"
if [ "$1" == "issue" ]; then
currentBranch=$(git symbolic-ref -q --short HEAD)
regex='^issue'
if [[ $currentBranch =~ $regex ]]; then
issue=${currentBranch#*#}
else
echo "'git open issue' expect branch naming to be issues/#123"
exit 0
fi
else
remote="$1"
fi
fi
remote_url="remote.${remote}.url"
@ -94,7 +105,9 @@ else
fi
giturl=${giturl%\.git}
if [ -n "$branch" ]; then
if [ -n "$issue" ]; then
giturl="${giturl}/issues/${issue}"
elif [ -n "$branch" ]; then
giturl="${giturl}/${providerUrlDifference}/${branch}"
fi