From b766d5ef809e6c9ff9c435dfd8632cba992e5259 Mon Sep 17 00:00:00 2001 From: ferreo Date: Mon, 5 Aug 2024 19:42:08 +0100 Subject: [PATCH] Fix issue with getting newest package version + upgrade to go 1.23 RC2 --- go.mod | 2 +- packages/packages.go | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index cbe4e45..83a361e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module brunel -go 1.22.5 +go 1.23 require ( github.com/alphadose/haxmap v1.4.0 diff --git a/packages/packages.go b/packages/packages.go index 68e83af..274b745 100644 --- a/packages/packages.go +++ b/packages/packages.go @@ -246,20 +246,21 @@ func processPackageResult(packages *haxmap.Map[string, domain.SourcePackage], re }) return true } + + pk.Version = getHighestVer(pk.Version, newPkg.Version) pkg, ok := pk.Packages.Get(newKey) if !ok { pk.Packages.Set(newKey, newPkg) - return true - } - mVer, _ := version.Parse(pkg.Version) - extVer, _ := version.Parse(strings.Split(newPkg.Version, "+b")[0]) - cmpVal := version.Compare(extVer, mVer) - if cmpVal >= 0 { - pk.Version = getHighestVer(pkg.Version, newPkg.Version) - pk.Packages.Set(newKey, newPkg) - packages.Set(newPkg.Source, pk) - return true + } else { + mVer, _ := version.Parse(pkg.Version) + extVer, _ := version.Parse(strings.Split(newPkg.Version, "+b")[0]) + cmpVal := version.Compare(extVer, mVer) + if cmpVal >= 0 { + pk.Packages.Set(newKey, newPkg) + } } + + packages.Set(newPkg.Source, pk) return true }) } @@ -285,9 +286,9 @@ func ProcessStalePackages(internalPackages *haxmap.Map[string, domain.SourcePack if ver != matchedPackage.Version { matchedPackage.NewVersion = ver matchedPackage.Status = domain.Stale + internalPackages.Set(newPackage, matchedPackage) } - internalPackages.Set(newPackage, matchedPackage) return true }) }