Skip to content

Commit

Permalink
simplify stew config command
Browse files Browse the repository at this point in the history
  • Loading branch information
marwanhawari committed Jan 21, 2025
1 parent a251782 commit 1bcaf19
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand All @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 1bcaf19

Please sign in to comment.