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
32
32
33
33
$ git open --print
34
34
# 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
35
38
```
36
39
37
40
## Installation
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ git open [remote] [branch]
18
18
Available options are
19
19
c,commit! open current commit
20
20
i,issue! open issues page
21
+ s,suffix= append this suffix
21
22
p,print! just print the url
22
23
"
23
24
@@ -30,17 +31,23 @@ is_commit=0
30
31
is_issue=0
31
32
protocol=" https"
32
33
print_only=0
34
+ suffix_flag=" "
33
35
34
36
while test $# ! = 0; do
35
37
case " $1 " in
36
38
--commit) is_commit=1;;
37
39
--issue) is_issue=1;;
40
+ --suffix=* ) suffix_flag=" $1 " ;;
38
41
--print) print_only=1;;
39
42
--) shift ; break ;;
40
43
esac
41
44
shift
42
45
done
43
46
47
+ # parse suffix from suffix=value
48
+ IFS=' =' read -ra suffix_flag <<< " $suffix_flag"
49
+ suffix=${suffix_flag[1]}
50
+
44
51
# are we in a git repo?
45
52
if ! git rev-parse --is-inside-work-tree & > /dev/null; then
46
53
echo " Not a git repository." 1>&2
@@ -238,6 +245,10 @@ elif [[ $remote_ref != "master" ]]; then
238
245
openurl=" $openurl$providerBranchRef "
239
246
fi
240
247
248
+ if [ " $suffix " ]; then
249
+ openurl=" $openurl /$suffix "
250
+ fi
251
+
241
252
# get current open browser command
242
253
case $( uname -s ) in
243
254
Darwin) open=' open' ;;
Original file line number Diff line number Diff line change 3
3
4
4
## SYNOPSIS
5
5
6
- ` git open ` [ --issue] [ --commit] [ remote-name] [ branch-name]
6
+ ` git open ` [ --issue] [ --commit] [ --suffix some_suffix ] [ remote-name] [ branch-name]
7
7
8
8
9
9
## DESCRIPTION
@@ -23,6 +23,9 @@ git hosting services are supported.
23
23
it will open the webpage with that issue. See ` EXAMPLES ` for more information.
24
24
This only works on GitHub, GitLab, Visual Studio Team Services and Team Foundation Server at the moment.
25
25
26
+ ` -s ` , ` --suffix ` some_suffix
27
+ Append the given suffix to the url
28
+
26
29
` -p ` , ` --print `
27
30
Just print the URL. Do not open it in browser.
28
31
@@ -56,6 +59,12 @@ git open --issue
56
59
If branches use naming convention of ` issues/#123 ` , it opens
57
60
https://github.com/TRACKED_REMOTE_USER/CURRENT_REPO/issues/123
58
61
62
+ ``` sh
63
+ git open --suffix pulls
64
+ ```
65
+
66
+ It opens the URL https://github.com/TRACKED_REMOTE_USER/CURRENT_REPO/pulls
67
+
59
68
``` sh
60
69
git open --print
61
70
```
Original file line number Diff line number Diff line change @@ -167,6 +167,11 @@ setup() {
167
167
assert_output " https://github.com/paulirish/git-open/commit/${sha} "
168
168
}
169
169
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
+
170
175
@test " gh: gist" {
171
176
git remote set-url origin
" [email protected] :2d84a6db1b41b4020685.git"
172
177
run ../git-open
You can’t perform that action at this time.
0 commit comments