mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
install: fix HEAD
installations with HOMEBREW_INSTALL_FROM_API
This commit is contained in:
parent
12d5e70b87
commit
50fac1737a
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -77,6 +77,10 @@ class Formula
|
||||
# e.g. `this-formula`
|
||||
attr_reader :name
|
||||
|
||||
# The path to the alias that was used to identify this {Formula}.
|
||||
# e.g. `/usr/local/Library/Taps/homebrew/homebrew-core/Aliases/another-name-for-this-formula`
|
||||
attr_reader :bottle_path
|
||||
|
||||
# The path to the alias that was used to identify this {Formula}.
|
||||
# e.g. `/usr/local/Library/Taps/homebrew/homebrew-core/Aliases/another-name-for-this-formula`
|
||||
attr_reader :alias_path
|
||||
@ -308,9 +312,20 @@ class Formula
|
||||
full_name_with_optional_tap(installed_alias_name)
|
||||
end
|
||||
|
||||
def prefix_formula_file
|
||||
return unless prefix.directory?
|
||||
|
||||
prefix/".brew/#{name}.rb"
|
||||
end
|
||||
|
||||
# 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.present? && default_specified_path.exist?
|
||||
return local_bottle_path if local_bottle_path.present? && local_bottle_path.exist?
|
||||
|
||||
default_specified_path
|
||||
end
|
||||
|
||||
# The name specified to find this formula.
|
||||
@ -523,7 +538,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 +1358,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
|
||||
|
@ -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_formula_file.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?
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user