Browse Source

Fixes #1447 - adds remote branch support

main
Eric Amodio 3 years ago
parent
commit
2b8a300703
2 changed files with 23 additions and 7 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +22
    -7
      src/commands/openFileOnRemote.ts

+ 1
- 0
CHANGELOG.md View File

@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [1447](https://github.com/eamodio/vscode-gitlens/issues/1447) - _Open File on Remote From..._ is missing remote branches
- Fixes [1442](https://github.com/eamodio/vscode-gitlens/issues/1442) - Interactive Rebase Editor not opened but plain text file when called from terminal
- Fixes [1439](https://github.com/eamodio/vscode-gitlens/issues/1439) - Copying a remote file URL for a file on Azure DevOps does not work — thanks to [PR #1440](https://github.com/eamodio/vscode-gitlens/pull/1440) by Lee C. ([MeltingMosaic](https://github.com/MeltingMosaic))
- Fixes [1445](https://github.com/eamodio/vscode-gitlens/issues/1439) - Improve documentation for hiding default added editor actions

+ 22
- 7
src/commands/openFileOnRemote.ts View File

@ -14,7 +14,7 @@ import { UriComparer } from '../comparers';
import { BranchSorting, TagSorting } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { GitRevision, RemoteResourceType } from '../git/git';
import { GitBranch, GitRevision, RemoteResourceType } from '../git/git';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { ReferencePicker } from '../quickpicks';
@ -106,7 +106,7 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand {
args = { range: true, ...args };
try {
const remotes = await Container.git.getRemotes(gitUri.repoPath);
let remotes = await Container.git.getRemotes(gitUri.repoPath);
const range =
args.range && editor != null && UriComparer.equals(editor.document.uri, uri)
? new Range(
@ -120,9 +120,14 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand {
if (args.branchOrTag == null && sha != null && !GitRevision.isSha(sha) && remotes.length !== 0) {
const [remoteName, branchName] = Strings.splitSingle(sha, '/');
if (branchName != null && remotes.some(r => r.name === remoteName)) {
args.branchOrTag = branchName;
sha = undefined;
if (branchName != null) {
const remote = remotes.find(r => r.name === remoteName);
if (remote != null) {
args.branchOrTag = branchName;
sha = undefined;
remotes = [remote];
}
}
}
@ -143,7 +148,7 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand {
allowEnteringRefs: true,
autoPick: true,
// checkmarks: false,
filter: { branches: b => b.tracking != null },
filter: { branches: b => b.remote || b.tracking != null },
picked: args.branchOrTag,
sort: {
branches: { current: true, orderBy: BranchSorting.DateDesc },
@ -153,7 +158,17 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand {
);
if (pick == null) return;
if (pick.refType === 'branch' || pick.refType === 'tag') {
if (pick.refType === 'branch') {
if (pick.remote) {
const remoteName = GitBranch.getRemote(pick.name);
const remote = remotes.find(r => r.name === remoteName);
if (remote != null) {
remotes = [remote];
}
}
args.branchOrTag = pick.remote ? GitBranch.getNameWithoutRemote(pick.name) : pick.name;
sha = undefined;
} else if (pick.refType === 'tag') {
args.branchOrTag = pick.ref;
sha = undefined;
} else {

Loading…
Cancel
Save