gsquash/git/cmd.go
Layla Manley bd03ce5c4c # Squashed 3 commits
- main3
- test2
- test1
2023-12-05 19:39:21 +00:00

27 lines
444 B
Go

package git
import (
"log"
"os/exec"
"strings"
)
// Execute runs a git command and returns the stdout
func (g *Git) Execute(args ...string) (string, error) {
log.Println("git", strings.Join(args, " "))
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 strings.TrimSuffix(string(out), "\n"), nil
}