summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2010-07-13 18:11:07 -0700
committerCarl Lerche <carllerche@mac.com>2010-07-13 18:11:07 -0700
commit17121b84c9b0401796f61a7e2fcb38c04477086c (patch)
tree76766e50ce04262e9f293d7484cfe06a26831eb0
parent911403eb5ec2827c422bdd59a6bb10c9b0780e5c (diff)
downloadbundler-17121b84c9b0401796f61a7e2fcb38c04477086c.tar.gz
Don't delete Gemfile.lock at the start of a bundle update
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/definition.rb8
-rw-r--r--spec/update/gems_spec.rb11
3 files changed, 17 insertions, 4 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 6bcf944de4..e468232e4c 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -134,7 +134,7 @@ module Bundler
if gems.empty? && sources.empty?
# We're doing a full update
- FileUtils.rm_f Bundler.root.join("Gemfile.lock")
+ Bundler.definition(true)
else
Bundler.definition(:gems => gems, :sources => sources)
end
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 5b85e63e00..e1b898221a 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -34,22 +34,24 @@ module Bundler
@dependencies, @sources, @unlock = dependencies, sources, unlock
@remote = false
@specs = nil
- @unlock[:gems] ||= []
- @unlock[:sources] ||= []
- if lockfile && File.exists?(lockfile)
+ if lockfile && File.exists?(lockfile) && unlock != true
locked = LockfileParser.new(File.read(lockfile))
@platforms = locked.platforms
@locked_deps = locked.dependencies
@last_resolve = SpecSet.new(locked.specs)
@locked_sources = locked.sources
else
+ @unlock = {}
@platforms = []
@locked_deps = []
@last_resolve = SpecSet.new([])
@locked_sources = []
end
+ @unlock[:gems] ||= []
+ @unlock[:sources] ||= []
+
current_platform = Gem.platforms.map { |p| p.to_generic }.compact.last
@platforms |= [current_platform]
diff --git a/spec/update/gems_spec.rb b/spec/update/gems_spec.rb
index 92b39aed4a..5233881342 100644
--- a/spec/update/gems_spec.rb
+++ b/spec/update/gems_spec.rb
@@ -20,6 +20,17 @@ describe "bundle update" do
bundle "update"
should_be_installed "rack 1.2", "rack-obama 1.0", "activesupport 3.0"
end
+
+ it "doesn't delete the Gemfile.lock file if something goes wrong" do
+ gemfile <<-G
+ source "file://#{gem_repo2}"
+ gem "activesupport"
+ gem "rack-obama"
+ exit!
+ G
+ bundle "update"
+ bundled_app("Gemfile.lock").should exist
+ end
end
describe "with a top level dependency" do