Bitbucket server, and minor tweaks to BROWSER (#84)

This commit is contained in:
Dave Wikoff 2017-06-18 23:08:56 -04:00 committed by Paul Irish
parent 75ced59719
commit 5f61cb0b46
2 changed files with 9 additions and 8 deletions

View file

@ -50,14 +50,16 @@ IFS='/' pathargs=($urlpath)
providerBranchRef="tree/$branch"
if [[ "$server" == 'bitbucket.org' ]]; then
# Bitbucket, see https://github.com/paulirish/git-open/issues/80 for why ?at is needed.
providerBranchRef="src?at=$branch"
# Bitbucket, see https://github.com/paulirish/git-open/issues/80 for why the ref and the ?at is needed.
ref=$(git rev-parse --short $branch)
providerBranchRef="src/$ref?at=$branch"
elif [[ ${pathargs[0]} == 'scm' ]]; then
# Bitbucket server, which starts with 'scm'
# Replace the first element, 'scm', with 'projects'. Keep the first argument, the string 'repos', and finally the rest of the arguments.
pathargs=('projects' ${pathargs[1]} 'repos' "${pathargs[@]:2}")
IFS='/' urlpath="${pathargs[*]}"
providerBranchRef="browse?at=$branch"
ref=$(git rev-parse --short $branch)
providerBranchRef="browse/$ref?at=$branch"
fi
# @TODO: support non-https?

View file

@ -123,11 +123,9 @@ setup() {
git remote set-url origin "https://bitbucket.org/kisom/consbri.git"
git checkout -B "devel"
run ../git-open
assert_output "https://bitbucket.org/kisom/consbri/src/devel"
ref=$(git rev-parse --short devel)
assert_output "https://bitbucket.org/kisom/consbri/src/$ref?at=devel"
refute_output --partial "//"
# alternative destination..
# assert_output "https://bitbucket.org/kisom/consbri/src/?at=devel"
}
@test "bitbucket: open source view with a slash/branch" {
@ -167,7 +165,8 @@ setup() {
git remote set-url origin "https://user@bitbucket.example.com/scm/ppp/test-repo.git"
git checkout -B "bb-server"
run ../git-open
assert_output "https://bitbucket.example.com/projects/ppp/repos/test-repo/browse?at=bb-server"
ref=$(git rev-parse -q --short HEAD)
assert_output "https://bitbucket.example.com/projects/ppp/repos/test-repo/browse/$ref?at=bb-server"
}