From e637a1fa9bd6e5946bcc3e08010f6534b81cee9b Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 7 Jan 2025 15:05:41 +0000 Subject: [PATCH] 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. --- Library/Homebrew/api.rb | 2 +- Library/Homebrew/env_config.rb | 4 ++++ Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/api.rb b/Library/Homebrew/api.rb index 103ac6eec4cb9..10a1a88bb676b 100644 --- a/Library/Homebrew/api.rb +++ b/Library/Homebrew/api.rb @@ -60,7 +60,7 @@ def self.fetch_json_api_file(endpoint, target: HOMEBREW_CACHE_API/endpoint, 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? diff --git a/Library/Homebrew/env_config.rb b/Library/Homebrew/env_config.rb index 44a23c4f37c48..180c6d5b83602 100644 --- a/Library/Homebrew/env_config.rb +++ b/Library/Homebrew/env_config.rb @@ -223,6 +223,10 @@ module EnvConfig "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.", diff --git a/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi b/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi index 6852fe574ed0e..e86443e2a7a62 100644 --- a/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi +++ b/Library/Homebrew/sorbet/rbi/dsl/homebrew/env_config.rbi @@ -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