From 4d5cca8ef248c64e5ba8bb81e13fdf72ea8a61fc Mon Sep 17 00:00:00 2001 From: "Aleksey @soar Smyrnov" Date: Mon, 7 Jan 2019 13:49:53 +0300 Subject: [PATCH] Comments for commit extraction Requested in https://github.com/ethereum/go-ethereum/pull/18315 --- internal/build/env.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/build/env.go b/internal/build/env.go index bfa054c36c..9f7b18673f 100644 --- a/internal/build/env.go +++ b/internal/build/env.go @@ -88,6 +88,9 @@ func LocalEnv() Environment { if splits := strings.Split(head, " "); len(splits) == 2 { head = splits[1] } 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})$") if commit := commitRe.FindString(head); commit != "" && env.Commit == "" { env.Commit = commit