Skip to content

Bitbucket Server remote - "scm/" path prefix not removed, possible regression from #767? #3218

@Coteh

Description

@Coteh

Description

Hi, I've been having issues getting my Bitbucket Server remote setup with the most recent version of GitLens. After searching through related issues in the issue tracker, what I could best describe is that I've been experiencing a combination of #267 and #692.

My remote URL look something like this: https://domain/scm/web/someRepo.git, assuming project name is "web" and repo name is "someRepo". From what I understand, the original fix for #267 would work if my URL looked like: https://domain/web/someRepo.git. However, because I have "scm/" prefix as well, this ends up turning repoBase into scm instead of web, and repoPath becomes web/someRepo instead of someRepo.

From what I gather, PR #767 (722a7d2) originally fixed this issue for Bitbucket Server URLs, by providing a special case for this scm/ prefix. However, I noticed in the following change from 5 months ago (ba0a6c8#diff-3df44eca214dcc6e95c893331e04e784c958b3167e664a01dd724acb68cdefefR54), the "scm/" handling was moved into a new splitPath override method, but the part that does the actual splitting splits the original path instead of the modified path (without the "scm/"), which is not what the previous version did. This I believe is causing the "scm/" to still appear in transformed Bitbucket Server URLs, and also any project name over 3 characters long is also mangled because of this. I have more details in my Reproduction Steps below.

I already have a fix for this here: https://github.com/Coteh/vscode-gitlens/commit/0ba49ab459ab0e4eb17cc5f6c30b9ec48d18c499
I will put up a PR for this shortly if that's ok?

Reproduction Steps

If you need them, here are some reproduction steps that you can do to replicate the issue on your end. (I guess you'll need a Bitbucket Server as well to test, or something that mimics it)

  1. Use the following config in user settings (modify domain and name to match your remote)
{
    "gitlens.integrations.enabled": true,
    "gitlens.remotes": [
        {
            "domain": "domain",
            "type": "BitbucketServer",
            "name": "My Server",
            "protocol": "https"
        }
    ]
}
  1. Attempt to open any remote link (such as when clicking on the globe icon when the commit overlay appears on a line)
  2. Remote link should properly contain a structure like projects/web/repos/someRepo. Instead it ends up being projects/scm/repos/web/someRepo.

This is further exacerbated when a project name is more than 3 characters long. The index that splitPath method inside bitbucket-server uses when splitting is going off of the new transformed path without scm/ prefix, but it's being applied to the original path with scm/ prefix in it. This will cause project names to have a slash and other extra characters and the repo name to be cut off. For example, if my project name was "tests", the transformed path would contain something like projects/scm/t/repos/sts/someRepo, the "e" would be cut off because that's where the index was in the transformed path "tests/someRepo".

GitLens Version

v14.9.0

VS Code Version

Version: 1.87.2 (Universal)
Commit: 863d2581ecda6849923a2118d93a088b0745d9d6
Date: 2024-03-08T15:21:31.043Z
Electron: 27.3.2
ElectronBuildId: 26836302
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin arm64 23.2.0

Git Version

git version 2.44.0

Logs, Screenshots, Screen Captures, etc

No response

Metadata

Metadata

Assignees

Labels

integration-bitbucketIssues or features related to Bitbucket integrationsneeds-verificationRequest for verificationpending-releaseResolved but not yet released to the stable editiontriageNeeds to be looked at

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions