0
0
mirror of https://github.com/thegeeklab/wp-git-action.git synced 2024-11-28 18:20:35 +00:00
wp-git-action/git/status.go

43 lines
544 B
Go
Raw Normal View History

package git
import (
"bytes"
"fmt"
"os"
"os/exec"
)
func Status(repo Repository) *exec.Cmd {
cmd := exec.Command(
"git",
"status",
"--porcelain",
)
cmd.Dir = repo.WorkDir
cmd.Stderr = os.Stderr
return cmd
}
func IsDirty(repo Repository) bool {
res := bytes.NewBufferString("")
cmd := Status(repo)
cmd.Dir = repo.WorkDir
cmd.Stderr = os.Stderr
cmd.Stdout = res
cmd.Stderr = res
err := runCommand(cmd)
if err != nil {
return false
}
if res.Len() > 0 {
fmt.Print(res.String())
return true
}
return false
}