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)
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
def self.internal_json_v3?
|
||||
ENV["HOMEBREW_INTERNAL_JSON_V3"].present?
|
||||
end
|
||||
end
|
||||
|
||||
sig { params(block: T.proc.returns(T.untyped)).returns(T.untyped) }
|
||||
|
@ -11,7 +11,6 @@ module Homebrew
|
||||
extend Cachable
|
||||
|
||||
DEFAULT_API_FILENAME = "formula.jws.json"
|
||||
INTERNAL_V3_API_FILENAME = "internal/v3/homebrew-core.jws.json"
|
||||
|
||||
private_class_method :cache
|
||||
|
||||
@ -43,19 +42,11 @@ module Homebrew
|
||||
|
||||
sig { returns(Pathname) }
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
sig { returns(T::Boolean) }
|
||||
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
|
||||
|
||||
cache["aliases"] = {}
|
||||
@ -70,7 +61,6 @@ module Homebrew
|
||||
|
||||
[json_formula["name"], json_formula.except("name")]
|
||||
end
|
||||
end
|
||||
|
||||
updated
|
||||
end
|
||||
|
@ -219,7 +219,6 @@ module Homebrew
|
||||
|
||||
# TODO: remove this and fix tests when possible.
|
||||
ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1"
|
||||
ENV.delete("HOMEBREW_INTERNAL_JSON_V3")
|
||||
|
||||
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]))
|
||||
end
|
||||
|
||||
# NOTE: We overwrite here instead of using `Hash#clear` to handle frozen hashes.
|
||||
sig { void }
|
||||
def clear_cache
|
||||
overwrite_cache!({})
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
sig { params(hash: T::Hash[T.untyped, T.untyped]).void }
|
||||
def overwrite_cache!(hash)
|
||||
@cache = hash
|
||||
cache.clear
|
||||
end
|
||||
end
|
||||
|
@ -213,39 +213,7 @@ module Formulary
|
||||
end
|
||||
end
|
||||
|
||||
add_deps = if Homebrew::API.internal_json_v3?
|
||||
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|
|
||||
add_deps = lambda do |spec|
|
||||
T.bind(self, SoftwareSpec)
|
||||
|
||||
dep_json = json_formula.fetch("#{spec}_dependencies", json_formula)
|
||||
@ -280,7 +248,6 @@ module Formulary
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
klass = Class.new(::Formula) do
|
||||
@loaded_from_api = true
|
||||
@ -299,15 +266,10 @@ module Formulary
|
||||
using: urls_stable["using"]&.to_sym,
|
||||
}.compact
|
||||
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?
|
||||
|
||||
if Homebrew::API.internal_json_v3?
|
||||
instance_exec(json_formula["dependencies"], &add_deps)
|
||||
else
|
||||
instance_exec(:stable, &add_deps)
|
||||
end
|
||||
|
||||
requirements[:stable]&.each do |req|
|
||||
depends_on req
|
||||
end
|
||||
@ -322,23 +284,14 @@ module Formulary
|
||||
}.compact
|
||||
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)
|
||||
end
|
||||
|
||||
requirements[:head]&.each do |req|
|
||||
depends_on req
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
bottles_stable = if Homebrew::API.internal_json_v3?
|
||||
json_formula["bottle"]
|
||||
else
|
||||
json_formula["bottle"]["stable"]
|
||||
end.presence
|
||||
bottles_stable = json_formula["bottle"]["stable"].presence
|
||||
|
||||
if bottles_stable
|
||||
bottle do
|
||||
@ -426,17 +379,12 @@ module Formulary
|
||||
.gsub(HOMEBREW_HOME_PLACEHOLDER, Dir.home)
|
||||
end
|
||||
|
||||
@tap_git_head_string = if Homebrew::API.internal_json_v3?
|
||||
Homebrew::API::Formula.tap_git_head
|
||||
else
|
||||
json_formula["tap_git_head"]
|
||||
end
|
||||
@tap_git_head_string = json_formula["tap_git_head"]
|
||||
|
||||
def tap_git_head
|
||||
self.class.instance_variable_get(:@tap_git_head_string)
|
||||
end
|
||||
|
||||
unless Homebrew::API.internal_json_v3?
|
||||
@oldnames_array = json_formula["oldnames"] || [json_formula["oldname"]].compact
|
||||
def oldnames
|
||||
self.class.instance_variable_get(:@oldnames_array)
|
||||
@ -446,7 +394,6 @@ module Formulary
|
||||
def aliases
|
||||
self.class.instance_variable_get(:@aliases_array)
|
||||
end
|
||||
end
|
||||
|
||||
@versioned_formulae_array = json_formula.fetch("versioned_formulae", [])
|
||||
def versioned_formulae_names
|
||||
|
@ -1307,8 +1307,6 @@ class CoreTap < AbstractCoreTap
|
||||
@tap_migrations ||= if Homebrew::EnvConfig.no_install_from_api?
|
||||
ensure_installed!
|
||||
super
|
||||
elsif Homebrew::API.internal_json_v3?
|
||||
Homebrew::API::Formula.tap_migrations
|
||||
else
|
||||
migrations, = Homebrew::API.fetch_json_api_file "formula_tap_migrations.jws.json",
|
||||
stale_seconds: TAP_MIGRATIONS_STALE_SECONDS
|
||||
|
Loading…
x
Reference in New Issue
Block a user