Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
SubhasmitaSw committed Mar 15, 2022
1 parent a587467 commit 5502f9c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions util/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ func (v buildIdentifier) compare(o buildIdentifier) int {
}

type comparer struct {
buildTags bool
buildTags bool
withoutPreReleases bool
}

// CompareOption is a configuration option for Compare.
Expand Down Expand Up @@ -213,16 +214,17 @@ func WithoutPreReleases() CompareOption {
// 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)
}

if c.withoutPreReleases {
a.Pre = nil
b.Pre = nil
}

if c.buildTags {
if comp := a.Compare(b); comp != 0 {
return comp
Expand Down

0 comments on commit 5502f9c

Please sign in to comment.