Skip to content

Commit

Permalink
LH-89808: Remove build number from compare/equals so that they are ig…
Browse files Browse the repository at this point in the history
…nored when checking upgradeable or not. (#160)
  • Loading branch information
isak-cisco authored Feb 12, 2025
1 parent 63d1766 commit a958865
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 4 additions & 7 deletions client/model/ftd/ftd_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func (v *Version) GreaterThanEqual(o *Version) bool {
}

// Equal tests if two versions are equal to each other.
// Note, versions can be equal with different metadata since metadata
// is not considered part of the comparable version.
// Note, versions can be equal with different build numbers or metadata
// since they are not considered part of the comparable version.
func (v *Version) Equal(o *Version) bool {
if v == o {
return true
Expand All @@ -176,8 +176,8 @@ func (v *Version) Equal(o *Version) bool {
// Compare compares this version to another one. It returns -1, 0, or 1 if
// the version smaller, equal, or larger than the other version.
//
// Versions are compared by X.Y.Z. Build metadata is ignored. Prerelease is
// lower than the version without a prerelease. Compare always takes into account
// Versions are compared by W.X.Y.Z. Build numbers and metadata are ignored.
// Prerelease is lower than the version without a prerelease. Compare always takes into account
// prereleases. If you want to work with ranges using typical range syntaxes that
// skip prereleases if the range is not looking for them use constraints.
func (v *Version) Compare(o *Version) int {
Expand All @@ -193,9 +193,6 @@ func (v *Version) Compare(o *Version) int {
if d := compareSegment(v.Hotfix(), o.Hotfix()); d != 0 {
return d
}
if d := compareSegment(v.Buildnum(), o.Buildnum()); d != 0 {
return d
}

return 0
}
Expand Down
6 changes: 3 additions & 3 deletions client/model/ftd/ftd_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ func TestFtdVersionComparison(t *testing.T) {
versionOneStr: "7.2.0-68",
versionTwoStr: "7.2.0-69",
assertFunc: func(t *testing.T, versionOne, versionTwo *ftd.Version) {
assert.True(t, versionOne.LessThan(versionTwo))
assert.True(t, versionTwo.GreaterThan(versionOne))
assert.False(t, versionTwo.Equal(versionOne))
assert.False(t, versionOne.LessThan(versionTwo))
assert.False(t, versionTwo.GreaterThan(versionOne))
assert.True(t, versionTwo.Equal(versionOne))
},
},
{
Expand Down

0 comments on commit a958865

Please sign in to comment.