mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-09 17:52:39 -05:00
Hides remote commands when there are no remotes
This commit is contained in:
@@ -585,11 +585,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.openCommitInRemote",
|
"command": "gitlens.openCommitInRemote",
|
||||||
"when": "editorTextFocus && gitlens:enabled && gitlens:isBlameable && config.gitlens.insiders"
|
"when": "editorTextFocus && gitlens:enabled && gitlens:hasRemotes && gitlens:isBlameable"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.openFileInRemote",
|
"command": "gitlens.openFileInRemote",
|
||||||
"when": "editorTextFocus && gitlens:enabled && config.gitlens.insiders"
|
"when": "editorTextFocus && gitlens:enabled && gitlens:hasRemotes"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"explorer/context": [
|
"explorer/context": [
|
||||||
@@ -600,7 +600,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.openFileInRemote",
|
"command": "gitlens.openFileInRemote",
|
||||||
"when": "gitlens:enabled && config.gitlens.insiders",
|
"when": "gitlens:enabled && gitlens:hasRemotes",
|
||||||
"group": "gitlens@2"
|
"group": "gitlens@2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export type CommandContext = 'gitlens:canToggleCodeLens' | 'gitlens:enabled' | '
|
|||||||
export const CommandContext = {
|
export const CommandContext = {
|
||||||
CanToggleCodeLens: 'gitlens:canToggleCodeLens' as CommandContext,
|
CanToggleCodeLens: 'gitlens:canToggleCodeLens' as CommandContext,
|
||||||
Enabled: 'gitlens:enabled' as CommandContext,
|
Enabled: 'gitlens:enabled' as CommandContext,
|
||||||
|
HasRemotes: 'gitlens:hasRemotes' as CommandContext,
|
||||||
IsBlameable: 'gitlens:isBlameable' as CommandContext,
|
IsBlameable: 'gitlens:isBlameable' as CommandContext,
|
||||||
Key: 'gitlens:key' as CommandContext
|
Key: 'gitlens:key' as CommandContext
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ export async function activate(context: ExtensionContext) {
|
|||||||
const git = new GitService(context);
|
const git = new GitService(context);
|
||||||
context.subscriptions.push(git);
|
context.subscriptions.push(git);
|
||||||
|
|
||||||
|
setRemoteCommandsContext(context, git);
|
||||||
|
|
||||||
const blameabilityTracker = new BlameabilityTracker(git);
|
const blameabilityTracker = new BlameabilityTracker(git);
|
||||||
context.subscriptions.push(blameabilityTracker);
|
context.subscriptions.push(blameabilityTracker);
|
||||||
|
|
||||||
@@ -150,4 +152,13 @@ async function notifyOnUnsupportedGitVersion(context: ExtensionContext, version:
|
|||||||
context.globalState.update(WorkspaceState.SuppressGitVersionWarning, true);
|
context.globalState.update(WorkspaceState.SuppressGitVersionWarning, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setRemoteCommandsContext(context: ExtensionContext, git: GitService): Promise<void> {
|
||||||
|
let hasRemotes = false;
|
||||||
|
if (git.config.insiders) {
|
||||||
|
const remotes = await git.getRemotes(git.repoPath);
|
||||||
|
hasRemotes = remotes.length !== 0;
|
||||||
|
}
|
||||||
|
setCommandContext(CommandContext.HasRemotes, hasRemotes);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user