Add error logging to git add and commit

This commit is contained in:
Peter Stuifzand 2019-02-02 11:08:50 +01:00
parent c67aa6ed4f
commit f70d1ccc05

12
file.go
View File

@ -52,11 +52,19 @@ func (fp *FilePages) Save(p string, page Page, summary, author string) {
func saveWithGit(fp *FilePages, p string, summary, author string) {
cmd := exec.Command("git", "add", ".")
cmd.Dir = fp.dirname
cmd.Run()
err := cmd.Run()
if err != nil {
log.Println(err)
return
}
cmd = exec.Command("git", "commit", "-m", "Changes to "+p+" by "+author+"\n\n"+summary)
cmd.Dir = fp.dirname
cmd.Run()
err = cmd.Run()
if err != nil {
log.Println(err)
return
}
}
func (fp *FilePages) Exist(p string) bool {