From 1a447a0dfca4696a943bcdde9d15752a02abe00c Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Tue, 5 Apr 2016 14:53:57 -0400 Subject: [PATCH] git: fix corruption in field values Signed-off-by: Vincent Batts --- git/commits.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/git/commits.go b/git/commits.go index 0084877..2d2f5d2 100644 --- a/git/commits.go +++ b/git/commits.go @@ -1,7 +1,6 @@ package git import ( - "bytes" "os" "os/exec" "strings" @@ -64,16 +63,15 @@ type CommitEntry map[string]string // LogCommit assembles the full information on a commit from its commit hash func LogCommit(commit string) (*CommitEntry, error) { - buf := bytes.NewBuffer([]byte{}) c := CommitEntry{} for k, v := range FieldNames { cmd := exec.Command("git", "log", "-1", `--pretty=format:`+k+``, commit) - cmd.Stdout = buf cmd.Stderr = os.Stderr - if err := cmd.Run(); err != nil { + out, err := cmd.Output() + if err != nil { return nil, err } - c[v] = strings.TrimSpace(string(buf.Bytes())) + c[v] = strings.TrimSpace(string(out)) } return &c, nil