File tree Expand file tree Collapse file tree 4 files changed +29
-1
lines changed Expand file tree Collapse file tree 4 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ $ git open --issue
3232
3333$ git open --print
3434# prints https://github.com/TRACKED_REMOTE_USER/CURRENT_REPO/tree/CURRENT_BRANCH
35+
36+ $ git open --suffix pulls
37+ # opens https://github.com/TRACKED_REMOTE_USER/CURRENT_REPO/pulls
3538```
3639
3740## Installation
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ git open [remote] [branch]
1818 Available options are
1919c,commit! open current commit
2020i,issue! open issues page
21+ s,suffix= append this suffix
2122p,print! just print the url
2223"
2324
@@ -30,17 +31,23 @@ is_commit=0
3031is_issue=0
3132protocol=" https"
3233print_only=0
34+ suffix_flag=" "
3335
3436while test $# ! = 0; do
3537 case " $1 " in
3638 --commit) is_commit=1;;
3739 --issue) is_issue=1;;
40+ --suffix=* ) suffix_flag=" $1 " ;;
3841 --print) print_only=1;;
3942 --) shift ; break ;;
4043 esac
4144 shift
4245done
4346
47+ # parse suffix from suffix=value
48+ IFS=' =' read -ra suffix_flag <<< " $suffix_flag"
49+ suffix=${suffix_flag[1]}
50+
4451# are we in a git repo?
4552if ! git rev-parse --is-inside-work-tree & > /dev/null; then
4653 echo " Not a git repository." 1>&2
@@ -238,6 +245,10 @@ elif [[ $remote_ref != "master" ]]; then
238245 openurl=" $openurl$providerBranchRef "
239246fi
240247
248+ if [ " $suffix " ]; then
249+ openurl=" $openurl /$suffix "
250+ fi
251+
241252# get current open browser command
242253case $( uname -s ) in
243254 Darwin) open=' open' ;;
Original file line number Diff line number Diff line change 33
44## SYNOPSIS
55
6- ` git open ` [ --issue] [ --commit] [ remote-name] [ branch-name]
6+ ` git open ` [ --issue] [ --commit] [ --suffix some_suffix ] [ remote-name] [ branch-name]
77
88
99## DESCRIPTION
@@ -23,6 +23,9 @@ git hosting services are supported.
2323 it will open the webpage with that issue. See ` EXAMPLES ` for more information.
2424 This only works on GitHub, GitLab, Visual Studio Team Services and Team Foundation Server at the moment.
2525
26+ ` -s ` , ` --suffix ` some_suffix
27+ Append the given suffix to the url
28+
2629` -p ` , ` --print `
2730 Just print the URL. Do not open it in browser.
2831
@@ -56,6 +59,12 @@ git open --issue
5659If branches use naming convention of ` issues/#123 ` , it opens
5760https://github.com/TRACKED_REMOTE_USER/CURRENT_REPO/issues/123
5861
62+ ``` sh
63+ git open --suffix pulls
64+ ```
65+
66+ It opens the URL https://github.com/TRACKED_REMOTE_USER/CURRENT_REPO/pulls
67+
5968``` sh
6069git open --print
6170```
Original file line number Diff line number Diff line change @@ -167,6 +167,11 @@ setup() {
167167 assert_output " https://github.com/paulirish/git-open/commit/${sha} "
168168}
169169
170+ @test " gh: git open --suffix anySuffix" {
171+ run ../git-open " --suffix" " anySuffix"
172+ assert_output " https://github.com/paulirish/git-open/anySuffix"
173+ }
174+
170175@test " gh: gist" {
171176 git remote set-url origin " git@gist.github.com:2d84a6db1b41b4020685.git"
172177 run ../git-open
You can’t perform that action at this time.
0 commit comments