diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-04-28 14:43:55 +0200 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-04-28 14:48:56 +0200 |
commit | 7d8ae92f75fa262f466a3f0fca29e26f3af38f12 (patch) | |
tree | 80cc3e82e1f3f579fdf9bd1f4de54a8baeab4fcd /spec/install/gemfile | |
parent | 2d6498b84198a20e73c65734d813558f5f921ce2 (diff) | |
download | bundler-7d8ae92f75fa262f466a3f0fca29e26f3af38f12.tar.gz |
[Git] Allow specifying non-branch symbolic refsseg-fetch-named-symbolic-refs
Diffstat (limited to 'spec/install/gemfile')
-rw-r--r-- | spec/install/gemfile/git_spec.rb | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index 8843fb7ebb..a53d96582a 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -207,6 +207,93 @@ RSpec.describe "bundle install with git sources" do expect(out).to eq("WIN") end + + it "works when the revision is a non-head ref" do + # want to ensure we don't fallback to master + update_git "foo", :path => lib_path("foo-1.0") do |s| + s.write("lib/foo.rb", "raise 'FAIL'") + end + + Dir.chdir(lib_path("foo-1.0")) do + `git update-ref -m 'Bundler Spec!' refs/bundler/1 master~1` + end + + # want to ensure we don't fallback to HEAD + update_git "foo", :path => lib_path("foo-1.0"), :branch => "rando" do |s| + s.write("lib/foo.rb", "raise 'FAIL'") + end + + install_gemfile! <<-G + git "#{lib_path("foo-1.0")}", :ref => "refs/bundler/1" do + gem "foo" + end + G + expect(err).to lack_errors + + run! <<-RUBY + require 'foo' + puts "WIN" if defined?(FOO) + RUBY + + expect(out).to eq("WIN") + end + + it "works when the revision is a non-head ref and it was previously downloaded" do + install_gemfile! <<-G + git "#{lib_path("foo-1.0")}" do + gem "foo" + end + G + + # want to ensure we don't fallback to master + update_git "foo", :path => lib_path("foo-1.0") do |s| + s.write("lib/foo.rb", "raise 'FAIL'") + end + + Dir.chdir(lib_path("foo-1.0")) do + `git update-ref -m 'Bundler Spec!' refs/bundler/1 master~1` + end + + # want to ensure we don't fallback to HEAD + update_git "foo", :path => lib_path("foo-1.0"), :branch => "rando" do |s| + s.write("lib/foo.rb", "raise 'FAIL'") + end + + install_gemfile! <<-G + git "#{lib_path("foo-1.0")}", :ref => "refs/bundler/1" do + gem "foo" + end + G + expect(err).to lack_errors + + run! <<-RUBY + require 'foo' + puts "WIN" if defined?(FOO) + RUBY + + expect(out).to eq("WIN") + end + + it "does not download random non-head refs" do + Dir.chdir(lib_path("foo-1.0")) do + `git update-ref -m 'Bundler Spec!' refs/bundler/1 master~1` + end + + install_gemfile! <<-G + git "#{lib_path("foo-1.0")}" do + gem "foo" + end + G + + # ensure we also git fetch after cloning + bundle! :update + + Dir.chdir(Dir[system_gem_path("cache/bundler/git/foo-*")].first) do + @out = sys_exec("git ls-remote .") + end + + expect(out).not_to include("refs/bundler/1") + end end describe "when specifying a branch" do |