1
0
Fork 0
mirror of https://github.com/vbatts/git-validation.git synced 2024-11-26 01:55:40 +00:00

Merge pull request #19 from wking/log-failed-git-commands

git/commits: Log failed Git commands
This commit is contained in:
Vincent Batts 2017-03-21 17:57:11 -04:00 committed by GitHub
commit fe12ea494a

View file

@ -18,6 +18,7 @@ func Commits(commitrange string) ([]CommitEntry, error) {
} }
output, err := exec.Command(cmdArgs[0], cmdArgs[1:]...).Output() output, err := exec.Command(cmdArgs[0], cmdArgs[1:]...).Output()
if err != nil { if err != nil {
logrus.Errorf("mm[git] cmd: %q", strings.Join(cmdArgs, " "))
return nil, err return nil, err
} }
commitHashes := strings.Split(strings.TrimSpace(string(output)), "\n") commitHashes := strings.Split(strings.TrimSpace(string(output)), "\n")
@ -95,6 +96,7 @@ func LogCommit(commit string) (*CommitEntry, error) {
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
out, err := cmd.Output() out, err := cmd.Output()
if err != nil { if err != nil {
logrus.Errorf("[git] cmd: %q", strings.Join(cmd.Args, " "))
return nil, err return nil, err
} }
c[v] = strings.TrimSpace(string(out)) c[v] = strings.TrimSpace(string(out))
@ -115,6 +117,7 @@ func FetchHeadCommit() (string, error) {
} }
output, err := exec.Command(cmdArgs[0], cmdArgs[1:]...).Output() output, err := exec.Command(cmdArgs[0], cmdArgs[1:]...).Output()
if err != nil { if err != nil {
logrus.Errorf("[git] cmd: %q", strings.Join(cmdArgs, " "))
return "", err return "", err
} }
return strings.TrimSpace(string(output)), nil return strings.TrimSpace(string(output)), nil
@ -128,6 +131,7 @@ func HeadCommit() (string, error) {
} }
output, err := exec.Command(cmdArgs[0], cmdArgs[1:]...).Output() output, err := exec.Command(cmdArgs[0], cmdArgs[1:]...).Output()
if err != nil { if err != nil {
logrus.Errorf("[git] cmd: %q", strings.Join(cmdArgs, " "))
return "", err return "", err
} }
return strings.TrimSpace(string(output)), nil return strings.TrimSpace(string(output)), nil