1
0
mirror of https://github.com/strongdm/comply synced 2024-11-05 07:25:26 +00:00
comply/vendor/github.com/Clever/gitsem/git.go
2019-07-14 13:51:10 -03:00

40 lines
795 B
Go

package main
import (
"bytes"
"os/exec"
"strings"
)
func isRepoClean() (bool, error) {
cmd := exec.Command("git", "status", "-s")
result := &bytes.Buffer{}
cmd.Stdout = result
if err := cmd.Run(); err != nil {
return false, err
}
return result.String() == "", nil
}
func repoRoot() (string, error) {
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
result := &bytes.Buffer{}
cmd.Stdout = result
if err := cmd.Run(); err != nil {
return "", err
}
return strings.TrimSpace(result.String()), nil
}
func addFile(path string) error {
return exec.Command("git", "add", path).Run()
}
func commit(message string) error {
return exec.Command("git", "commit", "-m", message).Run()
}
func tag(version string) error {
return exec.Command("git", "tag", version).Run()
}