1
+ import { window } from 'vscode' ;
1
2
import { Commands } from '../constants.commands' ;
2
3
import type { Container } from '../container' ;
3
4
import type { GraphWebviewShowingArgs } from '../plus/webviews/graph/registration' ;
4
- import { command } from '../system/vscode/command' ;
5
+ import { command , executeCoreCommand } from '../system/vscode/command' ;
5
6
import type { HomeWebviewShowingArgs } from '../webviews/home/registration' ;
6
7
import type { CommandContext } from './base' ;
7
8
import { Command } from './base' ;
@@ -36,6 +37,22 @@ export class ShowViewCommand extends Command {
36
37
return this . execute ( context , ...args ) ;
37
38
}
38
39
40
+ async notifyWhenNoRepository ( featureName ?: string ) {
41
+ if ( this . container . git . openRepositoryCount > 0 ) {
42
+ return ;
43
+ }
44
+
45
+ const message = featureName
46
+ ? `No repository detected. To view ${ featureName } , open a folder containing a git repository or clone from a URL in Source Control.`
47
+ : 'No repository detected. To use GitLens, open a folder containing a git repository or clone from a URL in Source Control.' ;
48
+
49
+ const openRepo = { title : 'Open a Folder or Repo' , isCloseAffordance : true } ;
50
+ const result = await window . showInformationMessage ( message , openRepo ) ;
51
+ if ( result === openRepo ) {
52
+ void executeCoreCommand ( 'workbench.view.scm' ) ;
53
+ }
54
+ }
55
+
39
56
async execute ( context : CommandContext , ...args : unknown [ ] ) {
40
57
const command = context . command as Commands ;
41
58
switch ( command ) {
@@ -47,6 +64,7 @@ export class ShowViewCommand extends Command {
47
64
case Commands . ShowBranchesView :
48
65
return this . container . views . showView ( 'branches' ) ;
49
66
case Commands . ShowCommitDetailsView :
67
+ void this . notifyWhenNoRepository ( 'Inspect' ) ;
50
68
return this . container . views . commitDetails . show ( ) ;
51
69
case Commands . ShowCommitsView :
52
70
return this . container . views . showView ( 'commits' ) ;
@@ -57,6 +75,7 @@ export class ShowViewCommand extends Command {
57
75
case Commands . ShowFileHistoryView :
58
76
return this . container . views . showView ( 'fileHistory' ) ;
59
77
case Commands . ShowGraphView :
78
+ void this . notifyWhenNoRepository ( 'the Commit Graph' ) ;
60
79
return this . container . views . graph . show ( undefined , ...( args as GraphWebviewShowingArgs ) ) ;
61
80
case Commands . ShowHomeView :
62
81
return this . container . views . home . show ( undefined , ...( args as HomeWebviewShowingArgs ) ) ;
0 commit comments