Skip to content

Commit

Permalink
Fixes #1006 - open files as revision for bitbucket
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Feb 1, 2021
1 parent cf5a394 commit 6effd60
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions src/quickpicks/remoteProviderPicker.ts
Expand Up @@ -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,
Expand Down Expand Up @@ -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)));
Expand Down

0 comments on commit 6effd60

Please sign in to comment.