Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Open file on remote" uses wrong URL to Bitbucket Server #1196

Closed
robross0606 opened this issue Nov 20, 2020 · 22 comments
Closed

"Open file on remote" uses wrong URL to Bitbucket Server #1196

robross0606 opened this issue Nov 20, 2020 · 22 comments
Assignees
Labels
bug Something isn't working verified Verified
Milestone

Comments

@robross0606
Copy link

robross0606 commented Nov 20, 2020

Issue Type: Bug

When using any of the "Open file on remote" options, the wrong URL is used to our Bitbucket server.

The browser opens to a URL like:
https://internal.company.com/projects/bitbucket/repos/scm/ncp/study-design-service

However, our actual URL would be something like:
https://internal.company.com/bitbucket/projects/NCP/repos/study-design-service/browse

How does the extension determine this URL?

Extension version: 11.0.2
VS Code version: Code 1.51.1 (e5a624b788d92b8d34d1392e4c4d9789406efe8f, 2020-11-10T23:34:32.027Z)
OS version: Windows_NT x64 10.0.19042
Bitbucket version: 7.5.1

System Info
Item Value
CPUs Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz (12 x 2592)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 31.75GB (16.60GB free)
Process Argv --folder-uri file:///c%3A/Code/ncp/study-design-service --crash-reporter-id 94973ead-12e5-4b7d-b033-6d97d3464d2b
Screen Reader no
VM 0%
@robross0606
Copy link
Author

robross0606 commented Nov 20, 2020

It appears like part of the problem is that something is misinterpreting my $repoBase variable.

The http link to our git repo would be something like:
https://internal.company.com/bitbucket/scm/ncp/study-design-service.git

The /scm portion gets included in $repoBase but that is not part of the path to the web interface URL to Bitbucket. Is there any way to control how this is parsed from the git URL?

@robross0606 robross0606 changed the title Open file on remote uses wrong URL "Open file on remote" uses wrong URL to Bitbucket Server Nov 20, 2020
@mgallagher
Copy link

You might try playing with the gitlens.remotes setting to have more control over the URL - https://github.com/eamodio/vscode-gitlens#custom-remotes-settings

The bitbucket-server remote config seems to assume a different URL pattern than what you need:

https://github.com/eamodio/vscode-gitlens/blob/b0fab09dd9325228ba0a1f602f27aff0fca1f484/src/git/remotes/bitbucket-server.ts#L36-L41

@robross0606
Copy link
Author

robross0606 commented Nov 24, 2020

@mgallagher, it isn't possible to do what you suggest because gitlens misinterprets the git address when coming up with the available variables for custom remotes. Things like ${repoBase} are incorrect. You cannot resolve the problem with custom remotes if the component parts provided by gitlens are wrong.

What I'm seeing is that this is already called out in another ticket and is due to gitlens misinterpreting a git address that has a context base.

@eamodio
Copy link
Member

eamodio commented Nov 28, 2020

Could someone provide a PR here? I don't have a Bitbucket server to test with.

@eamodio eamodio added help wanted Want community input and/or pull request bug Something isn't working labels Nov 28, 2020
@eamodio eamodio added this to the Backlog milestone Nov 28, 2020
@guaiamum
Copy link

guaiamum commented Dec 2, 2020

Experiencing a similar issue, the remote file url returned is encoding / as %2F from baseURL onwards... replacing the encoded chars yields a right url...

@eamodio
Copy link
Member

eamodio commented Dec 2, 2020

Can you please try this in the GitLens insiders edition? As I've fixed encoding issues there. Be sure to disable/uninstall the stable version of GitLens first.

You can install the insiders edition from here.

@guaiamum
Copy link

guaiamum commented Dec 2, 2020

Nice, it worked, thanks :)

@MaerF0x0
Copy link

@robross0606 can you try GitLens insiders edition to confirm bug fixed? ^^

@robross0606
Copy link
Author

robross0606 commented Jan 26, 2021

@robross0606 can you try GitLens insiders edition to confirm bug fixed? ^^

I can say with fair certainty that, no, this is not at all fixed.

With the insider version, it is opening on remote as:

https://server.name/projects/bitbucket/repos/scm/ncp/study-design-service/browse/index.js?at=feature/SD-165_amqp-export-completed

when the real URL is:

https://server.name/bitbucket/projects/NCP/repos/study-design-service/browse/index.js?at=feature/SD-165_amqp-export-completed

It is still getting thoroughly confused if the server has a context path. In this case, the actual server base path is http://server.name/bitbucket.

@robross0606
Copy link
Author

Part of the confusion here may be that @guaiamum's issue is different than mine. As far as I can tell, encoding is not my issue at all. I've confirmed by playing with gitlens.remotes that the component parts of the URL are indeed incorrectly parsed when the URL has a context path.

@robross0606
Copy link
Author

robross0606 commented Jan 26, 2021

Maybe it would help if I broke down the URL into accurate component parts:

https://server.name/bitbucket/projects/NCP/repos/study-design-service/browse/index.js?at=feature/SD-165_amqp-export-completed

Base server URL: https://server.name/bitbucket/
Project context: projects/NCP/
Repo context: repos/study-design-service/
Action: browse/index.js?at=feature/SD-165_amqp-export-completed

Now let's look at how it compiles the bad URL:

https://server.name/projects/bitbucket/repos/scm/ncp/study-design-service/browse/index.js?at=feature/SD-165_amqp-export-completed

Base server URL: https://server.name/ INCORRECT
Project context: projects/bitbucket/ INCORRECT
Repo context: repos/scm/ncp/study-design-service/ INCORRECT
Action: browse/index.js?at=feature/SD-165_amqp-export-completed

The URL used by Gitlens is wrong in most ways. The most egregious is the misinterpretation of the base server URL. But the inclusion of /scm/ is baffling. I have yet to see that path component anywhere when browsing through our Bitbucket server.

@eamodio
Copy link
Member

eamodio commented Jan 27, 2021

@robross0606 What are you using for you gitlens.remotes configuration and was is the actual remote url specified in your git config?

@eamodio eamodio added the needs-more-info Needs further information, steps, details, etc. label Jan 27, 2021
@robross0606
Copy link
Author

robross0606 commented Jan 27, 2021

@robross0606 What are you using for you gitlens.remotes configuration and was is the actual remote url specified in your git config?

I do not have gitlens.remotes specified in either my user or workspace configurations. So current behavior is default.

Raw git configuration is:

	url = https://server.name/bitbucket/scm/ncp/study-design-service.git

Now I see where scm is coming from, but Bitbucket does not use that element for web browsing. It results in a 404 error.

@robross0606
Copy link
Author

The first major problem with gitlens is that it tries to guess the base URL of the server and gets it wrong. Not every server base address stops at the first / if you're using context paths. This is why Atlassian itself allows you to configure the base URL of your server in their own vscode plugin:
image

@eamodio eamodio self-assigned this Jan 29, 2021
@eamodio eamodio modified the milestones: Backlog, Soon™ Jan 29, 2021
@eamodio eamodio removed help wanted Want community input and/or pull request needs-more-info Needs further information, steps, details, etc. labels Jan 29, 2021
@eamodio
Copy link
Member

eamodio commented Jan 29, 2021

@robross0606

Can you please verify this fix in tomorrow's insiders edition?

You can install the insiders edition from here. Be sure to disable/uninstall the stable version of GitLens first.

To get it to work, you will need to add something like the following to your settings.json

"gitlens.remotes": [
	{
		"type": "BitbucketServer",
		"regex": "^(server.name/bitbucket)/scm/(.*)$",
	},
]

@eamodio eamodio added needs-verification Request for community verification pending-release Resolved but not yet released to the stable edition labels Jan 29, 2021
@robross0606
Copy link
Author

Why was this closed without waiting for a response? NO it is not at all fixed. Not even a little. That didn't help anything at all.

@robross0606
Copy link
Author

Okay, this worked I think:

    { "type": "BitbucketServer", "regex": "^(.*/bitbucket)/scm/(.*)$" }

A bit clunky, but it worked.

@eamodio
Copy link
Member

eamodio commented Jan 29, 2021

@robross0606 I think the words you are failing to find are "Thank You". To show at least a modicum of appreciation or gratitude for my time spent looking into and fixing your issue. I honestly shouldn't be surprised given your tone previously (shame on me I guess), but I was certainly hoping that my efforts would at least be appreciated in kind.

Please remember this project (and most open-source in general) is volunteer work. I build and maintain GitLens in my free time (giving up sleep and family time too often) and offer it for FREE.

@robross0606
Copy link
Author

This goes both ways, man. I've spent plenty of time debugging this as well to point out the issue with details about why it is failing. I doubt this is "my" issue. We have a vanilla Bitbucker Server installation here. Thank you.

@eamodio
Copy link
Member

eamodio commented Jan 29, 2021

How does it go both ways? Was I rude and ungrateful to you? No, I saw that, despite your tone, you put in effort to help get to the bottom of the issue, so I in kind spent time to come up with a solution. Check your entitlement.

@robross0606
Copy link
Author

Wow, okay.

@eamodio
Copy link
Member

eamodio commented Jan 29, 2021

Really? OK, then.
image

@gitkraken gitkraken locked and limited conversation to collaborators Jan 29, 2021
@eamodio eamodio added verified Verified and removed needs-verification Request for community verification labels Feb 1, 2021
@eamodio eamodio modified the milestones: Soon™, Shipped Feb 3, 2021
@eamodio eamodio removed the pending-release Resolved but not yet released to the stable edition label Feb 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working verified Verified
Projects
None yet
Development

No branches or pull requests

5 participants