Fix -Qu exit code for empty update lists (#2162)

Fix -Qu exit code for empty update lists (#2061)

Previously, -Qun and -Qum without available updates could exit
with code 0 in some cases.
Also fix present and add more tests for such cases.
This commit is contained in:
smolx
2023-05-22 20:35:27 +02:00
committed by GitHub
parent ec15a5b363
commit a0a5e45fe7
2 changed files with 162 additions and 77 deletions

View File

@@ -134,6 +134,7 @@ func printUpdateList(ctx context.Context, cfg *settings.Configuration, cmdArgs *
foreignFilter := cmdArgs.ExistsArg("m", "foreign")
nativeFilter := cmdArgs.ExistsArg("n", "native")
noUpdates := true
_ = graph.ForEach(func(pkgName string, ii *dep.InstallInfo) error {
if !ii.Upgrade {
return nil
@@ -154,6 +155,7 @@ func printUpdateList(ctx context.Context, cfg *settings.Configuration, cmdArgs *
}
targets.Remove(pkgName)
noUpdates = false
}
return nil
@@ -168,7 +170,7 @@ func printUpdateList(ctx context.Context, cfg *settings.Configuration, cmdArgs *
return false
})
if missing {
if missing || noUpdates {
return fmt.Errorf("")
}