fix issue from PR #10

This commit is contained in:
Casey Lee 2019-01-17 15:28:52 -08:00
parent 8793c8a6a4
commit 20f20eddf7
No known key found for this signature in database
GPG key ID: 4CC378651BF9C168

View file

@ -72,20 +72,18 @@ func findGitHead(file string) (string, error) {
}() }()
headBuffer := new(bytes.Buffer) headBuffer := new(bytes.Buffer)
length, err := headBuffer.ReadFrom(bufio.NewReader(headFile)) _, err = headBuffer.ReadFrom(bufio.NewReader(headFile))
if err != nil { if err != nil {
log.Error(err) log.Error(err)
} }
headBytes := headBuffer.Bytes()
var ref string var ref string
if length <= 42 {
ref = string(headBuffer.Bytes()[:40])
} else {
head := make(map[string]string) head := make(map[string]string)
err = yaml.Unmarshal(headBuffer.Bytes(), head) err = yaml.Unmarshal(headBytes, head)
if err != nil { if err != nil {
log.Error(err) ref = string(headBytes)
} } else {
ref = head["ref"] ref = head["ref"]
} }