fixup handling of git revisions for non-branch HEAD
This commit is contained in:
parent
20f20eddf7
commit
cb0704e8bf
1 changed files with 13 additions and 5 deletions
|
@ -34,11 +34,19 @@ func FindGitRevision(file string) (shortSha string, sha string, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
// load commitid ref
|
|
||||||
refBuf, err := ioutil.ReadFile(fmt.Sprintf("%s/%s", gitDir, head))
|
var refBuf []byte
|
||||||
if err != nil {
|
if strings.HasPrefix(head, "refs/") {
|
||||||
return "", "", err
|
// load commitid ref
|
||||||
|
refBuf, err = ioutil.ReadFile(fmt.Sprintf("%s/%s", gitDir, head))
|
||||||
|
if err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
refBuf = []byte(head)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debugf("Found revision: %s", refBuf)
|
||||||
return string(refBuf[:7]), string(refBuf), nil
|
return string(refBuf[:7]), string(refBuf), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +90,7 @@ func findGitHead(file string) (string, error) {
|
||||||
head := make(map[string]string)
|
head := make(map[string]string)
|
||||||
err = yaml.Unmarshal(headBytes, head)
|
err = yaml.Unmarshal(headBytes, head)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ref = string(headBytes)
|
ref = strings.TrimRight(string(headBytes), "\r\n")
|
||||||
} else {
|
} else {
|
||||||
ref = head["ref"]
|
ref = head["ref"]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue