mirror of
https://github.com/paulirish/git-open.git
synced 2026-09-10 07:26:15 -04:00
Bitbucket server, and minor tweaks to BROWSER (#84)
This commit is contained in:
parent
75ced59719
commit
5f61cb0b46
8
git-open
8
git-open
|
|
@ -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?
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue