@@ -3,8 +3,13 @@ import { Commands } from '../constants';
33import type { Container } from '../container' ;
44import { GitUri } from '../git/gitUri' ;
55import { deletedOrMissing } from '../git/models/constants' ;
6+ import { isUncommitted } from '../git/models/reference' ;
67import { RemoteResourceType } from '../git/models/remoteResource' ;
7- import { showFileNotUnderSourceControlWarningMessage , showGenericErrorMessage } from '../messages' ;
8+ import {
9+ showCommitNotFoundWarningMessage ,
10+ showFileNotUnderSourceControlWarningMessage ,
11+ showGenericErrorMessage ,
12+ } from '../messages' ;
813import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker' ;
914import { command , executeCommand } from '../system/command' ;
1015import { Logger } from '../system/logger' ;
@@ -89,7 +94,11 @@ export class OpenCommitOnRemoteCommand extends ActiveEditorCommand {
8994
9095 const blame = await this . container . git . getBlameForLine ( gitUri , blameLine , editor ?. document ) ;
9196 if ( blame == null ) {
92- void showFileNotUnderSourceControlWarningMessage ( 'Unable to open commit on remote provider' ) ;
97+ void showFileNotUnderSourceControlWarningMessage (
98+ args ?. clipboard
99+ ? 'Unable to copy the commit SHA'
100+ : 'Unable to open the commit on the remote provider' ,
101+ ) ;
93102
94103 return ;
95104 }
@@ -100,6 +109,16 @@ export class OpenCommitOnRemoteCommand extends ActiveEditorCommand {
100109 : blame . commit . sha ;
101110 }
102111
112+ if ( args . sha == null || args . sha === deletedOrMissing || isUncommitted ( args . sha ) ) {
113+ void showCommitNotFoundWarningMessage (
114+ args ?. clipboard
115+ ? 'Unable to copy the commit SHA'
116+ : 'Unable to open the commit on the remote provider' ,
117+ ) ;
118+
119+ return ;
120+ }
121+
103122 void ( await executeCommand < OpenOnRemoteCommandArgs > ( Commands . OpenOnRemote , {
104123 resource : {
105124 type : RemoteResourceType . Commit ,
0 commit comments