mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
remove all references to JSON v3
The logic has now been removed in previous commits. This just removes some references to the `HOMEBREW_INTERNAL_JSON_V3` environment variable along with reverting the changes to the `Cachable` class that were originally added in bd72ec812c3ed656dfcf8e24f77df142a1fe9cc1.
This commit is contained in:
parent
eead014ceb
commit
f916f27d82
@ -184,11 +184,6 @@ module Homebrew
|
|||||||
|
|
||||||
Tap.fetch(org, repo)
|
Tap.fetch(org, repo)
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
|
||||||
def self.internal_json_v3?
|
|
||||||
ENV["HOMEBREW_INTERNAL_JSON_V3"].present?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(block: T.proc.returns(T.untyped)).returns(T.untyped) }
|
sig { params(block: T.proc.returns(T.untyped)).returns(T.untyped) }
|
||||||
|
@ -11,7 +11,6 @@ module Homebrew
|
|||||||
extend Cachable
|
extend Cachable
|
||||||
|
|
||||||
DEFAULT_API_FILENAME = "formula.jws.json"
|
DEFAULT_API_FILENAME = "formula.jws.json"
|
||||||
INTERNAL_V3_API_FILENAME = "internal/v3/homebrew-core.jws.json"
|
|
||||||
|
|
||||||
private_class_method :cache
|
private_class_method :cache
|
||||||
|
|
||||||
@ -43,19 +42,11 @@ module Homebrew
|
|||||||
|
|
||||||
sig { returns(Pathname) }
|
sig { returns(Pathname) }
|
||||||
def self.cached_json_file_path
|
def self.cached_json_file_path
|
||||||
if Homebrew::API.internal_json_v3?
|
|
||||||
HOMEBREW_CACHE_API/INTERNAL_V3_API_FILENAME
|
|
||||||
else
|
|
||||||
HOMEBREW_CACHE_API/DEFAULT_API_FILENAME
|
HOMEBREW_CACHE_API/DEFAULT_API_FILENAME
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def self.download_and_cache_data!
|
def self.download_and_cache_data!
|
||||||
if Homebrew::API.internal_json_v3?
|
|
||||||
json_formulae, updated = Homebrew::API.fetch_json_api_file INTERNAL_V3_API_FILENAME
|
|
||||||
overwrite_cache! T.cast(json_formulae, T::Hash[String, T.untyped])
|
|
||||||
else
|
|
||||||
json_formulae, updated = Homebrew::API.fetch_json_api_file DEFAULT_API_FILENAME
|
json_formulae, updated = Homebrew::API.fetch_json_api_file DEFAULT_API_FILENAME
|
||||||
|
|
||||||
cache["aliases"] = {}
|
cache["aliases"] = {}
|
||||||
@ -70,7 +61,6 @@ module Homebrew
|
|||||||
|
|
||||||
[json_formula["name"], json_formula.except("name")]
|
[json_formula["name"], json_formula.except("name")]
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
updated
|
updated
|
||||||
end
|
end
|
||||||
|
@ -219,7 +219,6 @@ module Homebrew
|
|||||||
|
|
||||||
# TODO: remove this and fix tests when possible.
|
# TODO: remove this and fix tests when possible.
|
||||||
ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1"
|
ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1"
|
||||||
ENV.delete("HOMEBREW_INTERNAL_JSON_V3")
|
|
||||||
|
|
||||||
ENV["USER"] ||= system_command!("id", args: ["-nu"]).stdout.chomp
|
ENV["USER"] ||= system_command!("id", args: ["-nu"]).stdout.chomp
|
||||||
|
|
||||||
|
@ -7,16 +7,8 @@ module Cachable
|
|||||||
@cache ||= T.let({}, T.nilable(T::Hash[T.untyped, T.untyped]))
|
@cache ||= T.let({}, T.nilable(T::Hash[T.untyped, T.untyped]))
|
||||||
end
|
end
|
||||||
|
|
||||||
# NOTE: We overwrite here instead of using `Hash#clear` to handle frozen hashes.
|
|
||||||
sig { void }
|
sig { void }
|
||||||
def clear_cache
|
def clear_cache
|
||||||
overwrite_cache!({})
|
cache.clear
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
sig { params(hash: T::Hash[T.untyped, T.untyped]).void }
|
|
||||||
def overwrite_cache!(hash)
|
|
||||||
@cache = hash
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -213,39 +213,7 @@ module Formulary
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
add_deps = if Homebrew::API.internal_json_v3?
|
add_deps = lambda do |spec|
|
||||||
lambda do |deps|
|
|
||||||
T.bind(self, SoftwareSpec)
|
|
||||||
|
|
||||||
deps&.each do |name, info|
|
|
||||||
tags = case info&.dig("tags")
|
|
||||||
in Array => tag_list
|
|
||||||
tag_list.map(&:to_sym)
|
|
||||||
in String => tag
|
|
||||||
tag.to_sym
|
|
||||||
else
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
|
|
||||||
if info&.key?("uses_from_macos")
|
|
||||||
bounds = info["uses_from_macos"].dup || {}
|
|
||||||
bounds.deep_transform_keys!(&:to_sym)
|
|
||||||
bounds.deep_transform_values!(&:to_sym)
|
|
||||||
|
|
||||||
if tags
|
|
||||||
uses_from_macos name => tags, **bounds
|
|
||||||
else
|
|
||||||
uses_from_macos name, **bounds
|
|
||||||
end
|
|
||||||
elsif tags
|
|
||||||
depends_on name => tags
|
|
||||||
else
|
|
||||||
depends_on name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
lambda do |spec|
|
|
||||||
T.bind(self, SoftwareSpec)
|
T.bind(self, SoftwareSpec)
|
||||||
|
|
||||||
dep_json = json_formula.fetch("#{spec}_dependencies", json_formula)
|
dep_json = json_formula.fetch("#{spec}_dependencies", json_formula)
|
||||||
@ -280,7 +248,6 @@ module Formulary
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
klass = Class.new(::Formula) do
|
klass = Class.new(::Formula) do
|
||||||
@loaded_from_api = true
|
@loaded_from_api = true
|
||||||
@ -299,15 +266,10 @@ module Formulary
|
|||||||
using: urls_stable["using"]&.to_sym,
|
using: urls_stable["using"]&.to_sym,
|
||||||
}.compact
|
}.compact
|
||||||
url urls_stable["url"], **url_spec
|
url urls_stable["url"], **url_spec
|
||||||
version Homebrew::API.internal_json_v3? ? json_formula["version"] : json_formula["versions"]["stable"]
|
version json_formula["versions"]["stable"]
|
||||||
sha256 urls_stable["checksum"] if urls_stable["checksum"].present?
|
sha256 urls_stable["checksum"] if urls_stable["checksum"].present?
|
||||||
|
|
||||||
if Homebrew::API.internal_json_v3?
|
|
||||||
instance_exec(json_formula["dependencies"], &add_deps)
|
|
||||||
else
|
|
||||||
instance_exec(:stable, &add_deps)
|
instance_exec(:stable, &add_deps)
|
||||||
end
|
|
||||||
|
|
||||||
requirements[:stable]&.each do |req|
|
requirements[:stable]&.each do |req|
|
||||||
depends_on req
|
depends_on req
|
||||||
end
|
end
|
||||||
@ -322,23 +284,14 @@ module Formulary
|
|||||||
}.compact
|
}.compact
|
||||||
url urls_head["url"], **url_spec
|
url urls_head["url"], **url_spec
|
||||||
|
|
||||||
if Homebrew::API.internal_json_v3?
|
|
||||||
instance_exec(json_formula["head_dependencies"], &add_deps)
|
|
||||||
else
|
|
||||||
instance_exec(:head, &add_deps)
|
instance_exec(:head, &add_deps)
|
||||||
end
|
|
||||||
|
|
||||||
requirements[:head]&.each do |req|
|
requirements[:head]&.each do |req|
|
||||||
depends_on req
|
depends_on req
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
bottles_stable = if Homebrew::API.internal_json_v3?
|
bottles_stable = json_formula["bottle"]["stable"].presence
|
||||||
json_formula["bottle"]
|
|
||||||
else
|
|
||||||
json_formula["bottle"]["stable"]
|
|
||||||
end.presence
|
|
||||||
|
|
||||||
if bottles_stable
|
if bottles_stable
|
||||||
bottle do
|
bottle do
|
||||||
@ -426,17 +379,12 @@ module Formulary
|
|||||||
.gsub(HOMEBREW_HOME_PLACEHOLDER, Dir.home)
|
.gsub(HOMEBREW_HOME_PLACEHOLDER, Dir.home)
|
||||||
end
|
end
|
||||||
|
|
||||||
@tap_git_head_string = if Homebrew::API.internal_json_v3?
|
@tap_git_head_string = json_formula["tap_git_head"]
|
||||||
Homebrew::API::Formula.tap_git_head
|
|
||||||
else
|
|
||||||
json_formula["tap_git_head"]
|
|
||||||
end
|
|
||||||
|
|
||||||
def tap_git_head
|
def tap_git_head
|
||||||
self.class.instance_variable_get(:@tap_git_head_string)
|
self.class.instance_variable_get(:@tap_git_head_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
unless Homebrew::API.internal_json_v3?
|
|
||||||
@oldnames_array = json_formula["oldnames"] || [json_formula["oldname"]].compact
|
@oldnames_array = json_formula["oldnames"] || [json_formula["oldname"]].compact
|
||||||
def oldnames
|
def oldnames
|
||||||
self.class.instance_variable_get(:@oldnames_array)
|
self.class.instance_variable_get(:@oldnames_array)
|
||||||
@ -446,7 +394,6 @@ module Formulary
|
|||||||
def aliases
|
def aliases
|
||||||
self.class.instance_variable_get(:@aliases_array)
|
self.class.instance_variable_get(:@aliases_array)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
@versioned_formulae_array = json_formula.fetch("versioned_formulae", [])
|
@versioned_formulae_array = json_formula.fetch("versioned_formulae", [])
|
||||||
def versioned_formulae_names
|
def versioned_formulae_names
|
||||||
|
@ -1307,8 +1307,6 @@ class CoreTap < AbstractCoreTap
|
|||||||
@tap_migrations ||= if Homebrew::EnvConfig.no_install_from_api?
|
@tap_migrations ||= if Homebrew::EnvConfig.no_install_from_api?
|
||||||
ensure_installed!
|
ensure_installed!
|
||||||
super
|
super
|
||||||
elsif Homebrew::API.internal_json_v3?
|
|
||||||
Homebrew::API::Formula.tap_migrations
|
|
||||||
else
|
else
|
||||||
migrations, = Homebrew::API.fetch_json_api_file "formula_tap_migrations.jws.json",
|
migrations, = Homebrew::API.fetch_json_api_file "formula_tap_migrations.jws.json",
|
||||||
stale_seconds: TAP_MIGRATIONS_STALE_SECONDS
|
stale_seconds: TAP_MIGRATIONS_STALE_SECONDS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user