From 6ac6cb4fcdc5c162543e14688d41c0b10a1b1e4a Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Wed, 24 Feb 2016 20:06:33 +0800 Subject: [PATCH] TapLoader: improve load logic * Use `Tap#formula_dir` instead of `Tap#formula_files` to find formula file to have better performance and avoid caching issue. * Change the loader logic to search name -> search alias -> search old name. This is more consistence with what we do when loading core formula file. Closes Homebrew/homebrew#49484. Signed-off-by: Xu Cheng --- Library/Homebrew/formulary.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 56f221f330..408714d791 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -148,15 +148,17 @@ class Formulary def initialize(tapped_name) user, repo, name = tapped_name.split("/", 3).map(&:downcase) @tap = Tap.fetch user, repo - name = @tap.formula_renames.fetch(name, name) - path = @tap.formula_files.detect { |file| file.basename(".rb").to_s == name } + formula_dir = @tap.formula_dir || @tap.path + path = formula_dir/"#{name}.rb" - unless path + unless path.file? if (possible_alias = @tap.alias_dir/name).file? path = possible_alias.resolved_path name = path.basename(".rb").to_s - else - path = @tap.path/"#{name}.rb" + elsif (new_name = @tap.formula_renames[name]) && + (new_path = formula_dir/"#{new_name}.rb").file? + path = new_path + name = new_name end end