Skip to content

Commit 6effd60

Browse files
committed
Fixes #1006 - open files as revision for bitbucket
1 parent cf5a394 commit 6effd60

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
3838

3939
### Fixed
4040

41+
- Fixes [#1006](https://github.com/eamodio/vscode-gitlens/issues/1006) - "GitLens: Open File on Remote" opens wrong Bitbucket URL
4142
- Fixes [#901](https://github.com/eamodio/vscode-gitlens/issues/901) - Bitbucket Server fails when url = https://DOMAIN/stash/scm/PROJECT/REPO.git
4243
- Fixes [#1354](https://github.com/eamodio/vscode-gitlens/issues/1354) - Stuck after merge a branch with a single quote in the name
4344
- 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)

src/quickpicks/remoteProviderPicker.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { Disposable, env, Uri, window } from 'vscode';
33
import { Commands, OpenOnRemoteCommandArgs } from '../commands';
44
import { GlyphChars } from '../constants';
5+
import { Container } from '../container';
56
import {
67
getNameFromRemoteResource,
78
GitBranch,
@@ -47,6 +48,26 @@ export class CopyOrOpenRemoteCommandQuickPickItem extends CommandQuickPickItem {
4748
if (GitBranch.getRemote(resource.ref2) === this.remote.name) {
4849
resource = { ...resource, ref2: GitBranch.getNameWithoutRemote(resource.ref2) };
4950
}
51+
} else if (
52+
resource.type === RemoteResourceType.File &&
53+
resource.branchOrTag != null &&
54+
(this.remote.provider.id === 'bitbucket' || this.remote.provider.id === 'bitbucket-server')
55+
) {
56+
// HACK ALERT
57+
// Since Bitbucket can't support branch names in the url (other than with the default branch),
58+
// turn this into a `Revision` request
59+
const { branchOrTag } = resource;
60+
const branchesOrTags = await Container.git.getBranchesAndOrTags(this.remote.repoPath, {
61+
filter: {
62+
branches: b => b.name === branchOrTag,
63+
tags: b => b.name === branchOrTag,
64+
},
65+
});
66+
67+
const sha = branchesOrTags?.[0].sha;
68+
if (sha) {
69+
resource = { ...resource, type: RemoteResourceType.Revision, sha: sha };
70+
}
5071
}
5172

5273
void (await (this.clipboard ? this.remote.provider.copy(resource) : this.remote.provider.open(resource)));

0 commit comments

Comments
 (0)