@@ -3,8 +3,13 @@ import { Commands } from '../constants';
3
3
import type { Container } from '../container' ;
4
4
import { GitUri } from '../git/gitUri' ;
5
5
import { deletedOrMissing } from '../git/models/constants' ;
6
+ import { isUncommitted } from '../git/models/reference' ;
6
7
import { RemoteResourceType } from '../git/models/remoteResource' ;
7
- import { showFileNotUnderSourceControlWarningMessage , showGenericErrorMessage } from '../messages' ;
8
+ import {
9
+ showCommitNotFoundWarningMessage ,
10
+ showFileNotUnderSourceControlWarningMessage ,
11
+ showGenericErrorMessage ,
12
+ } from '../messages' ;
8
13
import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker' ;
9
14
import { command , executeCommand } from '../system/command' ;
10
15
import { Logger } from '../system/logger' ;
@@ -89,7 +94,11 @@ export class OpenCommitOnRemoteCommand extends ActiveEditorCommand {
89
94
90
95
const blame = await this . container . git . getBlameForLine ( gitUri , blameLine , editor ?. document ) ;
91
96
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
+ ) ;
93
102
94
103
return ;
95
104
}
@@ -100,6 +109,16 @@ export class OpenCommitOnRemoteCommand extends ActiveEditorCommand {
100
109
: blame . commit . sha ;
101
110
}
102
111
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
+
103
122
void ( await executeCommand < OpenOnRemoteCommandArgs > ( Commands . OpenOnRemote , {
104
123
resource : {
105
124
type : RemoteResourceType . Commit ,
0 commit comments