Print an error message when a package isn't found when using -Si (#2718)

This commit is contained in:
Joey Holtzman
2025-12-21 07:41:03 -06:00
committed by GitHub
parent dd0f44c78d
commit 74e3cf80dd

View File

@@ -9,6 +9,7 @@ import (
aur "github.com/Jguer/aur"
alpm "github.com/Jguer/go-alpm/v2"
mapset "github.com/deckarep/golang-set/v2"
"github.com/leonelquinteros/gotext"
"github.com/Jguer/yay/v12/pkg/db"
"github.com/Jguer/yay/v12/pkg/query"
@@ -37,9 +38,9 @@ func syncInfo(ctx context.Context, run *runtime.Runtime,
cmdArgs *parser.Arguments, pkgS []string, dbExecutor db.Executor,
) error {
var (
info []aur.Pkg
err error
missing = false
remoteAurPkgs []aur.Pkg
err error
missing = false
)
pkgS = query.RemoveInvalidTargets(run.Logger, pkgS, run.Cfg.Mode)
@@ -77,15 +78,26 @@ func syncInfo(ctx context.Context, run *runtime.Runtime,
noDB = append(noDB, name)
}
info, err = run.AURClient.Get(ctx, &aur.Query{
remoteAurPkgs, err = run.AURClient.Get(ctx, &aur.Query{
Needles: noDB,
By: aur.Name,
})
if err != nil {
missing = true
run.Logger.Errorln(err)
}
// Check for any missing packages and print errors for any not found
found := mapset.NewThreadUnsafeSet[string]()
for i := range remoteAurPkgs {
found.Add(remoteAurPkgs[i].Name)
}
for _, name := range noDB {
if !found.Contains(name) {
missing = true
run.Logger.Errorln(gotext.Get("No AUR package found for"), " ", name)
}
}
}
if len(repoS) != 0 || (len(aurS) == 0 && len(repoS) == 0) {
@@ -100,12 +112,8 @@ func syncInfo(ctx context.Context, run *runtime.Runtime,
}
}
if len(aurS) != len(info) {
missing = true
}
for i := range info {
printInfo(run.Logger, run.Cfg, &info[i], cmdArgs.ExistsDouble("i"))
for i := range remoteAurPkgs {
printInfo(run.Logger, run.Cfg, &remoteAurPkgs[i], cmdArgs.ExistsDouble("i"))
}
if missing {