Skip to content

Commit

Permalink
Internal: delete unused common.VersionLessThan()
Browse files Browse the repository at this point in the history
The function is a leftover from the image definitions split and it is
not used. Moreover, the `images` copy of it is being reimplemented by
[1]. It is better to remove this copy to prevent any unintended use of
it or confusion.

[1] osbuild/images#195

Signed-off-by: Tomáš Hozza <[email protected]>
  • Loading branch information
thozza committed Oct 10, 2023
1 parent b228886 commit 43b36b8
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions internal/common/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,3 @@ func readOSRelease(r io.Reader) (map[string]string, error) {

return osrelease, nil
}

// Returns true if the version represented by the first argument is
// semantically older than the second.
// Meant to be used for comparing distro versions for differences between minor
// releases.
// Evaluates to false if a and b are equal.
// Assumes any missing components are 0, so 8 < 8.1.
func VersionLessThan(a, b string) bool {
aParts := strings.Split(a, ".")
bParts := strings.Split(b, ".")

// pad shortest argument with zeroes
for len(aParts) < len(bParts) {
aParts = append(aParts, "0")
}
for len(bParts) < len(aParts) {
bParts = append(bParts, "0")
}

for idx := 0; idx < len(aParts); idx++ {
if aParts[idx] < bParts[idx] {
return true
} else if aParts[idx] > bParts[idx] {
return false
}
}

// equal
return false
}

0 comments on commit 43b36b8

Please sign in to comment.