Skip to content

Commit

Permalink
bundle: add upgrade switch and command.
Browse files Browse the repository at this point in the history
This allows overriding the `HOMEBREW_BUNDLE_NO_UPGRADE` environment
variable. The environment variable wasn't really documented specifically
before so let's do that here, too.

Also, add `brew bundle upgrade` for a shorthand version.
  • Loading branch information
MikeMcQuaid committed Jan 23, 2025
1 parent f5acb38 commit af9f01c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
17 changes: 14 additions & 3 deletions cmd/bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class BundleCmd < AbstractCommand
You can skip the installation of dependencies by adding space-separated values to one or more of the following environment variables: `HOMEBREW_BUNDLE_BREW_SKIP`, `HOMEBREW_BUNDLE_CASK_SKIP`, `HOMEBREW_BUNDLE_MAS_SKIP`, `HOMEBREW_BUNDLE_WHALEBREW_SKIP`, `HOMEBREW_BUNDLE_TAP_SKIP`.
`brew bundle upgrade`:
Shorthand for `brew bundle install --upgrade`.
`brew bundle dump`:
Write all installed casks/formulae/images/taps into a `Brewfile` in the current directory.
Expand Down Expand Up @@ -66,7 +69,11 @@ class BundleCmd < AbstractCommand
env: :bundle_no_upgrade,
description: "`install` does not run `brew upgrade` on outdated dependencies. " \
"`check` does not check for outdated dependencies. " \
"Note they may still be upgraded by `brew install` if needed."
"Note they may still be upgraded by `brew install` if needed." \
"This is enabled by default if `HOMEBREW_BUNDLE_NO_UPGRADE` is set."
switch "--upgrade",
description: "`install` runs `brew upgrade` on outdated dependencies, " \
"even if `HOMEBREW_BUNDLE_NO_UPGRADE` is set. "
switch "-f", "--force",
description: "`install` runs with `--force`/`--overwrite`. " \
"`dump` overwrites an existing `Brewfile`. " \
Expand Down Expand Up @@ -126,15 +133,19 @@ def run
global = args.global?
file = args.file
args.zap?
no_upgrade = args.no_upgrade?
no_upgrade = if args.upgrade? || subcommand == "upgrade"
false
else
args.no_upgrade?
end
verbose = args.verbose?
force = args.force?
zap = args.zap?

no_type_args = !args.brews? && !args.casks? && !args.taps? && !args.mas? && !args.whalebrew? && !args.vscode?

case subcommand
when nil, "install"
when nil, "install", "upgrade"
Bundle::Commands::Install.run(
global:, file:, no_upgrade:, verbose:, force:,
no_lock: args.no_lock?,
Expand Down
3 changes: 3 additions & 0 deletions cmd/bundle.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class Homebrew::Cmd::BundleCmd::Args < Homebrew::CLI::Args
sig { returns(T::Boolean) }
def taps?; end

sig { returns(T::Boolean) }
def upgrade?; end

sig { returns(T::Boolean) }
def verbose?; end

Expand Down

0 comments on commit af9f01c

Please sign in to comment.