Skip to content

Commit

Permalink
feat: add to .gitignore command
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinzent03 committed Aug 15, 2022
1 parent 1cad1b7 commit c824903
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,22 @@ export default class ObsidianGit extends Plugin {
callback: () => this.promiseQueue.addTask(() => this.pullChangesFromRemote()),
});

this.addCommand({
id: "add-to-gitignore",
name: "Add file to gitignore",
checkCallback: (checking) => {
const file = app.workspace.getActiveFile();
if (checking) {
return file !== undefined;
} else {
app.vault.adapter.append(this.gitManager.getVaultPath(".gitignore"), "\n" + this.gitManager.getPath(file.path, true))
.then(() => {
this.refresh();
});
}
},
});

this.addCommand({
id: "push",
name: "Create backup",
Expand Down
2 changes: 1 addition & 1 deletion src/ui/modals/ignoreModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class IgnoreModal extends Modal {
div.createEl("button",
{
cls: ["mod-cta", "obsidian-git-center-button"],
text: "Confirm",
text: "Save",
})
.addEventListener("click", async () => {
this.resolve(text.value);
Expand Down

0 comments on commit c824903

Please sign in to comment.