chore(install): prefer short form ifs

This commit is contained in:
jguer 2021-08-23 17:37:58 +02:00
parent b7f9a5e677
commit 1869bbe291
No known key found for this signature in database
GPG Key ID: 6D6CC9BEA8556B35

View File

@ -68,7 +68,7 @@ func asexp(ctx context.Context, cmdArgs *parser.Arguments, pkgs []string) (err e
} }
// Install handles package installs. // Install handles package installs.
func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Executor, ignoreProviders bool) (err error) { func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Executor, ignoreProviders bool) error {
var ( var (
incompatible stringset.StringSet incompatible stringset.StringSet
do *dep.Order do *dep.Order
@ -88,24 +88,21 @@ func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Execu
if config.Runtime.Mode.AtLeastRepo() { if config.Runtime.Mode.AtLeastRepo() {
if config.CombinedUpgrade { if config.CombinedUpgrade {
if refreshArg { if refreshArg {
err = earlyRefresh(ctx, cmdArgs) if errR := earlyRefresh(ctx, cmdArgs); errR != nil {
if err != nil {
return fmt.Errorf(gotext.Get("error refreshing databases")) return fmt.Errorf(gotext.Get("error refreshing databases"))
} }
} }
} else if refreshArg || sysupgradeArg || len(cmdArgs.Targets) > 0 { } else if refreshArg || sysupgradeArg || len(cmdArgs.Targets) > 0 {
err = earlyPacmanCall(ctx, cmdArgs, dbExecutor) if errP := earlyPacmanCall(ctx, cmdArgs, dbExecutor); errP != nil {
if err != nil { return errP
return err
} }
} }
} }
// we may have done -Sy, our handle now has an old // we may have done -Sy, our handle now has an old
// database. // database.
err = dbExecutor.RefreshHandle() if errRefresh := dbExecutor.RefreshHandle(); errRefresh != nil {
if err != nil { return errRefresh
return err
} }
localNames, remoteNames, err := query.GetPackageNamesBySource(dbExecutor) localNames, remoteNames, err := query.GetPackageNamesBySource(dbExecutor)
@ -155,9 +152,8 @@ func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Execu
return err return err
} }
err = dp.CheckMissing(noDeps, noCheck) if errC := dp.CheckMissing(noDeps, noCheck); errC != nil {
if err != nil { return errC
return err
} }
if len(dp.Aur) == 0 { if len(dp.Aur) == 0 {
@ -184,9 +180,9 @@ func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Execu
return fmt.Errorf(gotext.Get("refusing to install AUR packages as root, aborting")) return fmt.Errorf(gotext.Get("refusing to install AUR packages as root, aborting"))
} }
conflicts, err := dp.CheckConflicts(config.UseAsk, settings.NoConfirm, noDeps) conflicts, errCC := dp.CheckConflicts(config.UseAsk, settings.NoConfirm, noDeps)
if err != nil { if errCC != nil {
return err return errCC
} }
do = dep.GetOrder(dp, noDeps, noCheck) do = dep.GetOrder(dp, noDeps, noCheck)
@ -265,10 +261,7 @@ func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Execu
return errA return errA
} }
var ( var toDiff, toEdit []dep.Base
toDiff []dep.Base
toEdit []dep.Base
)
if config.DiffMenu { if config.DiffMenu {
pkgbuildNumberMenu(do.Aur, remoteNamesCache) pkgbuildNumberMenu(do.Aur, remoteNamesCache)
@ -304,9 +297,8 @@ func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Execu
settings.NoConfirm = oldValue settings.NoConfirm = oldValue
} }
err = mergePkgbuilds(ctx, do.Aur) if errM := mergePkgbuilds(ctx, do.Aur); errM != nil {
if err != nil { return errM
return err
} }
srcinfos, err = parseSrcinfoFiles(do.Aur, true) srcinfos, err = parseSrcinfoFiles(do.Aur, true)
@ -349,9 +341,8 @@ func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Execu
} }
if config.PGPFetch { if config.PGPFetch {
err = pgp.CheckPgpKeys(do.Aur, srcinfos, config.GpgBin, config.GpgFlags, settings.NoConfirm) if errCPK := pgp.CheckPgpKeys(do.Aur, srcinfos, config.GpgBin, config.GpgFlags, settings.NoConfirm); errCPK != nil {
if err != nil { return errCPK
return err
} }
} }
@ -396,14 +387,12 @@ func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Execu
config.AURURL, config.Runtime.CompletionPath, config.CompletionInterval, false) config.AURURL, config.Runtime.CompletionPath, config.CompletionInterval, false)
}() }()
err = downloadPKGBUILDSourceFanout(ctx, config.Runtime.CmdBuilder, config.BuildDir, do.Aur, incompatible) if errP := downloadPKGBUILDSourceFanout(ctx, config.Runtime.CmdBuilder, config.BuildDir, do.Aur, incompatible); errP != nil {
if err != nil { text.Errorln(errP)
text.Errorln(err)
} }
err = buildInstallPkgbuilds(ctx, cmdArgs, dbExecutor, dp, do, srcinfos, incompatible, conflicts, noDeps, noCheck) if errB := buildInstallPkgbuilds(ctx, cmdArgs, dbExecutor, dp, do, srcinfos, incompatible, conflicts, noDeps, noCheck); errB != nil {
if err != nil { return errB
return err
} }
return nil return nil