Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Add another spec, separate new case into its own test
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Oct 3, 2018
1 parent 2264db9 commit a04d97d
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bundler/source/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def local?
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?
Expand Down
95 changes: 95 additions & 0 deletions spec/install/gemfile/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,47 @@
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

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"
Expand All @@ -1235,6 +1276,60 @@
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
Expand Down

0 comments on commit a04d97d

Please sign in to comment.