File tree Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ git open [remote] [branch]
16
16
https://github.com/paulirish/git-open/
17
17
18
18
Available options are
19
+ c,commit! open current commit
19
20
i,issue! open issues page
20
21
p,print! just print the url
21
22
"
@@ -25,12 +26,14 @@ p,print! just print the url
25
26
SUBDIRECTORY_OK=' Yes' . " $( git --exec-path) /git-sh-setup"
26
27
27
28
# Defaults
29
+ is_commit=0
28
30
is_issue=0
29
31
protocol=" https"
30
32
print_only=0
31
33
32
34
while test $# ! = 0; do
33
35
case " $1 " in
36
+ --commit) is_commit=1;;
34
37
--issue) is_issue=1;;
35
38
--print) print_only=1;;
36
39
--) shift ; break ;;
227
230
228
231
openurl=" $protocol ://$domain /$urlpath "
229
232
230
- # simplify URL for master
231
- if [[ $remote_ref != " master" ]]; then
233
+ if (( is_commit )) ; then
234
+ sha=$( git rev-parse HEAD)
235
+ openurl=" $openurl /commit/$sha "
236
+ elif [[ $remote_ref != " master" ]]; then
237
+ # simplify URL for master
232
238
openurl=" $openurl$providerBranchRef "
233
239
fi
234
240
Original file line number Diff line number Diff line change 3
3
4
4
## SYNOPSIS
5
5
6
- ` git open ` [ --issue] [ remote-name] [ branch-name]
6
+ ` git open ` [ --issue] [ --commit ] [ remote-name] [ branch-name]
7
7
8
8
9
9
## DESCRIPTION
@@ -14,6 +14,10 @@ git hosting services are supported.
14
14
15
15
## OPTIONS
16
16
17
+ ` -c ` , ` --commit `
18
+ Open the current commit. See ` EXAMPLES ` for more information.
19
+ Only tested with GitHub & GitLab.
20
+
17
21
` -i ` , ` --issue `
18
22
Open the current issue. When the name of the current branch matches the right pattern,
19
23
it will open the webpage with that issue. See ` EXAMPLES ` for more information.
@@ -58,6 +62,14 @@ git open --print
58
62
59
63
It prints the URL https://github.com/TRACKED_REMOTE_USER/CURRENT_REPO/
60
64
65
+ ``` sh
66
+ git open --commit
67
+ ```
68
+
69
+ Supposing that the current sha is ` 2ddc8d4548d0cee3d714dcf0068dbec5b168a9b2 ` , it opens
70
+ https://github.com/TRACKED_REMOTE_USER/CURRENT_REPO/commit/2ddc8d4548d0cee3d714dcf0068dbec5b168a9b2
71
+
72
+
61
73
## SUPPORTED GIT HOSTING SERVICES
62
74
63
75
git-open can automatically guess the corresponding repository page for remotes
Original file line number Diff line number Diff line change @@ -160,6 +160,13 @@ setup() {
160
160
assert_output " https://github.com/paulirish/git-open/issues/38"
161
161
}
162
162
163
+ @test " gh: git open --commit" {
164
+ git remote set-url origin " github.com:paulirish/git-open.git"
165
+ sha=$( git rev-parse HEAD)
166
+ run ../git-open " --commit"
167
+ assert_output " https://github.com/paulirish/git-open/commit/${sha} "
168
+ }
169
+
163
170
@test " gh: gist" {
164
171
git remote set-url origin
" [email protected] :2d84a6db1b41b4020685.git"
165
172
run ../git-open
You can’t perform that action at this time.
0 commit comments