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)
length, err := headBuffer.ReadFrom(bufio.NewReader(headFile))
_, err = headBuffer.ReadFrom(bufio.NewReader(headFile))
if err != nil {
log.Error(err)
}
headBytes := headBuffer.Bytes()
var ref string
if length <= 42 {
ref = string(headBuffer.Bytes()[:40])
head := make(map[string]string)
err = yaml.Unmarshal(headBytes, head)
if err != nil {
ref = string(headBytes)
} else {
head := make(map[string]string)
err = yaml.Unmarshal(headBuffer.Bytes(), head)
if err != nil {
log.Error(err)
}
ref = head["ref"]
}