From 8f46408bb5e554a22d782c076c6fba630355f6ce Mon Sep 17 00:00:00 2001 From: Erik Eng Date: Sat, 3 Oct 2026 00:05:47 +0200 Subject: [PATCH] bitbucket: link branches to /branch/ view --- git-open | 2 ++ test/git-open.bats | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/git-open b/git-open index a367db6..c13b1e4 100755 --- a/git-open +++ b/git-open @@ -199,7 +199,9 @@ else fi if [[ "$domain" == 'bitbucket.org' ]]; then + # Branches have a dedicated view; tags and detached commits use the source view providerBranchRef="/src/$remote_ref" + [[ -n "${upstream_branch:-$branch}" ]] && providerBranchRef="/branch/$remote_ref" elif [[ "${#pathargs[@]}" -ge 3 && ${pathargs[${#pathargs[@]} - 3]} == 'scm' ]]; then # Bitbucket server always has /scm/ as the third to last segment in the url path, e.g. /scm/ppp/test-repo.git # Anything before the 'scm' is part of the server's root context diff --git a/test/git-open.bats b/test/git-open.bats index e891be5..9430be7 100755 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -398,7 +398,7 @@ setup() { git checkout -B "devel" run ../git-open refute_output --partial "//kisom" - assert_output "https://bitbucket.org/kisom/consbri/src/devel" + assert_output "https://bitbucket.org/kisom/consbri/branch/devel" } @test "bitbucket: open source view with a slash/branch" { @@ -407,7 +407,7 @@ setup() { git remote set-url origin "https://bitbucket.org/guyzmo/git-repo.git" git checkout -B "bugfix/conftest_fix" run ../git-open - assert_output "https://bitbucket.org/guyzmo/git-repo/src/bugfix/conftest_fix" + assert_output "https://bitbucket.org/guyzmo/git-repo/branch/bugfix/conftest_fix" } @test "bitbucket: ssh:// clone urls" {