diff --git a/util/version/version.go b/util/version/version.go index cfd4392abd62..a0d4773287ca 100644 --- a/util/version/version.go +++ b/util/version/version.go @@ -201,12 +201,23 @@ func WithBuildTags() CompareOption { } } +func WithoutPreReleases() CompareOption { + return func(c *comparer) { + c.withoutPreReleases = true + } +} + // Compare 2 semver versions. // Defaults to doing the standard semver comparison when no options are specified. // The comparison logic can be modified by passing additional compare options. // Example: using the WithBuildTags() option modifies the compare logic to also // consider build tags when comparing versions. func Compare(a, b semver.Version, options ...CompareOption) int { + if c. withoutPreReleases { + a.Pre = nil + b.Pre = nil + } + c := &comparer{} for _, o := range options { o(c)