Browse Source

Fix issues with dry-run package reporting

- Filter orphans to only those not in requested packages
- Fix Removed count to reflect only actual removals
master
AI Bot 7 hours ago committed by Riyyi
parent
commit
e64382c1bd
  1. 17
      pkg/pacman/read/read.go

17
pkg/pacman/read/read.go

@ -85,7 +85,7 @@ func DryRun(packages []string) (*output.Result, error) {
if info == nil || (!info.Exists && !info.InAUR) { if info == nil || (!info.Exists && !info.InAUR) {
return nil, fmt.Errorf("package not found: %s", pkg) return nil, fmt.Errorf("package not found: %s", pkg)
} }
if info.InAUR { if info.InAUR && !info.Installed {
aurPkgs = append(aurPkgs, pkg) aurPkgs = append(aurPkgs, pkg)
} else if !info.Installed { } else if !info.Installed {
toInstall = append(toInstall, pkg) 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()) 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()) fmt.Fprintf(os.Stderr, "[debug] DryRun: done (%.2fs)\n", time.Since(start).Seconds())
return &output.Result{ return &output.Result{
Installed: len(toInstall) + len(aurPkgs), Installed: len(toInstall) + len(aurPkgs),
Removed: len(orphans), Removed: len(toRemove),
ToInstall: append(toInstall, aurPkgs...), ToInstall: append(toInstall, aurPkgs...),
ToRemove: orphans, ToRemove: toRemove,
}, nil }, nil
} }

Loading…
Cancel
Save