Prefer HEAD version if its installed

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
This commit is contained in:
Joshua Peek 2010-09-24 11:55:21 -05:00 committed by Adam Vandenberg
parent f4ce357d44
commit a305360099
2 changed files with 12 additions and 3 deletions

View File

@ -199,7 +199,7 @@ def info f
kids=f.prefix.parent.children kids=f.prefix.parent.children
kids.each do |keg| kids.each do |keg|
print "#{keg} (#{keg.abv})" print "#{keg} (#{keg.abv})"
print " *" if f.prefix == keg and kids.length > 1 print " *" if f.installed_prefix == keg and kids.length > 1
puts puts
end end
else else
@ -258,7 +258,7 @@ def cleanup name
if f.installed? and formula_cellar.directory? if f.installed? and formula_cellar.directory?
kids = f.prefix.parent.children kids = f.prefix.parent.children
kids.each do |keg| kids.each do |keg|
next if f.prefix == keg next if f.installed_prefix == keg
print "Uninstalling #{keg}..." print "Uninstalling #{keg}..."
FileUtils.rm_rf keg FileUtils.rm_rf keg
puts puts

View File

@ -98,11 +98,20 @@ class Formula
# if the dir is there, but it's empty we consider it not installed # if the dir is there, but it's empty we consider it not installed
def installed? def installed?
return prefix.children.length > 0 return installed_prefix.children.length > 0
rescue rescue
return false return false
end end
def installed_prefix
head_prefix = HOMEBREW_CELLAR+@name+'HEAD'
if @version == 'HEAD' || head_prefix.directory?
head_prefix
else
prefix
end
end
def path def path
self.class.path name self.class.path name
end end