mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Use newer internal api hash structure
This commit is contained in:
parent
8ec57eab2b
commit
62b69765e0
@ -20,9 +20,14 @@ module Homebrew
|
||||
|
||||
sig { params(name: String).returns(T::Hash[String, T.untyped]) }
|
||||
def self.formula(name)
|
||||
tag = Utils::Bottles.tag
|
||||
formula_stub = Homebrew::FormulaStub.from_array formula_stub(name)
|
||||
return cache["formula_stubs"][name] if cache.key?("formula_stubs") && cache["formula_stubs"].key?(name)
|
||||
|
||||
stub_array = all_formula_stubs[name]
|
||||
raise "No formula stub found for #{name}" unless stub_array
|
||||
|
||||
formula_stub = Homebrew::FormulaStub.from_array name, stub_array
|
||||
|
||||
tag = Utils::Bottles.tag
|
||||
bottle_specification = BottleSpecification.new
|
||||
bottle_specification.tap = Homebrew::DEFAULT_REPOSITORY
|
||||
bottle_specification.rebuild formula_stub.rebuild
|
||||
@ -33,7 +38,10 @@ module Homebrew
|
||||
|
||||
begin
|
||||
bottle_manifest_resource.fetch
|
||||
bottle_manifest_resource.formula_json
|
||||
formula_json = bottle_manifest_resource.formula_json
|
||||
|
||||
cache["formula_stubs"][name] = formula_json
|
||||
formula_json
|
||||
rescue Resource::BottleManifest::Error
|
||||
opoo "Falling back to API fetch for #{name}"
|
||||
Homebrew::API.fetch "formula/#{name}.json"
|
||||
@ -54,18 +62,11 @@ module Homebrew
|
||||
end
|
||||
private_class_method :download_and_cache_data!
|
||||
|
||||
sig { params(name: String).returns([String, String, Integer, T.nilable(String)]) }
|
||||
def self.formula_stub(name)
|
||||
sig { returns(T::Hash[String, [String, Integer, T.nilable(String)]]) }
|
||||
def self.all_formula_stubs
|
||||
download_and_cache_data! unless cache.key?("all_formula_stubs")
|
||||
|
||||
return cache["formula_stubs"][name] if cache["formula_stubs"].key?(name)
|
||||
|
||||
cache["all_formula_stubs"].find do |stub|
|
||||
next false if stub["name"] != name
|
||||
|
||||
cache["formula_stubs"][name] = stub
|
||||
true
|
||||
end
|
||||
cache["all_formula_stubs"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -11,13 +11,13 @@ module Homebrew
|
||||
const :rebuild, Integer
|
||||
const :sha256, T.nilable(String)
|
||||
|
||||
sig { params(array: [String, String, Integer, T.nilable(String)]).returns(FormulaStub) }
|
||||
def self.from_array(array)
|
||||
sig { params(name: String, array: [String, Integer, T.nilable(String)]).returns(FormulaStub) }
|
||||
def self.from_array(name, array)
|
||||
new(
|
||||
name: array[0],
|
||||
pkg_version: PkgVersion.parse(array[1]),
|
||||
rebuild: array[2],
|
||||
sha256: array[3],
|
||||
name: name,
|
||||
pkg_version: PkgVersion.parse(array[0]),
|
||||
rebuild: array[1],
|
||||
sha256: array[2],
|
||||
)
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user