mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
fix(version): report correct bera-geth version when building from detached HEAD (#77)
This commit is contained in:
parent
cdd8fc239f
commit
118eb75ed3
1 changed files with 3 additions and 3 deletions
|
|
@ -156,18 +156,18 @@ func LocalEnv() Environment {
|
|||
// 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})$")
|
||||
if commit := commitRe.FindString(head); commit != "" && env.Commit == "" {
|
||||
if commit := commitRe.FindString(strings.TrimSpace(head)); commit != "" && env.Commit == "" {
|
||||
env.Commit = commit
|
||||
env.Date = getDate(env.Commit)
|
||||
}
|
||||
return env
|
||||
// Do not return early; allow tag discovery even in detached HEAD.
|
||||
}
|
||||
if env.Commit == "" {
|
||||
env.Commit = readGitFile(head)
|
||||
}
|
||||
env.Date = getDate(env.Commit)
|
||||
if env.Branch == "" {
|
||||
if head != "HEAD" {
|
||||
if strings.HasPrefix(head, "refs/heads/") {
|
||||
env.Branch = strings.TrimPrefix(head, "refs/heads/")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue