mirror of
https://github.com/paulirish/git-open.git
synced 2026-09-10 07:26:15 -04:00
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:
parent
0b414e8b1d
commit
c5ec7264a8
|
|
@ -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
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
|
|
|
|||
17
git-open
17
git-open
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue