From e64382c1bdfc75946a7ed54b29300227986aba26 Mon Sep 17 00:00:00 2001 From: AI Bot Date: Sat, 18 Apr 2026 18:30:33 +0200 Subject: [PATCH] Fix issues with dry-run package reporting - Filter orphans to only those not in requested packages - Fix Removed count to reflect only actual removals --- pkg/pacman/read/read.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pkg/pacman/read/read.go b/pkg/pacman/read/read.go index c9975e8..d41e139 100644 --- a/pkg/pacman/read/read.go +++ b/pkg/pacman/read/read.go @@ -85,7 +85,7 @@ func DryRun(packages []string) (*output.Result, error) { if info == nil || (!info.Exists && !info.InAUR) { return nil, fmt.Errorf("package not found: %s", pkg) } - if info.InAUR { + if info.InAUR && !info.Installed { aurPkgs = append(aurPkgs, pkg) } else if !info.Installed { toInstall = append(toInstall, pkg) @@ -99,11 +99,22 @@ func DryRun(packages []string) (*output.Result, error) { } fmt.Fprintf(os.Stderr, "[debug] DryRun: orphans listed (%.2fs)\n", time.Since(start).Seconds()) + pkgSet := make(map[string]bool) + for _, p := range packages { + pkgSet[p] = true + } + var toRemove []string + for _, o := range orphans { + if !pkgSet[o] { + toRemove = append(toRemove, o) + } + } + fmt.Fprintf(os.Stderr, "[debug] DryRun: done (%.2fs)\n", time.Since(start).Seconds()) return &output.Result{ Installed: len(toInstall) + len(aurPkgs), - Removed: len(orphans), + Removed: len(toRemove), ToInstall: append(toInstall, aurPkgs...), - ToRemove: orphans, + ToRemove: toRemove, }, nil }