Add HOMEBREW_FORCE_API_AUTO_UPDATE

If set, this will update the Homebrew API formula or cask data even if
`HOMEBREW_NO_AUTO_UPDATE` is set.

This is useful in cases where you want to update the cached API data but
don't want to update Homebrew itself.

Co-authored-by: Bo Anderson <mail@boanderson.me>
This commit is contained in:
Mike McQuaid 2025-01-07 15:05:41 +00:00
parent 175cd9e5d5
commit d87d336c82
No known key found for this signature in database
3 changed files with 8 additions and 1 deletions

View File

@ -60,7 +60,7 @@ module Homebrew
skip_download = target.exist? &&
!target.empty? &&
(!Homebrew.auto_update_command? ||
Homebrew::EnvConfig.no_auto_update? ||
(Homebrew::EnvConfig.no_auto_update? && !Homebrew::EnvConfig.force_api_auto_update?) ||
((Time.now - stale_seconds) < target.mtime))
skip_download ||= Homebrew.running_as_root_but_not_owned_by_root?

View File

@ -223,6 +223,10 @@ module Homebrew
"e.g. `brew install ./package.rb`.",
boolean: true,
},
HOMEBREW_FORCE_API_AUTO_UPDATE: {
description: "If set, update the Homebrew API formula or cask data even if `HOMEBREW_NO_AUTO_UPDATE` is set.",
boolean: true,
},
HOMEBREW_FORCE_BREWED_CA_CERTIFICATES: {
description: "If set, always use a Homebrew-installed `ca-certificates` rather than the system version. " \
"Automatically set if the system version is too old.",

View File

@ -136,6 +136,9 @@ module Homebrew::EnvConfig
sig { returns(T.nilable(::String)) }
def forbidden_taps; end
sig { returns(T::Boolean) }
def force_api_auto_update?; end
sig { returns(T::Boolean) }
def force_brewed_ca_certificates?; end