Skip to content

Commit

Permalink
Merge pull request #10 from Code0x58/non-symbolic-ref-HEAD
Browse files Browse the repository at this point in the history
Allow non-symbolic-ref HEAD
  • Loading branch information
cplee authored Jan 17, 2019
2 parents 949dc46 + 1ead030 commit 19d1d0c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions common/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
head := make(map[string]string)
err = yaml.Unmarshal(headBuffer.Bytes(), head)
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
Expand Down

0 comments on commit 19d1d0c

Please sign in to comment.