gsquash/git/cmd.go
2023-12-05 19:03:27 +00:00

20 lines
348 B
Go

package git
import "os/exec"
// Execute runs a git command and returns the stdout
func (g *Git) Execute(args ...string) (string, error) {
cmd := exec.Command("git", args...)
if g.WorkingDir != "" {
cmd.Dir = g.WorkingDir
}
// Run and return stdout
out, err := cmd.Output()
if err != nil {
return "", err
}
return string(out), nil
}