commit 1
This commit is contained in:
19
git/cmd.go
Normal file
19
git/cmd.go
Normal file
@@ -0,0 +1,19 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user