Skip to content

Commit

Permalink
feat: add hostname commit message placeholder
Browse files Browse the repository at this point in the history
close #146
  • Loading branch information
Vinzent03 committed Dec 8, 2021
1 parent a36c741 commit 32d8382
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/gitManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export abstract class GitManager {
let numFiles = status.staged.length;
template = template.replace("{{numFiles}}", String(numFiles));
}
if (template.includes("{{hostname}}")) {
const hostname = localStorage.getItem(this.plugin.manifest.id + ":hostname") || "";
template = template.replace("{{hostname}}", hostname);
}

if (template.includes("{{files}}")) {
status = status ?? await this.status();
Expand Down
13 changes: 12 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class ObsidianGitSettingsTab extends PluginSettingTab {
.setName("Commit message")
.setDesc(
"Specify custom commit message. Available placeholders: {{date}}" +
" (see below) and {{numFiles}} (number of changed files in the commit)"
" (see below), {{hostname}} (see below) and {{numFiles}} (number of changed files in the commit)"
)
.addText((text) =>
text
Expand Down Expand Up @@ -115,6 +115,17 @@ export class ObsidianGitSettingsTab extends PluginSettingTab {
})
);

new Setting(containerEl)
.setName("{{hostname}} placeholder replacement")
.setDesc('Specify custom hostname for every device.')
.addText((text) =>
text
.setValue(localStorage.getItem(plugin.manifest.id + ":hostname"))
.onChange(async (value) => {
localStorage.setItem(plugin.manifest.id + ":hostname", value);
})
);

new Setting(containerEl)
.setName("Preview commit message")
.addButton((button) =>
Expand Down

0 comments on commit 32d8382

Please sign in to comment.