Commit the zettel after saving
Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
This commit is contained in:
parent
2537b4db9e
commit
59c4d132b2
2 changed files with 32 additions and 1 deletions
|
@ -1,6 +1,18 @@
|
|||
package lib
|
||||
|
||||
import "os/exec"
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func CommitZettel(id int, title string) {
|
||||
idString := strconv.Itoa(id)
|
||||
|
||||
runGitCommand("add", idString)
|
||||
runGitCommand("commit", "-m", title)
|
||||
runGitCommand("push")
|
||||
}
|
||||
|
||||
func execGitCommand(parts ...string) (string, error) {
|
||||
args := append([]string{"-C", GetZetDir()}, parts...)
|
||||
|
@ -10,3 +22,14 @@ func execGitCommand(parts ...string) (string, error) {
|
|||
|
||||
return string(output), err
|
||||
}
|
||||
|
||||
func runGitCommand(parts ...string) {
|
||||
args := append([]string{"-C", GetZetDir()}, parts...)
|
||||
command := exec.Command("git", args...)
|
||||
|
||||
command.Stderr = os.Stderr
|
||||
command.Stdin = os.Stdin
|
||||
command.Stdout = os.Stdout
|
||||
|
||||
command.Run()
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ func EditZet(id int) {
|
|||
zetPath := path.Join(GetZetDir(), strconv.Itoa(id), "index.adoc")
|
||||
|
||||
EditFile(zetPath)
|
||||
|
||||
onSave(id)
|
||||
}
|
||||
|
||||
func GetAllZets() []int {
|
||||
|
@ -136,3 +138,9 @@ func getTitleFromFile(filePath string) string {
|
|||
|
||||
return ""
|
||||
}
|
||||
|
||||
func onSave(id int) {
|
||||
title := getTitle(id)
|
||||
|
||||
CommitZettel(id, title)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue