From f64c6dac2503db5a0acb4e4a532c9c32b224eb67 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Sat, 24 Jul 2010 12:12:57 -0700 Subject: Fixes a bug where cached gems for other platforms were being removed when running `bundle update` --- lib/bundler/definition.rb | 16 ++++++++++++---- spec/cache/platform_spec.rb | 13 +++++++++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index e9e7291df6..0127365a03 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -38,13 +38,21 @@ module Bundler @specs = nil @lockfile_contents = "" - if lockfile && File.exists?(lockfile) && unlock != true + if lockfile && File.exists?(lockfile) @lockfile_contents = File.read(lockfile) locked = LockfileParser.new(@lockfile_contents) @platforms = locked.platforms - @locked_deps = locked.dependencies - @last_resolve = SpecSet.new(locked.specs) - @locked_sources = locked.sources + + if unlock != true + @locked_deps = locked.dependencies + @last_resolve = SpecSet.new(locked.specs) + @locked_sources = locked.sources + else + @unlock = {} + @locked_deps = [] + @last_resolve = SpecSet.new([]) + @locked_sources = [] + end else @unlock = {} @platforms = [] diff --git a/spec/cache/platform_spec.rb b/spec/cache/platform_spec.rb index 9e3f357060..7c9ec72867 100644 --- a/spec/cache/platform_spec.rb +++ b/spec/cache/platform_spec.rb @@ -35,14 +35,23 @@ describe "bundle cache with multiple platforms" do activesupport (2.3.5) activerecord (2.3.2) G - end - it "does not delete gems for other platforms" do cache_gems "rack-1.0.0", "activesupport-2.3.5", "activerecord-2.3.2" + end + + it "ensures that bundle install does not delete gems for other platforms" do bundle "install" bundled_app("vendor/cache/rack-1.0.0.gem").should exist bundled_app("vendor/cache/activesupport-2.3.5.gem").should exist bundled_app("vendor/cache/activerecord-2.3.2.gem").should exist end + + it "ensures that bundle update does not delete gems for other platforms" do + bundle "update" + + bundled_app("vendor/cache/rack-1.0.0.gem").should exist + bundled_app("vendor/cache/activesupport-2.3.5.gem").should exist + bundled_app("vendor/cache/activerecord-2.3.2.gem").should exist + end end -- cgit v1.2.1