to_rack: simplify the logic
Closes Homebrew/homebrew#42743. Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
parent
e1779503b7
commit
fac17e8459
@ -196,21 +196,14 @@ class Formulary
|
||||
end
|
||||
|
||||
def self.to_rack(ref)
|
||||
# First, check whether the rack with the given name exists.
|
||||
if (rack = HOMEBREW_CELLAR/File.basename(ref, ".rb")).directory?
|
||||
return rack
|
||||
end
|
||||
|
||||
# Second, use canonical name to locate rack.
|
||||
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
|
||||
end
|
||||
|
||||
rack
|
||||
HOMEBREW_CELLAR/name
|
||||
end
|
||||
|
||||
def self.canonical_name(ref)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user