summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2018-10-02 21:38:23 -0700
committerSamuel Giddins <segiddins@segiddins.me>2018-10-02 21:38:23 -0700
commita04d97d1bab4c4ffcb65484192cc9ea200de7b09 (patch)
tree08cfc809de900d4507d3ed6db1c9fdb65c776ca3
parent2264db9b12cf7ef74163b711baea95cfd91411e4 (diff)
downloadbundler-a04d97d1bab4c4ffcb65484192cc9ea200de7b09.tar.gz
Add another spec, separate new case into its own test
-rw-r--r--lib/bundler/source/git.rb2
-rw-r--r--spec/install/gemfile/git_spec.rb95
2 files changed, 96 insertions, 1 deletions
diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb
index 33f0af89ee..8a31fa307f 100644
--- a/lib/bundler/source/git.rb
+++ b/lib/bundler/source/git.rb
@@ -260,7 +260,7 @@ module Bundler
end
def requires_checkout?
- !cached_revision_checked_out? && allow_git_ops? && !local?
+ allow_git_ops? && !local? && !cached_revision_checked_out?
end
def cached_revision_checked_out?
diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb
index 843a177af4..651deb3265 100644
--- a/spec/install/gemfile/git_spec.rb
+++ b/spec/install/gemfile/git_spec.rb
@@ -1211,6 +1211,47 @@ In Gemfile:
install_gemfile <<-G
source "file://#{gem_repo1}"
+ gem "foo", :git => "#{lib_path("foo-1.0")}"
+ G
+
+ run! <<-R
+ require 'foo'
+ puts FOO
+ R
+
+ installed_time = out
+ expect(installed_time).to match(/\A\d+\.\d+\z/)
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "foo", :git => "#{lib_path("foo-1.0")}"
+ G
+
+ run! <<-R
+ require 'foo'
+ puts FOO
+ R
+ expect(out).to eq(installed_time)
+ end
+
+ it "does not reinstall the extension when changing another gem", :rubygems => ">= 2.3.0" do
+ build_git "foo" do |s|
+ s.add_dependency "rake"
+ s.extensions << "Rakefile"
+ s.write "Rakefile", <<-RUBY
+ task :default do
+ path = File.expand_path("../lib", __FILE__)
+ FileUtils.mkdir_p(path)
+ cur_time = Time.now.to_f.to_s
+ File.open("\#{path}/foo.rb", "w") do |f|
+ f.puts "FOO = \#{cur_time}"
+ end
+ end
+ RUBY
+ end
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
gem "rack", "0.9.1"
gem "foo", :git => "#{lib_path("foo-1.0")}"
G
@@ -1235,6 +1276,60 @@ In Gemfile:
R
expect(out).to eq(installed_time)
end
+
+ it "does reinstall the extension when changing refs", :rubygems => ">= 2.3.0" do
+ build_git "foo" do |s|
+ s.add_dependency "rake"
+ s.extensions << "Rakefile"
+ s.write "Rakefile", <<-RUBY
+ task :default do
+ path = File.expand_path("../lib", __FILE__)
+ FileUtils.mkdir_p(path)
+ cur_time = Time.now.to_f.to_s
+ File.open("\#{path}/foo.rb", "w") do |f|
+ f.puts "FOO = \#{cur_time}"
+ end
+ end
+ RUBY
+ end
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "foo", :git => "#{lib_path("foo-1.0")}"
+ G
+
+ run! <<-R
+ require 'foo'
+ puts FOO
+ R
+
+ update_git("foo", :branch => "branch2")
+
+ installed_time = out
+ expect(installed_time).to match(/\A\d+\.\d+\z/)
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "foo", :git => "#{lib_path("foo-1.0")}", :branch => "branch2"
+ G
+
+ run! <<-R
+ require 'foo'
+ puts FOO
+ R
+ expect(out).not_to eq(installed_time)
+
+ installed_time = out
+
+ update_git("foo")
+ bundle! "update foo"
+
+ run! <<-R
+ require 'foo'
+ puts FOO
+ R
+ expect(out).not_to eq(installed_time)
+ end
end
it "ignores git environment variables" do