summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel E. Giddins <segiddins@segiddins.me>2015-06-23 23:15:49 -0700
committerSamuel E. Giddins <segiddins@segiddins.me>2015-06-23 23:15:49 -0700
commitf3d6ecae9c968f97dc3a513d504271d3d15d29f8 (patch)
tree3a8d0ba8924ea3405e6c136da5427ab61c66d240
parent239d01df6d43cd4e9e333a18faf59d9c3e5e46c3 (diff)
downloadbundler-seg-bundled-with.tar.gz
[Definition] Dont updated bundled with when 100% unnecessaryseg-bundled-with
-rw-r--r--lib/bundler/definition.rb19
-rw-r--r--spec/lock/lockfile_spec.rb44
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