shad-go/tools/testtool/commands/git.go
Fedor Korotkiy 6a83a4f1fc Task grading
2020-02-13 02:10:17 +03:00

22 lines
422 B
Go

package commands
import (
"bytes"
"os"
"os/exec"
"strings"
)
func listChangedFiles(gitPath string) ([]string, error) {
var gitOutput bytes.Buffer
cmd := exec.Command("git", "diff-tree", "--no-commit-id", "--name-only", "-r", "HEAD")
cmd.Dir = gitPath
cmd.Stdout = &gitOutput
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return nil, err
}
return strings.Split(gitOutput.String(), "\n"), nil
}