20 lines
348 B
Go
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
|
|
}
|