aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd
diff options
context:
space:
mode:
authorMax Howell2012-03-09 15:24:58 +0000
committerMax Howell2012-03-09 15:25:09 +0000
commit981605d199d8ed0b83c2c19aea7e3839c56cca9b (patch)
treead3bcc6bd37d7ebb62cf480a8f1d5db654e1d7b7 /Library/Homebrew/cmd
parentfc2cc57ce87ef19539db48c3c2057c502f97fa94 (diff)
downloadbrew-981605d199d8ed0b83c2c19aea7e3839c56cca9b.tar.bz2
Don't cleanup the wrong things
This still isn't perfect, but it will handle hyphens in formula-names better now. A proper solution is not easy or maybe even possible unless we ban hyphens in versions AND formula names, or use a different character as a separate in downloaded cache files which we then ban from formula-name and version strings. Refs Homebrew/homebrew#2923.
Diffstat (limited to 'Library/Homebrew/cmd')
-rw-r--r--Library/Homebrew/cmd/cleanup.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/Library/Homebrew/cmd/cleanup.rb b/Library/Homebrew/cmd/cleanup.rb
index ba9745f1a..3f6471af9 100644
--- a/Library/Homebrew/cmd/cleanup.rb
+++ b/Library/Homebrew/cmd/cleanup.rb
@@ -51,10 +51,11 @@ module Homebrew extend self
def clean_cache
HOMEBREW_CACHE.children.each do |pn|
next unless pn.file?
- pn.stem =~ /^(.+)-(.+)$/ # greedy so works even if formula-name has hyphens in it
- if $1 and $2
- f = Formula.factory($1) rescue nil
- if not f or (f.version != $2 or ARGV.switch? "s" and not f.installed?)
+ version = pn.version
+ name = pn.basename.to_s.match(/(.*)-(#{version})/).captures.first rescue nil
+ if name and version
+ f = Formula.factory(name) rescue nil
+ if not f or (f.version != version or ARGV.switch? "s" and not f.installed?)
puts "Removing #{pn}..."
rm pn unless ARGV.switch? 'n'
end