Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(query): reduce verbosity of -Qu #2060

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/db/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"time"

alpm "github.com/Jguer/go-alpm/v2"

"github.com/Jguer/yay/v12/pkg/text"
)

type (
Expand Down Expand Up @@ -59,4 +61,6 @@ type Executor interface {
SyncPackages(...string) []IPackage
SyncSatisfier(string) IPackage
SyncSatisfierExists(string) bool

SetLogger(logger *text.Logger)
}
6 changes: 6 additions & 0 deletions pkg/db/ialpm/high_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package ialpm

import (
alpm "github.com/Jguer/go-alpm/v2"

"github.com/Jguer/yay/v12/pkg/text"
)

// GetPackageNamesBySource returns package names with and without correspondence in SyncDBS respectively.
Expand Down Expand Up @@ -43,3 +45,7 @@ func (ae *AlpmExecutor) InstalledSyncPackageNames() []string {

return ae.installedSyncPkgNames
}

func (ae *AlpmExecutor) SetLogger(logger *text.Logger) {
ae.log = logger
}
9 changes: 5 additions & 4 deletions pkg/upgrade/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func UpDevel(
for pkgName, pkg := range remote {
if localCache.ToUpgrade(ctxTimeout, pkgName) {
if _, ok := aurdata[pkgName]; !ok {
text.Warnln(gotext.Get("ignoring package devel upgrade (no AUR info found):"), pkgName)
log.Warnln(gotext.Get("ignoring package devel upgrade (no AUR info found):"), pkgName)
continue
}

Expand All @@ -53,11 +53,12 @@ func UpDevel(
return toUpgrade
}

func printIgnoringPackage(logger *text.Logger, pkg db.IPackage, newPkgVersion string) {
func printIgnoringPackage(log *text.Logger, pkg db.IPackage, newPkgVersion string) {
left, right := GetVersionDiff(pkg.Version(), newPkgVersion)

logger.Warnln(gotext.Get("%s: ignoring package upgrade (%s => %s)",
text.Cyan(pkg.Name()),
pkgName := pkg.Name()
log.Warnln(gotext.Get("%s: ignoring package upgrade (%s => %s)",
text.Cyan(pkgName),
left, right,
))
}
Expand Down
11 changes: 5 additions & 6 deletions print.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,9 @@ func printUpdateList(ctx context.Context, cfg *settings.Configuration, cmdArgs *
dbExecutor db.Executor, enableDowngrade bool, filter upgrade.Filter,
) error {
quietMode := cmdArgs.ExistsArg("q", "quiet")
logger := cfg.Runtime.Logger.Child("update-list")
if quietMode { // TODO: handle quiet mode in a better way
logger = text.NewLogger(io.Discard, os.Stdin, cfg.Debug, "update-list")
}
// TODO: handle quiet mode in a better way
logger := text.NewLogger(io.Discard, os.Stdin, cfg.Debug, "update-list")
dbExecutor.SetLogger(logger.Child("db"))

targets := mapset.NewThreadUnsafeSet(cmdArgs.Targets...)
grapher := dep.NewGrapher(dbExecutor, cfg.Runtime.AURCache, false, settings.NoConfirm,
Expand Down Expand Up @@ -141,8 +140,8 @@ func printUpdateList(ctx context.Context, cfg *settings.Configuration, cmdArgs *
if quietMode {
fmt.Printf("%s\n", pkgName)
} else {
fmt.Printf("%s %s -> %s\n", text.Bold(pkgName), text.Green(ii.LocalVersion),
text.Green(ii.Version))
fmt.Printf("%s %s -> %s\n", text.Bold(pkgName), text.Bold(text.Green(ii.LocalVersion)),
text.Bold(text.Green(ii.Version)))
}

targets.Remove(pkgName)
Expand Down