Fix installing from API with tap names

This commit is contained in:
Rylan Polster 2021-10-28 01:25:27 -04:00
parent c6913dc70a
commit 9fee68c500
No known key found for this signature in database
GPG Key ID: 46A744940CFF4D64
3 changed files with 8 additions and 3 deletions

View File

@ -22,6 +22,7 @@ module Homebrew
sig { params(name: String).returns(Hash) }
def fetch(name)
name = name.sub(%r{^homebrew/core/}, "")
Homebrew::API.fetch "#{bottle_api_path}/#{name}.json"
end
@ -85,7 +86,9 @@ module Homebrew
# Map the name of this formula to the local bottle path to allow the
# formula to be loaded by passing just the name to `Formulary::factory`.
Formulary.map_formula_name_to_local_bottle_path hash["name"], resource.downloader.cached_location
[hash["name"], "homebrew/core/#{hash["name"]}"].each do |name|
Formulary.map_formula_name_to_local_bottle_path name, resource.downloader.cached_location
end
end
end
end

View File

@ -12,6 +12,7 @@ module Homebrew
sig { params(token: String).returns(Hash) }
def fetch(token)
token = token.sub(%r{^homebrew/cask/}, "")
Homebrew::API.fetch "cask-source/#{token}.rb", json: false
end

View File

@ -138,11 +138,12 @@ module Homebrew
end
args.named.each do |name|
next if EnvConfig.install_from_api?
next if File.exist?(name)
next if name !~ HOMEBREW_TAP_FORMULA_REGEX && name !~ HOMEBREW_CASK_TAP_CASK_REGEX
next unless name =~ HOMEBREW_TAP_FORMULA_REGEX
tap = Tap.fetch(Regexp.last_match(1), Regexp.last_match(2))
next if (tap.core_tap? || tap == "homebrew/cask") && EnvConfig.install_from_api?
tap.install unless tap.installed?
end