From 6c870db1f18867617da84dfd73b7a2c2ef47d1b7 Mon Sep 17 00:00:00 2001 From: Jo Date: Tue, 21 Feb 2023 02:51:52 +0100 Subject: [PATCH] fix(aur): respect -uu for AUR downgrade (#1925) respect -uu for AUR downgrade --- pkg/upgrade/service.go | 2 +- pkg/upgrade/sources.go | 4 ++-- pkg/upgrade/sources_test.go | 2 +- upgrade.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/upgrade/service.go b/pkg/upgrade/service.go index c249ed239..e90d6c542 100644 --- a/pkg/upgrade/service.go +++ b/pkg/upgrade/service.go @@ -74,7 +74,7 @@ func (u *UpgradeService) upGraph(ctx context.Context, graph *topo.Graph[string, aurdata[pkg.Name] = pkg } - aurUp = UpAUR(remote, aurdata, u.cfg.TimeUpdate) + aurUp = UpAUR(remote, aurdata, u.cfg.TimeUpdate, enableDowngrade) } if u.cfg.Devel { diff --git a/pkg/upgrade/sources.go b/pkg/upgrade/sources.go index 5cd48122e..3c2d155fc 100644 --- a/pkg/upgrade/sources.go +++ b/pkg/upgrade/sources.go @@ -60,7 +60,7 @@ func printIgnoringPackage(pkg db.IPackage, newPkgVersion string) { // UpAUR gathers foreign packages and checks if they have new versions. // Output: Upgrade type package list. -func UpAUR(remote map[string]db.IPackage, aurdata map[string]*query.Pkg, timeUpdate bool) UpSlice { +func UpAUR(remote map[string]db.IPackage, aurdata map[string]*query.Pkg, timeUpdate, enableDowngrade bool) UpSlice { toUpgrade := UpSlice{Up: make([]Upgrade, 0), Repos: []string{"aur"}} for name, pkg := range remote { @@ -70,7 +70,7 @@ func UpAUR(remote map[string]db.IPackage, aurdata map[string]*query.Pkg, timeUpd } if (timeUpdate && (int64(aurPkg.LastModified) > pkg.BuildDate().Unix())) || - (db.VerCmp(pkg.Version(), aurPkg.Version) < 0) { + (db.VerCmp(pkg.Version(), aurPkg.Version) < 0) || enableDowngrade { if pkg.ShouldIgnore() { printIgnoringPackage(pkg, aurPkg.Version) } else { diff --git a/pkg/upgrade/sources_test.go b/pkg/upgrade/sources_test.go index ece0e1886..bffa84752 100644 --- a/pkg/upgrade/sources_test.go +++ b/pkg/upgrade/sources_test.go @@ -71,7 +71,7 @@ func Test_upAUR(t *testing.T) { t.Run(tt.name, func(t *testing.T) { t.Parallel() - got := UpAUR(tt.args.remote, tt.args.aurdata, tt.args.timeUpdate) + got := UpAUR(tt.args.remote, tt.args.aurdata, tt.args.timeUpdate, false) assert.EqualValues(t, tt.want, got) }) } diff --git a/upgrade.go b/upgrade.go index 66dc97563..5d3a9b45e 100644 --- a/upgrade.go +++ b/upgrade.go @@ -86,7 +86,7 @@ func upList(ctx context.Context, wg.Add(1) go func() { - aurUp = upgrade.UpAUR(remote, aurdata, config.TimeUpdate) + aurUp = upgrade.UpAUR(remote, aurdata, config.TimeUpdate, enableDowngrade) wg.Done() }()