aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorVlad Shablinsky2015-08-09 14:52:49 +0300
committerMike McQuaid2015-08-10 13:57:59 +0100
commit2cc6b9032965fed9e937da7b1c723e4b2cfd60a0 (patch)
tree4cb0fd6c4dd9d0424c6d3e460b785f0c2531323c /Library
parentab1164f4de48fda5e380e9e68326ea5a15cba804 (diff)
downloadbrew-2cc6b9032965fed9e937da7b1c723e4b2cfd60a0.tar.bz2
formulary: change logic for renamed formulae
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formulary.rb32
1 files changed, 30 insertions, 2 deletions
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb
index 717395f7c..4a31b3121 100644
--- a/Library/Homebrew/formulary.rb
+++ b/Library/Homebrew/formulary.rb
@@ -1,4 +1,5 @@
require "digest/md5"
+require "formula_renames"
# The Formulary is responsible for creating instances of Formula.
# It is not meant to be used directy from formulae.
@@ -141,6 +142,7 @@ class Formulary
def initialize(tapped_name)
user, repo, name = tapped_name.split("/", 3).map(&:downcase)
@tap = Tap.new user, repo.sub(/^homebrew-/, "")
+ name = @tap.formula_renames.fetch(name, name)
path = @tap.formula_files.detect { |file| file.basename(".rb").to_s == name }
path ||= @tap.path/"#{name}.rb"
@@ -212,7 +214,13 @@ class Formulary
when Pathname::BOTTLE_EXTNAME_RX
return BottleLoader.new(ref)
when HOMEBREW_CORE_FORMULA_REGEX
- return FormulaLoader.new($1, core_path($1))
+ name = $1
+ formula_with_that_name = core_path(name)
+ if (newname = FORMULA_RENAMES[name]) && !formula_with_that_name.file?
+ return FormulaLoader.new(newname, core_path(newname))
+ else
+ return FormulaLoader.new(name, formula_with_that_name)
+ end
when HOMEBREW_TAP_FORMULA_REGEX
return TapLoader.new(ref)
end
@@ -231,13 +239,33 @@ class Formulary
return AliasLoader.new(possible_alias)
end
- possible_tap_formulae = tap_paths(ref)
+ possible_tap_formulae = tap_paths(ref)
if possible_tap_formulae.size > 1
raise TapFormulaAmbiguityError.new(ref, possible_tap_formulae)
elsif possible_tap_formulae.size == 1
return FormulaLoader.new(ref, possible_tap_formulae.first)
end
+ if newref = FORMULA_RENAMES[ref]
+ formula_with_that_oldname = core_path(newref)
+ if formula_with_that_oldname.file?
+ return FormulaLoader.new(newref, formula_with_that_oldname)
+ end
+ end
+
+ possible_tap_newname_formulae = []
+ Tap.each do |tap|
+ if newref = tap.formula_renames[ref]
+ possible_tap_newname_formulae << "#{tap.name}/#{newref}"
+ end
+ end
+
+ if possible_tap_newname_formulae.size > 1
+ raise TapFormulaWithOldnameAmbiguityError.new(ref, possible_tap_newname_formulae)
+ elsif !possible_tap_newname_formulae.empty?
+ return TapLoader.new(possible_tap_newname_formulae.first)
+ end
+
possible_cached_formula = Pathname.new("#{HOMEBREW_CACHE_FORMULA}/#{ref}.rb")
if possible_cached_formula.file?
return FormulaLoader.new(ref, possible_cached_formula)