From 60ba8beefadedee7db03cb35b1fd24f2be6eeed5 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Fri, 9 Oct 2015 15:27:59 +0800 Subject: [PATCH] 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 --- Library/Homebrew/formulary.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 2bdaca7524..7577edb9ea 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -217,10 +217,15 @@ class Formulary tap = tab.tap spec ||= tab.spec - if tap.nil? || tap == "Homebrew/homebrew" + if tap.nil? factory(rack.basename.to_s, spec) 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