diff --git a/CHANGELOG.md b/CHANGELOG.md index ad2e1d1..8ae48f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Fixed +- Fixes [#1006](https://github.com/eamodio/vscode-gitlens/issues/1006) - "GitLens: Open File on Remote" opens wrong Bitbucket URL - Fixes [#901](https://github.com/eamodio/vscode-gitlens/issues/901) - Bitbucket Server fails when url = https://DOMAIN/stash/scm/PROJECT/REPO.git - Fixes [#1354](https://github.com/eamodio/vscode-gitlens/issues/1354) - Stuck after merge a branch with a single quote in the name - Fixes [#863](https://github.com/eamodio/vscode-gitlens/issues/863) - Pulling all repositories doesn't work unless built-in Git knows about the repo (requires VS Code v1.53 or later) diff --git a/src/quickpicks/remoteProviderPicker.ts b/src/quickpicks/remoteProviderPicker.ts index 8c6bec7..9412147 100644 --- a/src/quickpicks/remoteProviderPicker.ts +++ b/src/quickpicks/remoteProviderPicker.ts @@ -2,6 +2,7 @@ import { Disposable, env, Uri, window } from 'vscode'; import { Commands, OpenOnRemoteCommandArgs } from '../commands'; import { GlyphChars } from '../constants'; +import { Container } from '../container'; import { getNameFromRemoteResource, GitBranch, @@ -47,6 +48,26 @@ export class CopyOrOpenRemoteCommandQuickPickItem extends CommandQuickPickItem { if (GitBranch.getRemote(resource.ref2) === this.remote.name) { resource = { ...resource, ref2: GitBranch.getNameWithoutRemote(resource.ref2) }; } + } else if ( + resource.type === RemoteResourceType.File && + resource.branchOrTag != null && + (this.remote.provider.id === 'bitbucket' || this.remote.provider.id === 'bitbucket-server') + ) { + // HACK ALERT + // Since Bitbucket can't support branch names in the url (other than with the default branch), + // turn this into a `Revision` request + const { branchOrTag } = resource; + const branchesOrTags = await Container.git.getBranchesAndOrTags(this.remote.repoPath, { + filter: { + branches: b => b.name === branchOrTag, + tags: b => b.name === branchOrTag, + }, + }); + + const sha = branchesOrTags?.[0].sha; + if (sha) { + resource = { ...resource, type: RemoteResourceType.Revision, sha: sha }; + } } void (await (this.clipboard ? this.remote.provider.copy(resource) : this.remote.provider.open(resource)));