Formulary.from_rack: better formula resolution strategy

The flow is as follow:
* If tap is nil(DIY install), search using name.
* If tap is found, search using full name.
* If tap is found and full name searching failed, search using name.
  This usually means the formula may be migrated to different tap.

Closes Homebrew/homebrew#44771.

Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
Xu Cheng 2015-10-09 15:27:59 +08:00
parent 5b321ffb5a
commit 60ba8beefa

View File

@ -217,10 +217,15 @@ class Formulary
tap = tab.tap tap = tab.tap
spec ||= tab.spec spec ||= tab.spec
if tap.nil? || tap == "Homebrew/homebrew" if tap.nil?
factory(rack.basename.to_s, spec) factory(rack.basename.to_s, spec)
else else
factory("#{tap.sub("homebrew-", "")}/#{rack.basename}", spec) begin
factory("#{tap}/#{rack.basename}", spec)
rescue FormulaUnavailableError
# formula may be migrated to different tap. Try to search in core and all taps.
factory(rack.basename.to_s, spec)
end
end end
end end