Browse Source

Uses git found by the vscode git extension if available

main
Eric Amodio 6 years ago
parent
commit
38b55dfb9b
1 changed files with 17 additions and 1 deletions
  1. +17
    -1
      src/extension.ts

+ 17
- 1
src/extension.ts View File

@ -10,6 +10,10 @@ import { Logger } from './logger';
import { Messages } from './messages'; import { Messages } from './messages';
// import { Telemetry } from './telemetry'; // import { Telemetry } from './telemetry';
interface GitApi {
getGitPath(): Promise<string>;
}
export async function activate(context: ExtensionContext) { export async function activate(context: ExtensionContext) {
const start = process.hrtime(); const start = process.hrtime();
@ -36,7 +40,19 @@ export async function activate(context: ExtensionContext) {
const cfg = configuration.get<IConfig>(); const cfg = configuration.get<IConfig>();
try { try {
await GitService.initialize(cfg.advanced.git || workspace.getConfiguration('git').get<string>('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<string>('path'));
} }
catch (ex) { catch (ex) {
Logger.error(ex, `GitLens(v${gitlensVersion}).activate`); Logger.error(ex, `GitLens(v${gitlensVersion}).activate`);

Loading…
Cancel
Save