Add support for bitbucket repos cloned with ssh (#174)

This commit is contained in:
Prabhu Jayakumar 2026-02-24 21:39:33 +05:30 committed by GitHub
parent f4832493a0
commit 41ebfcebe1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 0 deletions

View file

@ -212,6 +212,15 @@ elif [[ "${#pathargs[@]}" -ge 3 && ${pathargs[${#pathargs[@]} - 3]} == 'scm' ]];
pathargs=(${pathPref[@]} 'projects' ${pathargs[${#pathargs[@]} - 2]} 'repos' "${pathargs[@]:${#pathargs[@]} - 1}")
IFS='/' urlpath="${pathargs[*]}"
providerBranchRef="/browse?at=$remote_ref"
elif [[ "$domain" == *"bitbucket"* ]] && [[ $gitprotocol == 'ssh' ]]; then
# bitbucket repo cloned with ssh will not have /scm/ segment in url path
# e.g. /ppp/test-repo.git
# Build the repo url starting with 'projects' and then keep the first argument, the string 'repos', and finally the rest of the arguments.
# shellcheck disable=SC2206
pathargs=('projects' ${pathargs[${#pathargs[@]} - 2]} 'repos' "${pathargs[@]:${#pathargs[@]} - 1}")
IFS='/' urlpath="${pathargs[*]}"
providerBranchRef="/browse?at=$remote_ref"
elif [[ "${#pathargs[@]}" -ge '2' && ${pathargs[${#pathargs[@]} - 2]} == '_git' ]]; then
# Visual Studio Team Services and Team Foundation Server always have /_git/ as the second to last segment in the url path
if (( is_issue )); then

View file

@ -494,6 +494,13 @@ setup() {
assert_output "https://mybb.domain.com/root/context/projects/~first.last/repos/rrr/browse?at=refs/heads/develop"
}
@test "bitbucket: Selfhosted Bitbucket Server with ssh:// clone urls" {
# https://github.com/paulirish/git-open/pull/174
git remote set-url origin "ssh://git@bitbucket.domain.com/ppp/rrr.git"
run ../git-open
assert_output "https://bitbucket.domain.com/projects/ppp/repos/rrr"
}
##
## GitLab