diff --git a/Library/Homebrew/cmd/outdated.rb b/Library/Homebrew/cmd/outdated.rb index d2c449823e..17f52b1f68 100644 --- a/Library/Homebrew/cmd/outdated.rb +++ b/Library/Homebrew/cmd/outdated.rb @@ -98,7 +98,8 @@ module Homebrew if verbose? outdated_kegs = f.outdated_kegs(fetch_head: args.fetch_HEAD?) - current_version = if ENV["HOMEBREW_INSTALL_FROM_API"].present? && (f.core_formula? || f.tap.blank?) + current_version = if !f.head? && ENV["HOMEBREW_INSTALL_FROM_API"].present? && + (f.core_formula? || f.tap.blank?) Homebrew::API::Versions.latest_formula_version(f.name)&.to_s || f.pkg_version.to_s elsif f.alias_changed? && !f.latest_formula.latest_version_installed? latest = f.latest_formula diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 8182bb8e87..715bd8f859 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -160,6 +160,7 @@ module Homebrew if ENV["HOMEBREW_INSTALL_FROM_API"].present? formulae_to_install.map! do |formula| + next formula if formula.head? next formula if formula.tap.present? && !formula.core_formula? next formula unless Homebrew::API::Bottle.available?(formula.name) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 0e7db0cb20..135bb6fc97 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -310,7 +310,12 @@ class Formula # The path that was specified to find this formula. def specified_path - alias_path || path + default_specified_path = alias_path || path + + return default_specified_path if default_specified_path.presence&.exist? + return local_bottle_path if local_bottle_path.presence&.exist? + + default_specified_path end # The name specified to find this formula. @@ -523,7 +528,7 @@ class Formula # exists and is not empty. # @private def latest_version_installed? - latest_prefix = if ENV["HOMEBREW_INSTALL_FROM_API"].present? && + latest_prefix = if !head? && ENV["HOMEBREW_INSTALL_FROM_API"].present? && (latest_pkg_version = Homebrew::API::Versions.latest_formula_version(name)) prefix latest_pkg_version else @@ -1343,7 +1348,7 @@ class Formula Formula.cache[:outdated_kegs][cache_key] ||= begin all_kegs = [] current_version = T.let(false, T::Boolean) - latest_version = if ENV["HOMEBREW_INSTALL_FROM_API"].present? && (core_formula? || tap.blank?) + latest_version = if !head? && ENV["HOMEBREW_INSTALL_FROM_API"].present? && (core_formula? || tap.blank?) Homebrew::API::Versions.latest_formula_version(name) || pkg_version else pkg_version diff --git a/Library/Homebrew/formula_cellar_checks.rb b/Library/Homebrew/formula_cellar_checks.rb index 721baa0696..536f65229f 100644 --- a/Library/Homebrew/formula_cellar_checks.rb +++ b/Library/Homebrew/formula_cellar_checks.rb @@ -287,7 +287,7 @@ module FormulaCellarChecks def check_cpuid_instruction(formula) return unless formula.prefix.directory? # TODO: add methods to `utils/ast` to allow checking for method use - return unless formula.path.read.include? "ENV.runtime_cpu_detection" + return unless (formula.prefix/".brew/#{formula.name}.rb").read.include? "ENV.runtime_cpu_detection" # Checking for `cpuid` only makes sense on Intel: # https://en.wikipedia.org/wiki/CPUID return unless Hardware::CPU.intel? diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 7ce6b00c08..8dba8022f6 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -41,7 +41,7 @@ class Tab < OpenStruct "source" => { "path" => formula.specified_path.to_s, "tap" => formula.tap&.name, - "tap_git_head" => formula.tap&.git_head, + "tap_git_head" => nil, # Filled in later if possible "spec" => formula.active_spec_sym.to_s, "versions" => { "stable" => formula.stable&.version.to_s, @@ -52,6 +52,9 @@ class Tab < OpenStruct "built_on" => DevelopmentTools.build_system_info, } + # We can only get `tap_git_head` if the tap is installed locally + attributes["source"]["tap_git_head"] = formula.tap.git_head if formula.tap&.installed? + new(attributes) end