Merge pull request #15434 from reitermarkus/formula-loaded-from-api
Add `Formula#loaded_from_api?`.
This commit is contained in:
commit
34dd47d7d4
@ -427,6 +427,12 @@ class Formula
|
|||||||
# @see .version
|
# @see .version
|
||||||
delegate version: :active_spec
|
delegate version: :active_spec
|
||||||
|
|
||||||
|
# Whether this formula was loaded using the formulae.brew.sh API
|
||||||
|
# @!method loaded_from_api?
|
||||||
|
# @private
|
||||||
|
# @see .loaded_from_api?
|
||||||
|
delegate loaded_from_api?: :"self.class"
|
||||||
|
|
||||||
def update_head_version
|
def update_head_version
|
||||||
return unless head?
|
return unless head?
|
||||||
return unless head.downloader.is_a?(VCSDownloadStrategy)
|
return unless head.downloader.is_a?(VCSDownloadStrategy)
|
||||||
@ -2238,7 +2244,7 @@ class Formula
|
|||||||
hash = to_hash
|
hash = to_hash
|
||||||
|
|
||||||
# Take from API, merging in local install status.
|
# Take from API, merging in local install status.
|
||||||
if self.class.loaded_from_api && !Homebrew::EnvConfig.no_install_from_api?
|
if loaded_from_api? && !Homebrew::EnvConfig.no_install_from_api?
|
||||||
json_formula = Homebrew::API::Formula.all_formulae[name].dup
|
json_formula = Homebrew::API::Formula.all_formulae[name].dup
|
||||||
return json_formula.merge(
|
return json_formula.merge(
|
||||||
hash.slice("name", "installed", "linked_keg", "pinned", "outdated"),
|
hash.slice("name", "installed", "linked_keg", "pinned", "outdated"),
|
||||||
@ -2758,6 +2764,7 @@ class Formula
|
|||||||
@skip_clean_paths = Set.new
|
@skip_clean_paths = Set.new
|
||||||
@link_overwrite_paths = Set.new
|
@link_overwrite_paths = Set.new
|
||||||
@allowed_missing_libraries = Set.new
|
@allowed_missing_libraries = Set.new
|
||||||
|
@loaded_from_api = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2784,7 +2791,7 @@ class Formula
|
|||||||
|
|
||||||
# Whether this formula was loaded using the formulae.brew.sh API
|
# Whether this formula was loaded using the formulae.brew.sh API
|
||||||
# @private
|
# @private
|
||||||
attr_accessor :loaded_from_api
|
attr_predicate :loaded_from_api?
|
||||||
|
|
||||||
# Whether this formula contains OS/arch-specific blocks
|
# 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`).
|
# (e.g. `on_macos`, `on_arm`, `on_monterey :or_older`, `on_system :linux, macos: :big_sur_or_newer`).
|
||||||
|
|||||||
@ -3,6 +3,8 @@
|
|||||||
# This file provides definitions for Forwardable#delegate, which is currently not supported by Sorbet.
|
# This file provides definitions for Forwardable#delegate, which is currently not supported by Sorbet.
|
||||||
|
|
||||||
class Formula
|
class Formula
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
|
def loaded_from_api?; end
|
||||||
def bottle_defined?; end
|
def bottle_defined?; end
|
||||||
def bottle_tag?(tag = nil); end
|
def bottle_tag?(tag = nil); end
|
||||||
def bottled?(tag = nil); end
|
def bottled?(tag = nil); end
|
||||||
|
|||||||
@ -1191,7 +1191,7 @@ on_request: installed_on_request?, options: options)
|
|||||||
if pour_bottle?(output_warning: true)
|
if pour_bottle?(output_warning: true)
|
||||||
formula.fetch_bottle_tab
|
formula.fetch_bottle_tab
|
||||||
else
|
else
|
||||||
@formula = Homebrew::API::Formula.source_download(formula) if formula.class.loaded_from_api
|
@formula = Homebrew::API::Formula.source_download(formula) if formula.loaded_from_api?
|
||||||
|
|
||||||
formula.fetch_patches
|
formula.fetch_patches
|
||||||
formula.resources.each(&:fetch)
|
formula.resources.each(&:fetch)
|
||||||
@ -1227,7 +1227,7 @@ on_request: installed_on_request?, options: options)
|
|||||||
tab.unused_options = []
|
tab.unused_options = []
|
||||||
tab.built_as_bottle = true
|
tab.built_as_bottle = true
|
||||||
tab.poured_from_bottle = true
|
tab.poured_from_bottle = true
|
||||||
tab.loaded_from_api = formula.class.loaded_from_api
|
tab.loaded_from_api = formula.loaded_from_api?
|
||||||
tab.installed_as_dependency = installed_as_dependency?
|
tab.installed_as_dependency = installed_as_dependency?
|
||||||
tab.installed_on_request = installed_on_request?
|
tab.installed_on_request = installed_on_request?
|
||||||
tab.time = Time.now.to_i
|
tab.time = Time.now.to_i
|
||||||
|
|||||||
@ -136,7 +136,7 @@ module Formulary
|
|||||||
|
|
||||||
mod.const_set(:BUILD_FLAGS, flags)
|
mod.const_set(:BUILD_FLAGS, flags)
|
||||||
|
|
||||||
class_s = Formulary.class_s(name)
|
class_name = class_s(name)
|
||||||
json_formula = Homebrew::API::Formula.all_formulae[name]
|
json_formula = Homebrew::API::Formula.all_formulae[name]
|
||||||
json_formula = Homebrew::API.merge_variations(json_formula)
|
json_formula = Homebrew::API.merge_variations(json_formula)
|
||||||
|
|
||||||
@ -147,6 +147,8 @@ module Formulary
|
|||||||
end
|
end
|
||||||
|
|
||||||
klass = Class.new(::Formula) do
|
klass = Class.new(::Formula) do
|
||||||
|
@loaded_from_api = true
|
||||||
|
|
||||||
desc json_formula["desc"]
|
desc json_formula["desc"]
|
||||||
homepage json_formula["homepage"]
|
homepage json_formula["homepage"]
|
||||||
license SPDX.string_to_license_expression(json_formula["license"])
|
license SPDX.string_to_license_expression(json_formula["license"])
|
||||||
@ -311,8 +313,7 @@ module Formulary
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
T.cast(klass, T.class_of(Formula)).loaded_from_api = true
|
mod.const_set(class_name, klass)
|
||||||
mod.const_set(class_s, klass)
|
|
||||||
|
|
||||||
cache[:api] ||= {}
|
cache[:api] ||= {}
|
||||||
cache[:api][name] = klass
|
cache[:api][name] = klass
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user