diff options
| author | Xu Cheng | 2015-08-10 21:35:59 +0800 |
|---|---|---|
| committer | Xu Cheng | 2015-08-10 21:59:51 +0800 |
| commit | fac17e8459c193e40144c5e7875f5b634d8af9a0 (patch) | |
| tree | 84d2aedda4be0900af9084c8327220b1b04f2806 /Library | |
| parent | e1779503b79df5799ac8da8cab3f7b507c2c3abe (diff) | |
| download | brew-fac17e8459c193e40144c5e7875f5b634d8af9a0.tar.bz2 | |
to_rack: simplify the logic
Closes Homebrew/homebrew#42743.
Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/formulary.rb | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 8fcffb59e..6735859ca 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -196,21 +196,14 @@ class Formulary end def self.to_rack(ref) - name = canonical_name(ref) - rack = HOMEBREW_CELLAR/name - - # Handle the case when ref is an old name and the installation - # hasn't been migrated or when it's a package installed from - # path but same name formula was renamed. - unless rack.directory? - if ref =~ HOMEBREW_TAP_FORMULA_REGEX - rack = HOMEBREW_CELLAR/$3 - elsif !ref.include?("/") - rack = HOMEBREW_CELLAR/ref - end + # First, check whether the rack with the given name exists. + if (rack = HOMEBREW_CELLAR/File.basename(ref, ".rb")).directory? + return rack end - rack + # Second, use canonical name to locate rack. + name = canonical_name(ref) + HOMEBREW_CELLAR/name end def self.canonical_name(ref) |
