Skip to content

Commit c4a0446

Browse files
committed
git: fix corruption in field values
Signed-off-by: Vincent Batts <[email protected]>
1 parent fff81e9 commit c4a0446

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

git/commits.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package git
22

33
import (
4-
"bytes"
54
"os"
65
"os/exec"
76
"strings"
@@ -64,16 +63,15 @@ type CommitEntry map[string]string
6463

6564
// LogCommit assembles the full information on a commit from its commit hash
6665
func LogCommit(commit string) (*CommitEntry, error) {
67-
buf := bytes.NewBuffer([]byte{})
6866
c := CommitEntry{}
6967
for k, v := range FieldNames {
7068
cmd := exec.Command("git", "log", "-1", `--pretty=format:`+k+``, commit)
71-
cmd.Stdout = buf
7269
cmd.Stderr = os.Stderr
73-
if err := cmd.Run(); err != nil {
70+
out, err := cmd.Output()
71+
if err != nil {
7472
return nil, err
7573
}
76-
c[v] = strings.TrimSpace(string(buf.Bytes()))
74+
c[v] = strings.TrimSpace(string(out))
7775
}
7876

7977
return &c, nil

0 commit comments

Comments
 (0)