diff options
author | André Arko <mail@arko.net> | 2015-06-24 13:56:46 -0700 |
---|---|---|
committer | André Arko <mail@arko.net> | 2015-06-24 13:56:46 -0700 |
commit | ec6b888dfc910ff65e3f4ac25ce43c3f901e0fd3 (patch) | |
tree | 25a4cf8146f9e2ff978610137b1cc01ce941279f | |
parent | f8ee889d4e0002dd871e0d6d5817944c23bd083d (diff) | |
parent | f3d6ecae9c968f97dc3a513d504271d3d15d29f8 (diff) | |
download | bundler-ec6b888dfc910ff65e3f4ac25ce43c3f901e0fd3.tar.gz |
Merge pull request #3779 from bundler/seg-bundled-with
[Definition] Dont updated bundled with when 100% unnecessary
-rw-r--r-- | lib/bundler/definition.rb | 19 | ||||
-rw-r--r-- | spec/lock/lockfile_spec.rb | 44 |
2 files changed, 52 insertions, 11 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 81401ff81a..be3c2eca43 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -248,23 +248,24 @@ module Bundler # i.e., Windows with `git config core.autocrlf=true` contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n") - return if lockfiles_equal?(@lockfile_contents, contents, preserve_bundled_with) - - if Bundler.settings[:frozen] - Bundler.ui.error "Cannot write a changed lockfile while frozen." - return - end - if @locked_bundler_version locked_major = @locked_bundler_version.segments.first current_major = Gem::Version.create(Bundler::VERSION).segments.first - if locked_major < current_major - Bundler.ui.warn "Warning: the lockfile is being updated to Bundler #{Bundler::VERSION.split('.').first}, " \ + if updating_major = locked_major < current_major + Bundler.ui.warn "Warning: the lockfile is being updated to Bundler #{current_major}, " \ "after which you will be unable to return to Bundler #{@locked_bundler_version.segments.first}." end end + preserve_bundled_with ||= !updating_major && (Bundler.settings[:frozen] || !@unlocking) + return if lockfiles_equal?(@lockfile_contents, contents, preserve_bundled_with) + + if Bundler.settings[:frozen] + Bundler.ui.error "Cannot write a changed lockfile while frozen." + return + end + File.open(file, 'wb'){|f| f.puts(contents) } rescue Errno::EACCES raise Bundler::InstallError, diff --git a/spec/lock/lockfile_spec.rb b/spec/lock/lockfile_spec.rb index 657f91a2c6..9f13a016d7 100644 --- a/spec/lock/lockfile_spec.rb +++ b/spec/lock/lockfile_spec.rb @@ -74,8 +74,7 @@ describe "the lockfile format" do G end - it "updates the lockfile's bundler version if not present" do - + it "does not update the lockfile's bundler version if nothing changed during bundle install" do lockfile <<-L GEM remote: file:#{gem_repo1}/ @@ -87,6 +86,9 @@ describe "the lockfile format" do DEPENDENCIES rack + + BUNDLED WITH + 1.10.0 L install_gemfile <<-G @@ -108,6 +110,44 @@ describe "the lockfile format" do rack BUNDLED WITH + 1.10.0 + G + end + + it "updates the lockfile's bundler version if not present" do + + lockfile <<-L + GEM + remote: file:#{gem_repo1}/ + specs: + rack (1.0.0) + + PLATFORMS + #{generic(Gem::Platform.local)} + + DEPENDENCIES + rack + L + + install_gemfile <<-G + source "file://#{gem_repo1}" + + gem "rack", "> 0" + G + + lockfile_should_be <<-G + GEM + remote: file:#{gem_repo1}/ + specs: + rack (1.0.0) + + PLATFORMS + #{generic(Gem::Platform.local)} + + DEPENDENCIES + rack (> 0) + + BUNDLED WITH #{Bundler::VERSION} G end |