mirror of
https://github.com/Jguer/yay
synced 2024-10-05 23:59:13 +00:00
fix(clean_menu): optimize any base installed
This commit is contained in:
parent
a43fbacc96
commit
f3c3e2e4d4
|
@ -36,11 +36,7 @@ func cleanNumberMenu(bases []dep.Base, installed stringset.StringSet) ([]dep.Bas
|
|||
if !cOtherInclude.Get("n") && !cOtherInclude.Get("none") {
|
||||
for i, base := range bases {
|
||||
pkg := base.Pkgbase()
|
||||
anyInstalled := false
|
||||
|
||||
for _, b := range base {
|
||||
anyInstalled = anyInstalled || installed.Get(b.Name)
|
||||
}
|
||||
anyInstalled := base.AnyIsInSet(installed)
|
||||
|
||||
dir := filepath.Join(config.BuildDir, pkg)
|
||||
if _, err := os.Stat(dir); os.IsNotExist(err) {
|
||||
|
|
13
install.go
13
install.go
|
@ -564,12 +564,7 @@ func pkgbuildNumberMenu(bases []dep.Base, installed stringset.StringSet) {
|
|||
toPrint += fmt.Sprintf(text.Magenta("%3d")+" %-40s", len(bases)-n,
|
||||
text.Bold(base.String()))
|
||||
|
||||
anyInstalled := false
|
||||
for _, b := range base {
|
||||
anyInstalled = anyInstalled || installed.Get(b.Name)
|
||||
}
|
||||
|
||||
if anyInstalled {
|
||||
if base.AnyIsInSet(installed) {
|
||||
toPrint += text.Bold(text.Green(gotext.Get(" (Installed)")))
|
||||
}
|
||||
|
||||
|
@ -625,11 +620,7 @@ func editDiffNumberMenu(bases []dep.Base, installed stringset.StringSet, diff bo
|
|||
if !eOtherInclude.Get("n") && !eOtherInclude.Get("none") {
|
||||
for i, base := range bases {
|
||||
pkg := base.Pkgbase()
|
||||
anyInstalled := false
|
||||
|
||||
for _, b := range base {
|
||||
anyInstalled = anyInstalled || installed.Get(b.Name)
|
||||
}
|
||||
anyInstalled := base.AnyIsInSet(installed)
|
||||
|
||||
if !eIsInclude && eExclude.Get(len(bases)-i) {
|
||||
continue
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package dep
|
||||
|
||||
import aur "github.com/Jguer/yay/v11/pkg/query"
|
||||
import (
|
||||
aur "github.com/Jguer/yay/v11/pkg/query"
|
||||
"github.com/Jguer/yay/v11/pkg/stringset"
|
||||
)
|
||||
|
||||
// Base is an AUR base package.
|
||||
type Base []*aur.Pkg
|
||||
|
@ -20,6 +23,16 @@ func (b Base) URLPath() string {
|
|||
return b[0].URLPath
|
||||
}
|
||||
|
||||
func (b Base) AnyIsInSet(set stringset.StringSet) bool {
|
||||
for _, pkg := range b {
|
||||
if set.Get(pkg.Name) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// Packages foo and bar from a pkgbase named base would print like so:
|
||||
// base (foo bar).
|
||||
func (b Base) String() string {
|
||||
|
|
Loading…
Reference in a new issue