mirror of
https://github.com/strongdm/comply
synced 2024-11-24 16:44:53 +00:00
40 lines
804 B
Go
40 lines
804 B
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
func isRepoClean() (bool, error) {
|
|
cmd := exec.Command("git", "status", "--porcelain")
|
|
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()
|
|
}
|