diff options
| author | Max Howell | 2012-03-09 15:24:58 +0000 |
|---|---|---|
| committer | Max Howell | 2012-03-09 15:25:09 +0000 |
| commit | 70ae09d9c396643fe59f2d688f2a0ccb3f8c3474 (patch) | |
| tree | 6ca384903e5ce814ce69a2ca6640035543f2ccf4 /Library | |
| parent | 2e790b3b59d17dd7ede9c0c4bc4c3357a34e6889 (diff) | |
| download | homebrew-70ae09d9c396643fe59f2d688f2a0ccb3f8c3474.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 #2923.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/cleanup.rb | 9 |
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 |
