Skip to content

Commit

Permalink
Simplify IsGreater
Browse files Browse the repository at this point in the history
Co-authored-by: Evan Forbes <[email protected]>
  • Loading branch information
cmwaters and evan-forbes authored Nov 2, 2023
1 parent 4ac4bdb commit 93a42f9
Showing 1 changed file with 9 additions and 24 deletions.
33 changes: 9 additions & 24 deletions test/e2e/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,19 @@ func (v Version) String() string {
}

func (v Version) IsGreater(v2 Version) bool {
if v.Major > v2.Major {
return true
if v.Major != v2.Major {
return v.Major > v2.Major
}
if v.Major < v2.Major {
return false
if v.Minor != v2.Minor {
return v.Minor > v2.Minor
}
if v.Minor > v2.Minor {
return true
if v.Patch != v2.Patch {
return v.Patch > v2.Patch
}
if v.Minor < v2.Minor {
return false
if v.IsRC != v2.IsRC {
return !v.IsRC
}
if v.Patch > v2.Patch {
return true
}
if v.Patch < v2.Patch {
return false
}
if !v.IsRC && v2.IsRC {
return true
}
if v.IsRC && !v2.IsRC {
return false
}
if v.RC > v2.RC {
return true
}
return false
return v.RC > v2.RC
}

type VersionSet []Version
Expand Down

0 comments on commit 93a42f9

Please sign in to comment.