Skip to content

Commit 70a6464

Browse files
committed
fix: show missing repo message
1 parent 6c6a2f4 commit 70a6464

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/main.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,15 @@ export default class ObsidianGit extends Plugin {
384384
name: "CAUTION: Discard all changes",
385385
callback: async () => {
386386
if (! await this.isAllInitialized()) return false;
387-
const modal = new GeneralModal({
388-
options: ["NO", "YES"],
389-
placeholder: "Do you want to discard all changes to tracked files? This action cannot be undone.",
390-
onlySelection: true
391-
});
392-
const shouldDiscardAll = await modal.open() === "YES";
393-
if (shouldDiscardAll) {
394-
this.promiseQueue.addTask(() => this.discardAll());
395-
}
387+
const modal = new GeneralModal({
388+
options: ["NO", "YES"],
389+
placeholder: "Do you want to discard all changes to tracked files? This action cannot be undone.",
390+
onlySelection: true
391+
});
392+
const shouldDiscardAll = await modal.open() === "YES";
393+
if (shouldDiscardAll) {
394+
this.promiseQueue.addTask(() => this.discardAll());
395+
}
396396
}
397397
});
398398

@@ -585,7 +585,7 @@ export default class ObsidianGit extends Plugin {
585585
this.displayError("Cannot run git command");
586586
break;
587587
case "missing-repo":
588-
new Notice("Can't find a valid git repository. Please create one via the given command or clone an existing repo.");
588+
new Notice("Can't find a valid git repository. Please create one via the given command or clone an existing repo.", 10000);
589589
break;
590590
case "valid":
591591
this.gitReady = true;
@@ -1088,7 +1088,7 @@ export default class ObsidianGit extends Plugin {
10881088
async discardAll() {
10891089
await this.gitManager.discardAll({
10901090
status: this.cachedStatus
1091-
})
1091+
});
10921092
new Notice('All local changes have been discarded. New files remain untouched.');
10931093
}
10941094

src/simpleGit.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { spawnSync } from "child_process";
2+
import debug from 'debug';
23
import { FileSystemAdapter, normalizePath, Notice } from "obsidian";
34
import * as path from "path";
45
import { sep } from "path";
@@ -7,7 +8,6 @@ import { GitManager } from "./gitManager";
78
import ObsidianGit from "./main";
89
import { BranchInfo, FileStatusResult, PluginState, Status } from "./types";
910
import { splitRemoteBranch } from "./utils";
10-
import debug from 'debug';
1111

1212
export class SimpleGit extends GitManager {
1313
git: simple.SimpleGit;
@@ -52,9 +52,9 @@ export class SimpleGit extends GitManager {
5252
}
5353

5454
debug.enable('simple-git');
55-
56-
await this.git.cwd(await this.git.revparse("--show-toplevel"));
57-
55+
if (await this.git.checkIsRepo()) {
56+
await this.git.cwd(await this.git.revparse("--show-toplevel"));
57+
}
5858
}
5959
}
6060

0 commit comments

Comments
 (0)