mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 18:48:45 -05:00
Allows dynamic switching of insiders
This commit is contained in:
@@ -62,21 +62,12 @@ export async function activate(context: ExtensionContext) {
|
|||||||
notifyOnUnsupportedGitVersion(context, gitVersion);
|
notifyOnUnsupportedGitVersion(context, gitVersion);
|
||||||
notifyOnNewGitLensVersion(context, gitlensVersion);
|
notifyOnNewGitLensVersion(context, gitlensVersion);
|
||||||
|
|
||||||
let gitEnabled = workspace.getConfiguration('git').get<boolean>('enabled');
|
|
||||||
setCommandContext(CommandContext.Enabled, gitEnabled);
|
|
||||||
context.subscriptions.push(workspace.onDidChangeConfiguration(() => {
|
|
||||||
if (gitEnabled !== workspace.getConfiguration('git').get<boolean>('enabled')) {
|
|
||||||
gitEnabled = !gitEnabled;
|
|
||||||
setCommandContext(CommandContext.Enabled, gitEnabled);
|
|
||||||
}
|
|
||||||
}, this));
|
|
||||||
|
|
||||||
context.workspaceState.update(WorkspaceState.RepoPath, repoPath);
|
context.workspaceState.update(WorkspaceState.RepoPath, repoPath);
|
||||||
|
|
||||||
const git = new GitService(context);
|
const git = new GitService(context);
|
||||||
context.subscriptions.push(git);
|
context.subscriptions.push(git);
|
||||||
|
|
||||||
setRemoteCommandsContext(context, git);
|
setCommandsContext(context, git);
|
||||||
|
|
||||||
const blameabilityTracker = new BlameabilityTracker(git);
|
const blameabilityTracker = new BlameabilityTracker(git);
|
||||||
context.subscriptions.push(blameabilityTracker);
|
context.subscriptions.push(blameabilityTracker);
|
||||||
@@ -154,11 +145,30 @@ async function notifyOnUnsupportedGitVersion(context: ExtensionContext, version:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setRemoteCommandsContext(context: ExtensionContext, git: GitService): Promise<void> {
|
let savedGitEnabled: boolean;
|
||||||
let hasRemotes = false;
|
let savedInsiders: boolean;
|
||||||
if (git.config.insiders) {
|
|
||||||
const remotes = await git.getRemotes(git.repoPath);
|
async function setCommandsContext(context: ExtensionContext, git: GitService): Promise<void> {
|
||||||
hasRemotes = remotes.length !== 0;
|
onCommandsContextConfigurationChanged(git);
|
||||||
}
|
context.subscriptions.push(workspace.onDidChangeConfiguration(() => onCommandsContextConfigurationChanged(git), this));
|
||||||
setCommandContext(CommandContext.HasRemotes, hasRemotes);
|
}
|
||||||
|
|
||||||
|
async function onCommandsContextConfigurationChanged(git: GitService) {
|
||||||
|
const gitEnabled = workspace.getConfiguration('git').get<boolean>('enabled');
|
||||||
|
if (gitEnabled !== savedGitEnabled) {
|
||||||
|
savedGitEnabled = gitEnabled;
|
||||||
|
setCommandContext(CommandContext.Enabled, gitEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
const insiders = workspace.getConfiguration('gitlens').get<boolean>('insiders');
|
||||||
|
if (insiders !== savedInsiders) {
|
||||||
|
savedInsiders = insiders;
|
||||||
|
|
||||||
|
let hasRemotes = false;
|
||||||
|
if (insiders) {
|
||||||
|
const remotes = await git.getRemotes(git.repoPath);
|
||||||
|
hasRemotes = remotes.length !== 0;
|
||||||
|
}
|
||||||
|
setCommandContext(CommandContext.HasRemotes, hasRemotes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user