From 1bcaf1911117149a96b6d31e5140c0372caf546d Mon Sep 17 00:00:00 2001 From: Marwan Hawari Date: Mon, 20 Jan 2025 22:45:19 -0500 Subject: [PATCH] simplify stew config command --- cmd/upgrade.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/cmd/upgrade.go b/cmd/upgrade.go index f2de670..3ddd3ca 100644 --- a/cmd/upgrade.go +++ b/cmd/upgrade.go @@ -12,7 +12,7 @@ import ( // Upgrade is executed when you run `stew upgrade` func Upgrade(upgradeAllCliFlag bool, binaryName string) { - userOS, userArch, _, systemInfo, err := stew.Initialize() + userOS, userArch, stewConfig, systemInfo, err := stew.Initialize() stew.CatchAndExit(err) if upgradeAllCliFlag && binaryName != "" { @@ -38,7 +38,7 @@ func Upgrade(upgradeAllCliFlag bool, binaryName string) { } if upgradeAllCliFlag { - upgradeAll(userOS, userArch, lockFile, systemInfo) + upgradeAll(userOS, userArch, lockFile, systemInfo, stewConfig) } else { err := upgradeOne(binaryName, userOS, userArch, lockFile, systemInfo) stew.CatchAndExit(err) @@ -128,15 +128,9 @@ func upgradeOne(binaryName, userOS, userArch string, lockFile stew.LockFile, sys return nil } -func upgradeAll(userOS, userArch string, lockFile stew.LockFile, systemInfo stew.SystemInfo) { - stewConfigFilePath, err := stew.GetStewConfigFilePath(userOS) - stew.CatchAndExit(err) - stewConfig, err := stew.ReadStewConfigJSON(stewConfigFilePath) - stew.CatchAndExit(err) - excludedBinaries := stewConfig.ExcludedFromUpgradeAll - +func upgradeAll(userOS, userArch string, lockFile stew.LockFile, systemInfo stew.SystemInfo, stewConfig stew.StewConfig) { for _, pkg := range lockFile.Packages { - if _, packageIsExcluded := stew.Contains(excludedBinaries, pkg.Binary); packageIsExcluded { + if _, packageIsExcluded := stew.Contains(stewConfig.ExcludedFromUpgradeAll, pkg.Binary); packageIsExcluded { fmt.Printf("%v (excluded)\n", constants.YellowColor(pkg.Binary)) continue }