From 38b55dfb9b2ed51f78132da43ed9d96899e9e9b8 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Thu, 31 May 2018 01:02:29 -0400 Subject: [PATCH] Uses git found by the vscode git extension if available --- src/extension.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index 323697b..0d93c54 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -10,6 +10,10 @@ import { Logger } from './logger'; import { Messages } from './messages'; // import { Telemetry } from './telemetry'; +interface GitApi { + getGitPath(): Promise; +} + export async function activate(context: ExtensionContext) { const start = process.hrtime(); @@ -36,7 +40,19 @@ export async function activate(context: ExtensionContext) { const cfg = configuration.get(); try { - await GitService.initialize(cfg.advanced.git || workspace.getConfiguration('git').get('path')); + let gitPath = cfg.advanced.git; + if (!gitPath) { + // Try to use the same git as the built-in vscode git extension + try { + const gitExtension = extensions.getExtension('vscode.git'); + if (gitExtension !== undefined) { + gitPath = await (gitExtension.exports as GitApi).getGitPath(); + } + } + catch { } + } + + await GitService.initialize(gitPath || workspace.getConfiguration('git').get('path')); } catch (ex) { Logger.error(ex, `GitLens(v${gitlensVersion}).activate`);