Skip to content

Commit 80c0b65

Browse files
committed
fix: properly resolve merge conflict
close #502
1 parent c135c0b commit 80c0b65

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/main.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ export default class ObsidianGit extends Plugin {
704704
await this.saveData(this.settings);
705705
}
706706

707-
async saveLastAuto(date: Date, mode: "backup" | "pull" | "push") {
707+
saveLastAuto(date: Date, mode: "backup" | "pull" | "push") {
708708
if (mode === "backup") {
709709
this.localStorage.setLastAutoBackup(date.toString());
710710
} else if (mode === "pull") {
@@ -714,7 +714,7 @@ export default class ObsidianGit extends Plugin {
714714
}
715715
}
716716

717-
async loadLastAuto(): Promise<{ backup: Date; pull: Date; push: Date }> {
717+
loadLastAuto(): { backup: Date; pull: Date; push: Date } {
718718
return {
719719
backup: new Date(this.localStorage.getLastAutoBackup() ?? ""),
720720
pull: new Date(this.localStorage.getLastAutoPull() ?? ""),
@@ -982,7 +982,7 @@ export default class ObsidianGit extends Plugin {
982982
}): Promise<boolean> {
983983
if (!(await this.isAllInitialized())) return false;
984984

985-
const hadConflict = this.localStorage.getConflict() === "true";
985+
let hadConflict = this.localStorage.getConflict() === "true";
986986

987987
let changedFiles: { vault_path: string }[];
988988
let status: Status | undefined;
@@ -992,6 +992,12 @@ export default class ObsidianGit extends Plugin {
992992
this.mayDeleteConflictFile();
993993
status = await this.updateCachedStatus();
994994

995+
//Should not be necessary, but just in case
996+
if (status.conflicted.length == 0) {
997+
this.localStorage.setConflict("false");
998+
hadConflict = false;
999+
}
1000+
9951001
// check for conflict files on auto backup
9961002
if (fromAutoBackup && status.conflicted.length > 0) {
9971003
this.displayError(
@@ -1078,6 +1084,14 @@ export default class ObsidianGit extends Plugin {
10781084
unstagedFiles,
10791085
});
10801086
}
1087+
1088+
//Handle resolved conflict after commit
1089+
if (this.gitManager instanceof SimpleGit) {
1090+
if ((await this.updateCachedStatus()).conflicted.length == 0) {
1091+
this.localStorage.setConflict("false");
1092+
}
1093+
}
1094+
10811095
let roughly = false;
10821096
if (committedFiles === undefined) {
10831097
roughly = true;

0 commit comments

Comments
 (0)