Merge pull request #16637 from sjorek/issue-16636-fix-support-of-formulae-aliases-in-taps

Fix support of formulae aliases in taps
This commit is contained in:
Kevin 2024-02-11 14:15:42 -08:00 committed by GitHub
commit ac7e759540
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View File

@ -906,9 +906,10 @@ module Formulary
user, repo, name = tapped_name.split("/", 3).map(&:downcase)
tap = Tap.fetch user, repo
type = nil
alias_name = tap.core_tap? ? name : "#{tap}/#{name}"
if (possible_alias = tap.alias_table[name].presence)
name = possible_alias
if (possible_alias = tap.alias_table[alias_name].presence)
name = possible_alias.split("/").last
type = :alias
elsif (new_name = tap.formula_renames[name].presence)
old_name = name
@ -942,8 +943,7 @@ module Formulary
if tap.core_tap? && !Homebrew::EnvConfig.no_install_from_api?
if type == :alias
alias_name = tapped_name[HOMEBREW_TAP_FORMULA_REGEX, 3]
return AliasAPILoader.new(alias_name)
return AliasAPILoader.new(name)
elsif Homebrew::API::Formula.all_formulae.key?(name)
return FormulaAPILoader.new(name)
end

View File

@ -243,6 +243,13 @@ describe Formulary do
expect(described_class.factory("bar")).to be_a(Formula)
end
it "returns a Formula from a fully qualified Alias path" do
alias_dir = tap.path/"Aliases"
alias_dir.mkpath
FileUtils.ln_s formula_path, alias_dir/"bar"
expect(described_class.factory("#{tap}/bar")).to be_a(Formula)
end
it "raises an error when the Formula cannot be found" do
expect do
described_class.factory("#{tap}/not_existed_formula")