summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2010-07-15 10:28:56 -0700
committerCarl Lerche <carllerche@mac.com>2010-07-15 10:29:31 -0700
commitbf367148a45bfc56142db4d4fc32f137e1056f60 (patch)
tree49b044fca4b15b6f9ea34ca262fce81a2c5026e7
parent4d19f45578a0ddb0ec99f260de8d5208c8659824 (diff)
downloadbundler-bf367148a45bfc56142db4d4fc32f137e1056f60.tar.gz
Don't claim to be deleting gems from vendor/cache when nothing actually happens
-rw-r--r--lib/bundler/runtime.rb21
-rw-r--r--spec/cache/gems_spec.rb12
-rw-r--r--spec/cache/path_spec.rb4
3 files changed, 28 insertions, 9 deletions
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index efcee1c5b6..a3cbac1cf6 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -86,13 +86,22 @@ module Bundler
FileUtils.mkdir_p(cache_path)
resolve = @definition.resolve
+ cached = Dir["#{cache_path}/*.gem"]
- Bundler.ui.info "Removing outdated .gem files from vendor/cache"
- Pathname.glob(cache_path.join("*.gem").to_s).each do |gem_path|
- cached = Gem::Format.from_file_by_path(gem_path).spec
- unless resolve.any?{|s| s.name == cached.name && s.version == cached.version }
- Bundler.ui.info " * #{File.basename(gem_path)}"
- gem_path.rmtree
+ cached = cached.delete_if do |path|
+ spec = Gem::Format.from_file_by_path(path).spec
+
+ resolve.any? do |s|
+ s.name == spec.name && s.version == spec.version
+ end
+ end
+
+ if cached.any?
+ Bundler.ui.info "Removing outdated .gem files from vendor/cache"
+
+ cached.each do |path|
+ Bundler.ui.info " * #{File.basename(path)}"
+ File.delete(path)
end
end
end
diff --git a/spec/cache/gems_spec.rb b/spec/cache/gems_spec.rb
index 8f80b6e5cc..088a34709d 100644
--- a/spec/cache/gems_spec.rb
+++ b/spec/cache/gems_spec.rb
@@ -157,6 +157,16 @@ describe "bundle cache" do
File.open(bundled_app("vendor/cache/bar"), 'w'){|f| f.write("not a gem") }
bundle :cache
end
+
+ it "does not say that it is removing gems when it isn't actually doing so" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+ bundle "cache"
+ bundle "install"
+ out.should_not =~ /removing/i
+ end
end
-end \ No newline at end of file
+end
diff --git a/spec/cache/path_spec.rb b/spec/cache/path_spec.rb
index 10c1e77716..6a78ac3b5e 100644
--- a/spec/cache/path_spec.rb
+++ b/spec/cache/path_spec.rb
@@ -10,7 +10,7 @@ describe "bundle cache" do
G
bundle "cache"
- out.should == "Updating .gem files in vendor/cache\nRemoving outdated .gem files from vendor/cache"
+ out.should == "Updating .gem files in vendor/cache"
end
it "warns when the path is outside of the bundle" do
@@ -24,4 +24,4 @@ describe "bundle cache" do
out.should include("foo at `#{lib_path("foo-1.0")}` will not be cached")
end
end
-end \ No newline at end of file
+end