Refactor
Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
This commit is contained in:
parent
a4901b9ae7
commit
d27eca0a07
13 changed files with 71 additions and 57 deletions
|
@ -1,35 +0,0 @@
|
|||
package lib
|
||||
|
||||
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...)
|
||||
command := exec.Command("git", args...)
|
||||
|
||||
output, err := command.CombinedOutput()
|
||||
|
||||
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()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue