summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2014-03-31 11:00:01 +0800
committerAndre Arko <andre@arko.net>2014-03-31 11:00:01 +0800
commitabb55ce407c80d017841266238c971e07dd0d8b6 (patch)
tree47ab25bf5afa67c2fdc829633925e16a94a80679
parent0ccb61c92712f292807770aec84bdde96436020c (diff)
parentd98f3f9ba83bc67c6f566a928b78ff0a7ba06420 (diff)
downloadbundler-abb55ce407c80d017841266238c971e07dd0d8b6.tar.gz
Merge pull request #2948 from dylanahsmith/sha-ext-dir
Use git sha as part of extension directory for git referenced gems.
-rw-r--r--lib/bundler/rubygems_ext.rb9
-rw-r--r--lib/bundler/source/git.rb4
-rw-r--r--spec/install/gemfile/git_spec.rb37
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"