From 1ead030d2ee2a961f3b56a774e65bd905bd7cfe6 Mon Sep 17 00:00:00 2001 From: Oliver Bristow Date: Thu, 17 Jan 2019 22:13:15 +0000 Subject: [PATCH] Allow non-symbolic-ref HEAD --- common/git.go | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/common/git.go b/common/git.go index 76f0091..b58965d 100644 --- a/common/git.go +++ b/common/git.go @@ -72,19 +72,26 @@ func findGitHead(file string) (string, error) { }() headBuffer := new(bytes.Buffer) - _, err = headBuffer.ReadFrom(bufio.NewReader(headFile)) - if err != nil { - log.Error(err) - } - head := make(map[string]string) - err = yaml.Unmarshal(headBuffer.Bytes(), head) + length, err := headBuffer.ReadFrom(bufio.NewReader(headFile)) if err != nil { log.Error(err) } - log.Debugf("HEAD points to '%s'", head["ref"]) + 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"] + } - return head["ref"], nil + log.Debugf("HEAD points to '%s'", ref) + + return ref, nil } // FindGithubRepo get the repo