fix(aur): respect -uu for AUR downgrade (#1925)

respect -uu for AUR downgrade
This commit is contained in:
Jo 2023-02-21 02:51:52 +01:00 committed by GitHub
parent f0433cc339
commit 6c870db1f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View File

@ -74,7 +74,7 @@ func (u *UpgradeService) upGraph(ctx context.Context, graph *topo.Graph[string,
aurdata[pkg.Name] = pkg aurdata[pkg.Name] = pkg
} }
aurUp = UpAUR(remote, aurdata, u.cfg.TimeUpdate) aurUp = UpAUR(remote, aurdata, u.cfg.TimeUpdate, enableDowngrade)
} }
if u.cfg.Devel { if u.cfg.Devel {

View File

@ -60,7 +60,7 @@ func printIgnoringPackage(pkg db.IPackage, newPkgVersion string) {
// UpAUR gathers foreign packages and checks if they have new versions. // UpAUR gathers foreign packages and checks if they have new versions.
// Output: Upgrade type package list. // 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"}} toUpgrade := UpSlice{Up: make([]Upgrade, 0), Repos: []string{"aur"}}
for name, pkg := range remote { 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())) || 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() { if pkg.ShouldIgnore() {
printIgnoringPackage(pkg, aurPkg.Version) printIgnoringPackage(pkg, aurPkg.Version)
} else { } else {

View File

@ -71,7 +71,7 @@ func Test_upAUR(t *testing.T) {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() 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) assert.EqualValues(t, tt.want, got)
}) })
} }

View File

@ -86,7 +86,7 @@ func upList(ctx context.Context,
wg.Add(1) wg.Add(1)
go func() { go func() {
aurUp = upgrade.UpAUR(remote, aurdata, config.TimeUpdate) aurUp = upgrade.UpAUR(remote, aurdata, config.TimeUpdate, enableDowngrade)
wg.Done() wg.Done()
}() }()