Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1358 from robertwahler/bundler

---

This fixes issue #1105, Gemfile.lock always updated on Windows
when running bundle install
  • Loading branch information...
commit 711b24055333126dc9dcf893048a83576cba4568 2 parents 7c5e545 + dc15dc5
@indirect indirect authored
Showing with 51 additions and 17 deletions.
  1. +4 −4 lib/bundler/definition.rb
  2. +47 −13 spec/lock/lockfile_spec.rb
View
8 lib/bundler/definition.rb
@@ -180,6 +180,10 @@ def groups
def lock(file)
contents = to_lock
+ # Convert to \r\n if the existing lock has them
+ # i.e., Windows with `git config core.autocrlf=true`
+ contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n")
+
return if @lockfile_contents == contents
if Bundler.settings[:frozen]
@@ -187,10 +191,6 @@ def lock(file)
return
end
- # Convert to \r\n if the existing lock has them
- # i.e., Windows with `git config core.autocrlf=true`
- contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match("\r\n")
-
File.open(file, 'wb'){|f| f.puts(contents) }
end
View
60 spec/lock/lockfile_spec.rb
@@ -671,13 +671,18 @@
end
- context "line endings" do
+ describe "line endings" do
+ def set_lockfile_mtime_to_known_value
+ time = Time.local(2000, 1, 1, 0, 0, 0)
+ File.utime(time, time, bundled_app('Gemfile.lock'))
+ end
before(:each) do
build_repo2
install_gemfile <<-G
source "file://#{gem_repo2}"
gem "rack"
G
+ set_lockfile_mtime_to_known_value
end
it "generates Gemfile.lock with \\n line endings" do
@@ -685,22 +690,51 @@
should_be_installed "rack 1.0"
end
- it "preserves Gemfile.lock \\n line endings" do
- update_repo2
+ context "during updates" do
- bundle "update"
- File.read(bundled_app("Gemfile.lock")).should_not match("\r\n")
- should_be_installed "rack 1.2"
+ it "preserves Gemfile.lock \\n line endings" do
+ update_repo2
+
+ lambda { bundle "update" }.should change { File.mtime(bundled_app('Gemfile.lock')) }
+ File.read(bundled_app("Gemfile.lock")).should_not match("\r\n")
+ should_be_installed "rack 1.2"
+ end
+
+ it "preserves Gemfile.lock \\n\\r line endings" do
+ update_repo2
+ win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
+ File.open(bundled_app("Gemfile.lock"), "wb"){|f| f.puts(win_lock) }
+ set_lockfile_mtime_to_known_value
+
+ lambda { bundle "update" }.should change { File.mtime(bundled_app('Gemfile.lock')) }
+ File.read(bundled_app("Gemfile.lock")).should match("\r\n")
+ should_be_installed "rack 1.2"
+ end
end
- it "preserves Gemfile.lock \\n\\r line endings" do
- update_repo2
- win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
- File.open(bundled_app("Gemfile.lock"), "wb"){|f| f.puts(win_lock) }
+ context "when nothing changes" do
- bundle "update"
- File.read(bundled_app("Gemfile.lock")).should match("\r\n")
- should_be_installed "rack 1.2"
+ it "preserves Gemfile.lock \\n line endings" do
+ lambda { ruby <<-RUBY
+ require 'rubygems'
+ require 'bundler'
+ Bundler.setup
+ RUBY
+ }.should_not change { File.mtime(bundled_app('Gemfile.lock')) }
+ end
+
+ it "preserves Gemfile.lock \\n\\r line endings" do
+ win_lock = File.read(bundled_app("Gemfile.lock")).gsub(/\n/, "\r\n")
+ File.open(bundled_app("Gemfile.lock"), "wb"){|f| f.puts(win_lock) }
+ set_lockfile_mtime_to_known_value
+
+ lambda { ruby <<-RUBY
+ require 'rubygems'
+ require 'bundler'
+ Bundler.setup
+ RUBY
+ }.should_not change { File.mtime(bundled_app('Gemfile.lock')) }
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.