Skip to content

Commit 6f07fd9

Browse files
committed
Adds notification when no repo
1 parent c674705 commit 6f07fd9

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

src/commands/showView.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { window } from 'vscode';
12
import { Commands } from '../constants.commands';
23
import type { Container } from '../container';
34
import type { GraphWebviewShowingArgs } from '../plus/webviews/graph/registration';
4-
import { command } from '../system/vscode/command';
5+
import { command, executeCoreCommand } from '../system/vscode/command';
56
import type { HomeWebviewShowingArgs } from '../webviews/home/registration';
67
import type { CommandContext } from './base';
78
import { Command } from './base';
@@ -36,6 +37,22 @@ export class ShowViewCommand extends Command {
3637
return this.execute(context, ...args);
3738
}
3839

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+
3956
async execute(context: CommandContext, ...args: unknown[]) {
4057
const command = context.command as Commands;
4158
switch (command) {
@@ -47,6 +64,7 @@ export class ShowViewCommand extends Command {
4764
case Commands.ShowBranchesView:
4865
return this.container.views.showView('branches');
4966
case Commands.ShowCommitDetailsView:
67+
void this.notifyWhenNoRepository('Inspect');
5068
return this.container.views.commitDetails.show();
5169
case Commands.ShowCommitsView:
5270
return this.container.views.showView('commits');
@@ -57,6 +75,7 @@ export class ShowViewCommand extends Command {
5775
case Commands.ShowFileHistoryView:
5876
return this.container.views.showView('fileHistory');
5977
case Commands.ShowGraphView:
78+
void this.notifyWhenNoRepository('the Commit Graph');
6079
return this.container.views.graph.show(undefined, ...(args as GraphWebviewShowingArgs));
6180
case Commands.ShowHomeView:
6281
return this.container.views.home.show(undefined, ...(args as HomeWebviewShowingArgs));

src/commands/walkthroughs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { urls } from '../constants';
33
import { Commands } from '../constants.commands';
44
import type { Source, Sources } from '../constants.telemetry';
55
import type { Container } from '../container';
6-
import { command, executeCommand, executeCoreCommand } from '../system/vscode/command';
6+
import { command, executeCommand } from '../system/vscode/command';
77
import { openUrl, openWalkthrough as openWalkthroughCore } from '../system/vscode/utils';
88
import { Command } from './base';
99

@@ -163,13 +163,13 @@ export class WalkthroughGitLensInspectCommand extends Command {
163163
}
164164

165165
execute() {
166-
const command = 'workbench.view.extension.gitlensInspect';
166+
const command = Commands.ShowCommitDetailsView;
167167
this.container.telemetry.sendEvent('walkthrough/action', {
168168
type: 'command',
169169
name: command,
170170
command: command,
171171
});
172-
executeCoreCommand(command);
172+
executeCommand(command);
173173
}
174174
}
175175

src/webviews/apps/home/components/repo-alerts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class GlRepoAlerts extends GlElement {
8989
Explorer.
9090
</p>
9191
<p class="centered">
92-
<gl-button class="is-basic" href="command:workbench.view.explorer"
92+
<gl-button class="is-basic" href="command:workbench.view.scm"
9393
>Open a Folder or Repository</gl-button
9494
>
9595
</p>

0 commit comments

Comments
 (0)