Skip to content

Commit

Permalink
fix: properly resolve merge conflict
Browse files Browse the repository at this point in the history
close #502
  • Loading branch information
Vinzent03 committed Jun 2, 2023
1 parent c135c0b commit 80c0b65
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ export default class ObsidianGit extends Plugin {
await this.saveData(this.settings);
}

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

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

const hadConflict = this.localStorage.getConflict() === "true";
let hadConflict = this.localStorage.getConflict() === "true";

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

//Should not be necessary, but just in case
if (status.conflicted.length == 0) {
this.localStorage.setConflict("false");
hadConflict = false;
}

// check for conflict files on auto backup
if (fromAutoBackup && status.conflicted.length > 0) {
this.displayError(
Expand Down Expand Up @@ -1078,6 +1084,14 @@ export default class ObsidianGit extends Plugin {
unstagedFiles,
});
}

//Handle resolved conflict after commit
if (this.gitManager instanceof SimpleGit) {
if ((await this.updateCachedStatus()).conflicted.length == 0) {
this.localStorage.setConflict("false");
}
}

let roughly = false;
if (committedFiles === undefined) {
roughly = true;
Expand Down

0 comments on commit 80c0b65

Please sign in to comment.