From 9c8c583a95c99656aeff23d33d0ca422f55bad0a Mon Sep 17 00:00:00 2001 From: lukester1975 Date: Sun, 16 Jan 2022 19:43:26 +0000 Subject: Use vscode.workspace.rootPath to construct SimpleGit instance. (#268) Allows per-workspace git user and email address. --- src/GitConfig.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/GitConfig.ts b/src/GitConfig.ts index 2a425f6..0b6f756 100644 --- a/src/GitConfig.ts +++ b/src/GitConfig.ts @@ -1,10 +1,17 @@ -import simpleGit, {ConfigValues, SimpleGit} from "simple-git"; +import simpleGit, { ConfigValues, SimpleGit } from "simple-git"; +import { workspace } from "vscode"; export default class GitConfig { private gitConfig: ConfigValues; public constructor() { - const git: SimpleGit = simpleGit(); + let git: SimpleGit; + try { + git = simpleGit(workspace.workspaceFolders?.[0].uri.fsPath); + } catch (error) { + git = simpleGit(); + } + git.listConfig().then((result) => { this.gitConfig = result.all; }); -- cgit v1.2.3