Allow non-symbolic-ref HEAD

This commit is contained in:
Oliver Bristow 2019-01-17 22:13:15 +00:00
parent 949dc467e0
commit 1ead030d2e
No known key found for this signature in database
GPG key ID: 6B75B2FEA72B664A

View file

@ -72,19 +72,26 @@ func findGitHead(file string) (string, error) {
}()
headBuffer := new(bytes.Buffer)
_, err = headBuffer.ReadFrom(bufio.NewReader(headFile))
length, err := headBuffer.ReadFrom(bufio.NewReader(headFile))
if err != nil {
log.Error(err)
}
var ref string
if length <= 42 {
ref = string(headBuffer.Bytes()[:40])
} else {
head := make(map[string]string)
err = yaml.Unmarshal(headBuffer.Bytes(), head)
if err != nil {
log.Error(err)
}
ref = head["ref"]
}
log.Debugf("HEAD points to '%s'", head["ref"])
log.Debugf("HEAD points to '%s'", ref)
return head["ref"], nil
return ref, nil
}
// FindGithubRepo get the repo