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.
This commit is contained in:
Martin HS 2024-08-19 13:35:04 +02:00 committed by GitHub
parent 710c3f32ac
commit 60db6a7b42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -111,6 +111,7 @@ func LocalEnv() Environment {
commitRe, _ := regexp.Compile("^([0-9a-f]{40})$")
if commit := commitRe.FindString(head); commit != "" && env.Commit == "" {
env.Commit = commit
env.Date = getDate(env.Commit)
}
return env
}