Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support of formulae aliases in taps #16637

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions Library/Homebrew/formulary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -906,9 +906,10 @@ def self.tap_formula_name_type(tapped_name, warn:)
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)
sjorek marked this conversation as resolved.
Show resolved Hide resolved
name = possible_alias.split("/").last
type = :alias
elsif (new_name = tap.formula_renames[name].presence)
old_name = name
Expand Down Expand Up @@ -942,8 +943,7 @@ def self.tap_loader_for(tapped_name, warn:)

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)
sjorek marked this conversation as resolved.
Show resolved Hide resolved
elsif Homebrew::API::Formula.all_formulae.key?(name)
return FormulaAPILoader.new(name)
end
Expand Down
7 changes: 7 additions & 0 deletions Library/Homebrew/test/formulary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ class Wrong#{described_class.class_s(formula_name)} < Formula
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")
Expand Down