diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 1aad266d51..10d7fd3ca4 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2704,6 +2704,10 @@ class Formula super end + # Whether this formula was loaded using the formulae.brew.sh API + # @private + attr_accessor :loaded_from_api + # Whether this formula contains OS/arch-specific blocks # (e.g. `on_macos`, `on_arm`, `on_monterey :or_older`, `on_system :linux, macos: :big_sur_or_newer`). # @private diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 5b5918c019..b375f8dfc0 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -1202,6 +1202,7 @@ class FormulaInstaller tab.unused_options = [] tab.built_as_bottle = true tab.poured_from_bottle = true + tab.loaded_from_api = formula.class.loaded_from_api tab.installed_as_dependency = installed_as_dependency? tab.installed_on_request = installed_on_request? tab.time = Time.now.to_i diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 9c5761ce4d..a043518bb0 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -217,6 +217,7 @@ module Formulary end end + klass.loaded_from_api = true mod.const_set(class_s, klass) cache[:api] ||= {} diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 8dba8022f6..06a0152de5 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -31,6 +31,7 @@ class Tab < OpenStruct "installed_as_dependency" => false, "installed_on_request" => false, "poured_from_bottle" => false, + "loaded_from_api" => false, "time" => Time.now.to_i, "source_modified_time" => formula.source_modified_time.to_i, "compiler" => compiler, @@ -189,6 +190,7 @@ class Tab < OpenStruct "installed_as_dependency" => false, "installed_on_request" => false, "poured_from_bottle" => false, + "loaded_from_api" => false, "time" => nil, "source_modified_time" => 0, "stdlib" => nil, @@ -332,6 +334,7 @@ class Tab < OpenStruct "unused_options" => unused_options.as_flags, "built_as_bottle" => built_as_bottle, "poured_from_bottle" => poured_from_bottle, + "loaded_from_api" => loaded_from_api, "installed_as_dependency" => installed_as_dependency, "installed_on_request" => installed_on_request, "changed_files" => changed_files&.map(&:to_s), @@ -384,6 +387,7 @@ class Tab < OpenStruct "Built from source" end + s << "using the formulae.brew.sh API" if loaded_from_api s << Time.at(time).strftime("on %Y-%m-%d at %H:%M:%S") if time unless used_options.empty?