Skip to content

Commit

Permalink
fix: stage individual file
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Aug 16, 2022
1 parent f6f4a97 commit 76e317b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/isomorphicGit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,19 @@ export class IsomorphicGit extends GitManager {
}

async stage(filepath: string, relativeToVault: boolean): Promise<void> {
filepath = this.getPath(filepath, relativeToVault);
const gitPath = this.getPath(filepath, relativeToVault);
let vaultPath: string;
if (relativeToVault) {
vaultPath = filepath;
} else {
vaultPath = this.getVaultPath(filepath);
}
try {
this.plugin.setState(PluginState.add);
if (await this.app.vault.adapter.exists(filepath)) {
await this.wrapFS(git.add({ ...this.getRepo(), filepath: filepath }));
if (await this.app.vault.adapter.exists(vaultPath)) {
await this.wrapFS(git.add({ ...this.getRepo(), filepath: gitPath }));
} else {
await this.wrapFS(git.remove({ ...this.getRepo(), filepath: filepath }));
await this.wrapFS(git.remove({ ...this.getRepo(), filepath: gitPath }));
}
} catch (error) {
this.plugin.displayError(error);
Expand Down

0 comments on commit 76e317b

Please sign in to comment.