mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-04-20 19:38:39 +00:00
In PackageList, sort the package version from latest to oldest
This enables us to return the latest version of a package when no version is specified rather than the oldest. Therefore, we don't need to modify the search algorithm to return the latest version of a package.
This commit is contained in:
@@ -300,13 +300,13 @@ func (l *PackageList) Swap(i, j int) {
|
||||
l.packagesIndex[i], l.packagesIndex[j] = l.packagesIndex[j], l.packagesIndex[i]
|
||||
}
|
||||
|
||||
// Compare compares two packages by name in lexographical order and version
|
||||
// Compare compares two packages by name (lexographical) and version (latest to oldest)
|
||||
func (l *PackageList) Less(i, j int) bool {
|
||||
iPkg := l.packagesIndex[i]
|
||||
jPkg := l.packagesIndex[j]
|
||||
|
||||
if iPkg.Name == jPkg.Name {
|
||||
return CompareVersions(iPkg.Version, jPkg.Version) == -1
|
||||
return CompareVersions(iPkg.Version, jPkg.Version) == 1
|
||||
}
|
||||
|
||||
return iPkg.Name < jPkg.Name
|
||||
|
||||
Reference in New Issue
Block a user