mirror of
https://github.com/vbatts/git-validation.git
synced 2024-11-17 22:08:39 +00:00
git: fix corruption in field values
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
3ff2ef6b70
commit
1a447a0dfc
1 changed files with 3 additions and 5 deletions
|
@ -1,7 +1,6 @@
|
||||||
package git
|
package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -64,16 +63,15 @@ type CommitEntry map[string]string
|
||||||
|
|
||||||
// LogCommit assembles the full information on a commit from its commit hash
|
// LogCommit assembles the full information on a commit from its commit hash
|
||||||
func LogCommit(commit string) (*CommitEntry, error) {
|
func LogCommit(commit string) (*CommitEntry, error) {
|
||||||
buf := bytes.NewBuffer([]byte{})
|
|
||||||
c := CommitEntry{}
|
c := CommitEntry{}
|
||||||
for k, v := range FieldNames {
|
for k, v := range FieldNames {
|
||||||
cmd := exec.Command("git", "log", "-1", `--pretty=format:`+k+``, commit)
|
cmd := exec.Command("git", "log", "-1", `--pretty=format:`+k+``, commit)
|
||||||
cmd.Stdout = buf
|
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
if err := cmd.Run(); err != nil {
|
out, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
c[v] = strings.TrimSpace(string(buf.Bytes()))
|
c[v] = strings.TrimSpace(string(out))
|
||||||
}
|
}
|
||||||
|
|
||||||
return &c, nil
|
return &c, nil
|
||||||
|
|
Loading…
Reference in a new issue