|
2 | 2 | import { Disposable, env, Uri, window } from 'vscode'; |
3 | 3 | import { Commands, OpenOnRemoteCommandArgs } from '../commands'; |
4 | 4 | import { GlyphChars } from '../constants'; |
| 5 | +import { Container } from '../container'; |
5 | 6 | import { |
6 | 7 | getNameFromRemoteResource, |
7 | 8 | GitBranch, |
@@ -47,6 +48,26 @@ export class CopyOrOpenRemoteCommandQuickPickItem extends CommandQuickPickItem { |
47 | 48 | if (GitBranch.getRemote(resource.ref2) === this.remote.name) { |
48 | 49 | resource = { ...resource, ref2: GitBranch.getNameWithoutRemote(resource.ref2) }; |
49 | 50 | } |
| 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 | + } |
50 | 71 | } |
51 | 72 |
|
52 | 73 | void (await (this.clipboard ? this.remote.provider.copy(resource) : this.remote.provider.open(resource))); |
|
0 commit comments