aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorXu Cheng2016-02-24 20:06:33 +0800
committerXu Cheng2016-02-24 20:51:35 +0800
commit6ac6cb4fcdc5c162543e14688d41c0b10a1b1e4a (patch)
treeacb00ad02d1d1d6664648cb9a4393bffafb41e21 /Library
parent6b6159a858009b6d82b858830533a4a3ce135a28 (diff)
downloadbrew-6ac6cb4fcdc5c162543e14688d41c0b10a1b1e4a.tar.bz2
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 <xucheng@me.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formulary.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb
index 56f221f33..408714d79 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