Skip to content

Conversation

@amtoaer
Copy link
Contributor

@amtoaer amtoaer commented Nov 5, 2025

Closes #41995

Release Notes:

  • Fixed support for self-hosted Bitbucket

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Nov 5, 2025
@maxdeviant maxdeviant changed the title git: Fix self-hosted BitBucket url can not be parsed git: Fix self-hosted BitBucket URL can not be parsed Nov 5, 2025
@amtoaer amtoaer force-pushed the fix_bitbucket_selfhosted branch from 6f9f0a7 to 549d624 Compare November 6, 2025 07:01
@lesha-co
Copy link

lesha-co commented Nov 6, 2025

Thank you for a quick reply!
I'm not sure if self-hosted BitBucket uses different URLs from bitbucket.org but it's almost right, see:

I have:

> git config --get remote.origin.url             
ssh://git@{domain}/{project}/{repo}.git

where {domain} is bitbucket.company.tld

After running "get permalink" I get:

https://{domain}/{project}/{repo}/src/{hash}/{path}#lines-4

But when visiting the desired file in web interface I have this URL:

https://{domain}/projects/{project}/repos/{repo}/browse/{path}?at={hash}#4

@amtoaer
Copy link
Contributor Author

amtoaer commented Nov 6, 2025

@lesha-co Got it. I can change the URL logic, but I'm not sure if self-hosted Bitbucket requires a special URL or if the original code was just wrong. I'd like to confirm this, but I'm still blocked from creating a workspace on bitbucket.org. :(

If you don't mind, could you register a Bitbucket.org account and confirm the correct URL structure?

@lesha-co
Copy link

lesha-co commented Nov 6, 2025

Sure! I've done it and BitBucket Cloud gave me the link that conforms to the pattern Zed uses.

What I've found: Atlassian Community forums mention that BitBucket Server indeed uses different pattern see this post

There is an issue though, they have different paths for repos under "projects" and under users. I'm not sure how to solve it solely relying on git remote URL:

https://<DOMAIN>/projects/<PROJECT>/repos/<REPO_NAME>/browse/<FILE_PATH>/<FILE_NAME>#<LINE_NUMBER>
https://<DOMAIN>/users   /<USER>   /repos/<REPO_NAME>/browse/<FILE_PATH>/<FILE_NAME>#<LINE_NUMBER>

@lesha-co
Copy link

lesha-co commented Nov 6, 2025

Here's relevant part of GitLens extension in VSCode:

https://github.com/gitkraken/vscode-gitlens/blob/a6e3c6fbb255116507eaabaa9940c192ed7bb0e1/src/git/remotes/bitbucket-server.ts#L68

They seem to ignore the /users/, can't find it anywhere so I guess we can go ahead and ignore it too

@amtoaer
Copy link
Contributor Author

amtoaer commented Nov 6, 2025

Okay, I've adapted the logic to support the commit permalink, path permalink, and pull request link for self-hosted Bitbucket instances.

Additionally, it appears the line-number format for bitbucket.org was also incorrect. Following the official Atlassian documentation, the correct format for specifying line ranges is #{filename}-{start}:{end} instead of the old #lines-{start}:{end}.

@amtoaer amtoaer changed the title git: Fix self-hosted BitBucket URL can not be parsed git: Support self-hosted Bitbucket and correct line number format for public instance Nov 6, 2025
@lesha-co
Copy link

lesha-co commented Nov 6, 2025

No, it's another difference between Cloud and Server
see, this is a valid URL:

https://bitbucket.org/lesha2/reponame/src/aa845f08fb92860fdb13fdd6645e039e6773a22d/.gitignore#lines-4

@lesha-co
Copy link

lesha-co commented Nov 6, 2025

Update: I tried 451110f and it works for me. Great, thanks!

just remember that #lines-123 is valid for Cloud and #123 is valid for Server

@amtoaer
Copy link
Contributor Author

amtoaer commented Nov 6, 2025

Ah, it seems their official documentation might be a bit out of date. The page at https://support.atlassian.com/bitbucket-cloud/docs/hyperlink-to-source-code-in-bitbucket/ only explicitly mentions the #{filename}-{line} format. I will revert that part of the change now.

@amtoaer
Copy link
Contributor Author

amtoaer commented Nov 6, 2025

So, to confirm the current state: Bitbucket Cloud uses #lines-{start}:{end} but Bitbucket Server uses the simpler #start-end? Is that right?

@amtoaer amtoaer marked this pull request as draft November 6, 2025 15:57
@lesha-co
Copy link

lesha-co commented Nov 6, 2025

Yes, that is correct :)

@amtoaer amtoaer marked this pull request as ready for review November 6, 2025 16:14
@amtoaer amtoaer changed the title git: Support self-hosted Bitbucket and correct line number format for public instance git: Fix support for self-hosted Bitbucket Nov 6, 2025
@cole-miller
Copy link
Member

Thanks!

@cole-miller cole-miller merged commit 35c5815 into zed-industries:main Nov 10, 2025
26 checks passed
@JosephTLyons JosephTLyons moved this to 🚢 Shipped by Community in Git board Nov 19, 2025
11happy pushed a commit to 11happy/zed that referenced this pull request Dec 1, 2025
Closes zed-industries#41995

Release Notes:

- Fixed support for self-hosted Bitbucket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

Status: 🚢 Shipped by Community

Development

Successfully merging this pull request may close these issues.

Git: fails to create a permalink to the line

3 participants