aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2016-11-02 14:47:24 -0400
committerMike McQuaid2016-11-02 14:47:24 -0400
commit133bad9a9740ab55b4158c72185c677fc1062ab2 (patch)
tree938a1336f02bb32b5dcb1c9a6c9fe8919287e57d /Library
parentec527ff982e0dbaa7d7089bd8c5e209fb94e210a (diff)
downloadbrew-133bad9a9740ab55b4158c72185c677fc1062ab2.tar.bz2
formulary: migrate fully-scoped formulae names.
e.g. allow `brew install some/tap/formula` to look that formula up in another tap if it has been migrated. Also, add a deprecation message to point people towards the correct naming.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formulary.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb
index 5ce09f6ba..4d6832e44 100644
--- a/Library/Homebrew/formulary.rb
+++ b/Library/Homebrew/formulary.rb
@@ -159,6 +159,11 @@ class Formulary
attr_reader :tap
def initialize(tapped_name)
+ name, path = formula_name_path(tapped_name)
+ super name, path
+ end
+
+ def formula_name_path(tapped_name, warn: true)
user, repo, name = tapped_name.split("/", 3).map(&:downcase)
@tap = Tap.fetch user, repo
formula_dir = @tap.formula_dir || @tap.path
@@ -170,12 +175,25 @@ class Formulary
name = path.basename(".rb").to_s
elsif (new_name = @tap.formula_renames[name]) &&
(new_path = formula_dir/"#{new_name}.rb").file?
+ old_name = name
path = new_path
name = new_name
+ new_name = @tap.core_tap? ? name : "#{@tap}/#{name}"
+ elsif (new_tap_name = @tap.tap_migrations[name])
+ new_tap = Tap.fetch new_tap_name
+ new_tap.install unless new_tap.installed?
+ new_tapped_name = "#{new_tap_name}/#{name}"
+ name, path = formula_name_path(new_tapped_name, warn: false)
+ old_name = tapped_name
+ new_name = new_tap.core_tap? ? name : new_tapped_name
+ end
+
+ if warn && old_name && new_name
+ opoo "Use #{new_name} instead of deprecated #{old_name}"
end
end
- super name, path
+ [name, path]
end
def get_formula(spec, alias_path: nil)