summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlukester1975 <lukester1975@users.noreply.github.com>2022-01-16 19:43:26 +0000
committerGitHub <noreply@github.com>2022-01-16 20:43:26 +0100
commit9c8c583a95c99656aeff23d33d0ca422f55bad0a (patch)
tree590f1d49d6846ba5226fad00fee41204ea15cdff
parenta5b5d32b7d794c7bf9a774768108bdc999f3f8bc (diff)
downloaddoxdocgen-9c8c583a95c99656aeff23d33d0ca422f55bad0a.tar.gz
Use vscode.workspace.rootPath to construct SimpleGit instance. (#268)
Allows per-workspace git user and email address.
-rw-r--r--src/GitConfig.ts11
1 files 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;
});