Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions pkg/version/fixbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,38 @@

package version

import "runtime/debug"
import (
"runtime/debug"
"strings"
)

func init() {
fixBuild = buildInfoFixBuild
}

func buildInfoFixBuild(v *Version) {
// Return if v.Build already set, but not if it is Git ident expand file blob hash
if !strings.HasPrefix(v.Build, "$Id: ") && !strings.HasSuffix(v.Build, " $") {
Copy link
Contributor Author

@codeaucafe codeaucafe Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically don't need this IF the $Id$ is removed but I think its best to keep as fallback/backwards compatibility

return
}

info, ok := debug.ReadBuildInfo()
if !ok {
return
}
for i := range info.Settings {
if info.Settings[i].Key == "gitrevision" {
v.Build = info.Settings[i].Value
break

for _, setting := range info.Settings {
if setting.Key == "vcs.revision" {
v.Build = setting.Value
return
}
}

// If we didn't find vcs.revision, try the old key for backward compatibility
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leaving as backwards compatibility fall back

for _, setting := range info.Settings {
if setting.Key == "gitrevision" {
v.Build = setting.Value
return
}
}
}