Skip to content

Fix Bitbucket branch and commit URLs - #237

Open
uvw wants to merge 1 commit into
paulirish:masterfrom
uvw:fix/bitbucket-branch-and-commit-urls
Open

Fix Bitbucket branch and commit URLs#237
uvw wants to merge 1 commit into
paulirish:masterfrom
uvw:fix/bitbucket-branch-and-commit-urls

Conversation

@uvw

@uvw uvw commented Sep 4, 2026

Copy link
Copy Markdown

What

On bitbucket.org, git open produced wrong URLs for commits and for branches whose name contains a slash.

Before (broken) After (correct)
Commit /commit/<sha> (404) /commits/<sha>
Slash branch /src/release/9.12.x (404) /src/HEAD/?at=release%2F9.12.x
Plain branch/tag /src/<ref> /src/<ref> (unchanged)

Why the slash-branch fix looks the way it does

/src/<ref> 404s when the branch name has a slash, because Bitbucket reads the first path segment (release) as the ref and 9.12.x as a file path. Bitbucket disambiguates via the ?at=<ref> query param with a valid commit-ish in the path. HEAD works as a repo-agnostic placeholder, so no commit SHA lookup is needed.

Verified live against atlassian/aui (the page header reads source:release/9.12.x). Plain refs keep the simpler /src/<ref>.

Examples

Commit:

  • Correct → https://bitbucket.org/atlassian/aui/commits/c0635692ee698f24bd909427a2ae3575915f466e
  • Broken (404) → https://bitbucket.org/atlassian/aui/commit/c0635692ee698f24bd909427a2ae3575915f466e

Slash branch:

  • Correct → https://bitbucket.org/atlassian/aui/src/HEAD/?at=release%2F9.12.x
  • Broken (404) → https://bitbucket.org/atlassian/aui/src/release/9.12.x

Scope

Both changes are gated on $domain == 'bitbucket.org', so GitHub, AWS CodeCommit,
Bitbucket Server (/scm/, /browse?at=), and every other forge are unaffected.

Tests

bats test/ passes. Adds coverage for the Bitbucket commit URL and the
slash-branch source view; the existing plain-branch and tag cases are unchanged.

@uvw
uvw marked this pull request as ready for review September 4, 2026 01:59
Bitbucket Cloud needs different paths than the shared defaults:

- Commits live at /commits/<sha>, not /commit/<sha> (the singular 404s).
- /src/<ref> 404s when the branch name contains a slash (e.g.
  release/9.12.x), because Bitbucket reads the first path segment as the
  ref. Browse via /src/HEAD/?at=<ref> with the slash percent-encoded;
  plain refs keep the simpler /src/<ref>.

Both changes are scoped to bitbucket.org, so GitHub, CodeCommit, and
Bitbucket Server are unaffected. Adds bats coverage for the commit URL
and the slash-branch source view.
@uvw
uvw force-pushed the fix/bitbucket-branch-and-commit-urls branch from 6819324 to 7b34795 Compare September 4, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant