cmd-zet/internal/git/git.go
Oliver Davies a3202aaff3 Refactor
Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
2025-10-04 00:36:00 +01:00

37 lines
754 B
Go

package git
import (
"os"
"os/exec"
"strconv"
"code.oliverdavies.uk/opdavies/cmd-zet/internal/config"
)
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", config.GetZetDir()}, parts...)
command := exec.Command("git", args...)
output, err := command.CombinedOutput()
return string(output), err
}
func runGitCommand(parts ...string) {
args := append([]string{"-C", config.GetZetDir()}, parts...)
command := exec.Command("git", args...)
command.Stderr = os.Stderr
command.Stdin = os.Stdin
command.Stdout = os.Stdout
command.Run()
}