link_overwrite: allow to overwrite files from alias

See https://github.com/Homebrew/homebrew-core/pull/54912#issuecomment-653893645
Formulary.factory("python") points to python@3.8, which breaks link_overwrite
for that case.

This changes checks if the formula is an alias, so that we can still override
the files during installation.
This commit is contained in:
Michka Popoff 2020-07-05 22:24:03 +02:00
parent 505c1e7240
commit 5eae33b59d

View File

@ -1112,13 +1112,15 @@ class Formula
return false if tab_tap.nil?
begin
Formulary.factory(keg.name)
f = Formulary.factory(keg.name)
rescue FormulaUnavailableError
# formula for this keg is deleted, so defer to allowlist
rescue TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError
return false # this keg belongs to another formula
else
return false # this keg belongs to another formula
# this keg belongs to another formula
# but it is not an alias
return false unless f.aliases.include? keg.name
end
end
to_check = path.relative_path_from(HOMEBREW_PREFIX).to_s