Merge pull request #130 from orestisf1993/tags-commits

Support opening current tag / commit
This commit is contained in:
Dave Wikoff 2018-09-17 11:08:39 -04:00 committed by GitHub
commit 4ca19904a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View file

@ -153,8 +153,8 @@ function getConfig() {
domain=$(getConfig "domain")
protocol=$(getConfig "protocol")
# Get current branch
branch=${2:-$(git symbolic-ref -q --short HEAD)}
# Get current branch / tag / commit
branch=${2:-$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match 2>/dev/null || git rev-parse HEAD)}
# Split arguments on '/'
IFS='/' read -r -a pathargs <<<"$urlpath"

View file

@ -65,6 +65,17 @@ setup() {
assert_output "https://github.com/user/repo/tree/mybranch"
}
@test "gh: tag" {
git remote set-url origin "git@github.com:user/repo.git"
git tag mytag
echo a > a
git add a
git commit -m a
git checkout mytag
run ../git-open
assert_output "https://github.com/user/repo/tree/mytag"
}
@test "gh: non-origin remote" {
git remote set-url origin "git@github.com:user/repo.git"
git remote add upstream "git@github.com:upstreamorg/repo.git"
@ -292,6 +303,17 @@ setup() {
assert_output --partial "https://bitbucket.org/paulirish/crbug-extension"
}
@test "bitbucket: tag" {
git remote set-url origin "git@bitbucket.org:paulirish/crbug-extension.git"
git tag mytag
echo a > a
git add a
git commit -m a
git checkout mytag
run ../git-open
assert_output "https://bitbucket.org/paulirish/crbug-extension/src?at=mytag"
}
@test "bitbucket: non-origin remote" {
# https://github.com/paulirish/git-open/pull/4
git remote add bbclone "git@bitbucket.org:rwhitbeck/git-open.git"