File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -153,8 +153,8 @@ function getConfig() {
153153domain=$( getConfig " domain" )
154154protocol=$( getConfig " protocol" )
155155
156- # Get current branch
157- branch=${2:- $(git symbolic-ref -q --short HEAD)}
156+ # Get current branch / tag / commit
157+ branch=${2:- $(git symbolic-ref -q --short HEAD || git describe --tags --exact-match 2> / dev / null || git rev-parse HEAD )}
158158
159159# Split arguments on '/'
160160IFS=' /' read -r -a pathargs <<< " $urlpath"
Original file line number Diff line number Diff line change @@ -65,6 +65,17 @@ setup() {
6565 assert_output " https://github.com/user/repo/tree/mybranch"
6666}
6767
68+ @test " gh: tag" {
69+ git remote set-url origin " git@github.com:user/repo.git"
70+ git tag mytag
71+ echo a > a
72+ git add a
73+ git commit -m a
74+ git checkout mytag
75+ run ../git-open
76+ assert_output " https://github.com/user/repo/tree/mytag"
77+ }
78+
6879@test " gh: non-origin remote" {
6980 git remote set-url origin " git@github.com:user/repo.git"
7081 git remote add upstream " git@github.com:upstreamorg/repo.git"
@@ -292,6 +303,17 @@ setup() {
292303 assert_output --partial " https://bitbucket.org/paulirish/crbug-extension"
293304}
294305
306+ @test " bitbucket: tag" {
307+ git remote set-url origin " git@bitbucket.org:paulirish/crbug-extension.git"
308+ git tag mytag
309+ echo a > a
310+ git add a
311+ git commit -m a
312+ git checkout mytag
313+ run ../git-open
314+ assert_output " https://bitbucket.org/paulirish/crbug-extension/src?at=mytag"
315+ }
316+
295317@test " bitbucket: non-origin remote" {
296318 # https://github.com/paulirish/git-open/pull/4
297319 git remote add bbclone " git@bitbucket.org:rwhitbeck/git-open.git"
You can’t perform that action at this time.
0 commit comments