diff options
-rw-r--r-- | lib/bundler/rubygems_ext.rb | 9 | ||||
-rw-r--r-- | lib/bundler/source/git.rb | 4 | ||||
-rw-r--r-- | spec/install/gemfile/git_spec.rb | 37 |
3 files changed, 50 insertions, 0 deletions
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index ea018ac972..dccb6fb281 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -45,6 +45,15 @@ module Gem end end + if method_defined?(:extension_dir) + alias_method :rg_extension_dir, :extension_dir + def extension_dir + @extension_dir ||= source.respond_to?(:extension_dir_name) ? + File.expand_path(File.join(extensions_dir, source.extension_dir_name)) : + rg_extension_dir + end + end + # RubyGems 1.8+ used only. remove_method :gem_dir if instance_methods(false).include?(:gem_dir) def gem_dir diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb index 5919328137..3a42202302 100644 --- a/lib/bundler/source/git.rb +++ b/lib/bundler/source/git.rb @@ -90,6 +90,10 @@ module Bundler alias :path :install_path + def extension_dir_name + "#{base_name}-#{shortref_for_path(revision)}" + end + def unlock! git_proxy.revision = nil @unlocked = true diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index 4933727b36..5d83e47b49 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -854,6 +854,43 @@ describe "bundle install with git sources" do expect(out).to eq("YES") end + it "does not use old extension after ref changes" do + git_reader = build_git "foo", :no_default => true do |s| + s.extensions = ["ext/extconf.rb"] + s.write "ext/extconf.rb", <<-RUBY + require "mkmf" + create_makefile("foo") + RUBY + s.write "ext/foo.c", "void Init_foo() {}" + end + + 2.times do |i| + Dir.chdir(git_reader.path) do + File.open("ext/foo.c", "w") do |file| + file.write <<-C + #include "ruby.h" + VALUE foo() { return INT2FIX(#{i}); } + void Init_foo() { rb_define_global_function("foo", &foo, 0); } + C + end + `git commit -m 'commit for iteration #{i}' ext/foo.c` + end + git_sha = git_reader.ref_for("HEAD") + + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "foo", :git => "#{lib_path('foo-1.0')}", :ref => "#{git_sha}" + G + + run <<-R + require 'foo' + puts foo + R + + expect(out).to eq(i.to_s) + end + end + it "does not prompt to gem install if extension fails" do build_git "foo" do |s| s.add_dependency "rake" |