internal/build: include git-date on detached head (#30320)

When we are building in detached head, we cannot easily obtain the same information as we can if we're in non-detached head.

However, one thing we _can_ obtain is the git-hash and git-date. Currently, we omit to include the git-date into the build-info, which causes problem for reproducable builds which are on a detached head.

This change fixes it to include the date-info always.
pull/30326/head
Martin HS 1 month ago committed by GitHub
parent 710c3f32ac
commit 60db6a7b42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      internal/build/env.go

@ -111,6 +111,7 @@ func LocalEnv() Environment {
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
env.Date = getDate(env.Commit)
} }
return env return env
} }

Loading…
Cancel
Save