Skip to content

Commit 0c03c6f

Browse files
committed
Adds better error messaging
1 parent 9233e27 commit 0c03c6f

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/commands/openCommitOnRemote.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ import { Commands } from '../constants';
33
import type { Container } from '../container';
44
import { GitUri } from '../git/gitUri';
55
import { deletedOrMissing } from '../git/models/constants';
6+
import { isUncommitted } from '../git/models/reference';
67
import { RemoteResourceType } from '../git/models/remoteResource';
7-
import { showFileNotUnderSourceControlWarningMessage, showGenericErrorMessage } from '../messages';
8+
import {
9+
showCommitNotFoundWarningMessage,
10+
showFileNotUnderSourceControlWarningMessage,
11+
showGenericErrorMessage,
12+
} from '../messages';
813
import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker';
914
import { command, executeCommand } from '../system/command';
1015
import { 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

Comments
 (0)