Merge pull request #9031 from MikeMcQuaid/keg-for-realpath
Keg.for: handle non-existent path.
This commit is contained in:
commit
5648ae12f2
@ -183,13 +183,15 @@ class Keg
|
||||
|
||||
# if path is a file in a keg then this will return the containing Keg object
|
||||
def self.for(path)
|
||||
path = path.realpath
|
||||
until path.root?
|
||||
return Keg.new(path) if path.parent.parent == HOMEBREW_CELLAR.realpath
|
||||
original_path = path
|
||||
if original_path.exist? && (path = original_path.realpath)
|
||||
until path.root?
|
||||
return Keg.new(path) if path.parent.parent == HOMEBREW_CELLAR.realpath
|
||||
|
||||
path = path.parent.realpath # realpath() prevents root? failing
|
||||
path = path.parent.realpath # realpath() prevents root? failing
|
||||
end
|
||||
end
|
||||
raise NotAKegError, "#{path} is not inside a keg"
|
||||
raise NotAKegError, "#{original_path} is not inside a keg"
|
||||
end
|
||||
|
||||
def self.all
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user