Comments for commit extraction

Requested in https://github.com/ethereum/go-ethereum/pull/18315
This commit is contained in:
Aleksey @soar Smyrnov 2019-01-07 13:49:53 +03:00 committed by GitHub
parent 5065a81feb
commit 4d5cca8ef2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -88,6 +88,9 @@ func LocalEnv() Environment {
if splits := strings.Split(head, " "); len(splits) == 2 { if splits := strings.Split(head, " "); len(splits) == 2 {
head = splits[1] head = splits[1]
} else { } else {
// In this case we are in "detached head" state
// see: https://git-scm.com/docs/git-checkout#_detached_head
// Additional check required to verify, that file contains commit hash
commitRe, _ := regexp.Compile("^([0-9a-f]{40})$") commitRe, _ := regexp.Compile("^([0-9a-f]{40})$")
if commit := commitRe.FindString(head); commit != "" && env.Commit == "" { if commit := commitRe.FindString(head); commit != "" && env.Commit == "" {
env.Commit = commit env.Commit = commit