mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-10-20 10:57:09 +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:
1 parent
ff77fbf5d9
commit
e19a615641
1 file changed
+2
-2
+2
-2
@@ -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