22import { commands , Range , TextEditor , Uri , window } from 'vscode' ;
33import { GlyphChars } from '../constants' ;
44import { Container } from '../container' ;
5- import { GitUri } from '../git/gitService' ;
5+ import { GitUri , RemoteResourceType } from '../git/gitService' ;
66import { Logger } from '../logger' ;
77import { BranchesAndTagsQuickPick , CommandQuickPickItem } from '../quickpicks' ;
88import {
@@ -18,8 +18,9 @@ import { OpenInRemoteCommandArgs } from './openInRemote';
1818
1919export interface OpenFileInRemoteCommandArgs {
2020 branch ?: string ;
21- range ?: boolean ;
2221 clipboard ?: boolean ;
22+ range ?: boolean ;
23+ sha ?: string ;
2324}
2425
2526@command ( )
@@ -51,7 +52,7 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
5152 const gitUri = await GitUri . fromUri ( uri ) ;
5253 if ( ! gitUri . repoPath ) return undefined ;
5354
54- if ( args . branch === undefined ) {
55+ if ( args . branch === undefined && args . sha === undefined ) {
5556 const branch = await Container . git . getBranch ( gitUri . repoPath ) ;
5657 if ( branch === undefined || branch . tracking === undefined ) {
5758 const pick = await new BranchesAndTagsQuickPick ( gitUri . repoPath ) . show (
@@ -84,14 +85,15 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
8485 editor . selection . end . with ( { line : editor . selection . end . line + 1 } )
8586 )
8687 : undefined ;
88+ const sha = args . sha || gitUri . sha ;
8789
8890 return commands . executeCommand ( Commands . OpenInRemote , uri , {
8991 resource : {
90- type : gitUri . sha === undefined ? 'file' : 'revision' ,
92+ type : sha === undefined ? RemoteResourceType . File : RemoteResourceType . Revision ,
9193 branch : args . branch || 'HEAD' ,
9294 fileName : gitUri . getRelativePath ( ) ,
9395 range : range ,
94- sha : gitUri . sha
96+ sha : sha
9597 } ,
9698 remotes,
9799 clipboard : args . clipboard
0 commit comments