Skip to content

Commit

Permalink
hiding git shallow marker to avoid ci failure when bundler tries to c…
Browse files Browse the repository at this point in the history
…heckout a git gem from a shallow repo
  • Loading branch information
jkutner committed Apr 5, 2013
1 parent 0fe9b9b commit 6c7d38c
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions spec/warbler/bundler_spec.rb
Expand Up @@ -20,6 +20,15 @@ def use_config(&block)
@extra_config = block
end

def hide_shallow_git_clone
git_shallow_marker = File.join(Warbler::WARBLER_HOME, ".git/shallow")
tmp_marker = File.join(Warbler::WARBLER_HOME, ".git/shallow.tmp")
File.rename(git_shallow_marker, tmp_marker) if File.exists?(git_shallow_marker)
yield
ensure
File.rename(tmp_marker, git_shallow_marker) if File.exist?(tmp_marker)
end

let(:config) { drbclient.config(@extra_config) }
let(:jar) { drbclient.jar }

Expand Down Expand Up @@ -61,19 +70,23 @@ def use_config(&block)
end

it "works with :git entries in Gemfiles" do
File.open("Gemfile", "w") {|f| f << "gem 'warbler', :git => '#{Warbler::WARBLER_HOME}'\n"}
`#{RUBY_EXE} -S bundle install --local`
jar.apply(config)
file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/lib/warbler/version\.rb}).should_not be_empty
file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/warbler.gemspec}).should_not be_empty
hide_shallow_git_clone do
File.open("Gemfile", "w") {|f| f << "gem 'warbler', :git => '#{Warbler::WARBLER_HOME}'\n"}
`#{RUBY_EXE} -S bundle install --local`
jar.apply(config)
file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/lib/warbler/version\.rb}).should_not be_empty
file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/warbler.gemspec}).should_not be_empty
end
end

it "bundles only the gemspec for :git entries that are excluded" do
File.open("Gemfile", "w") {|f| f << "gem 'rake'\ngroup :test do\ngem 'warbler', :git => '#{Warbler::WARBLER_HOME}'\nend\n"}
`#{RUBY_EXE} -S bundle install --local`
jar.apply(config)
file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/lib/warbler/version\.rb}).should be_empty
file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/warbler.gemspec}).should_not be_empty
hide_shallow_git_clone do
File.open("Gemfile", "w") {|f| f << "gem 'rake'\ngroup :test do\ngem 'warbler', :git => '#{Warbler::WARBLER_HOME}'\nend\n"}
`#{RUBY_EXE} -S bundle install --local`
jar.apply(config)
file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/lib/warbler/version\.rb}).should be_empty
file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/warbler.gemspec}).should_not be_empty
end
end

it "does not work with :path entries in Gemfiles" do
Expand Down Expand Up @@ -117,14 +130,16 @@ def use_config(&block)
cleanup_temp_files

it "works with :git entries in Gemfiles" do
File.open("Gemfile", "w") {|f| f << "gem 'warbler', :git => '#{Warbler::WARBLER_HOME}'\n"}
`#{RUBY_EXE} -S bundle install --local`
jar.apply(config)
file_list(%r{^bundler/gems/warbler[^/]*/lib/warbler/version\.rb}).should_not be_empty
file_list(%r{^bundler/gems/warbler[^/]*/warbler.gemspec}).should_not be_empty
jar.add_init_file(config)
contents = jar.contents('META-INF/init.rb')
contents.should =~ /ENV\['BUNDLE_GEMFILE'\] = File.expand_path(.*, __FILE__)/
hide_shallow_git_clone do
File.open("Gemfile", "w") {|f| f << "gem 'warbler', :git => '#{Warbler::WARBLER_HOME}'\n"}
`#{RUBY_EXE} -S bundle install --local`
jar.apply(config)
file_list(%r{^bundler/gems/warbler[^/]*/lib/warbler/version\.rb}).should_not be_empty
file_list(%r{^bundler/gems/warbler[^/]*/warbler.gemspec}).should_not be_empty
jar.add_init_file(config)
contents = jar.contents('META-INF/init.rb')
contents.should =~ /ENV\['BUNDLE_GEMFILE'\] = File.expand_path(.*, __FILE__)/
end
end

it "adds BUNDLE_GEMFILE to init.rb" do
Expand Down

0 comments on commit 6c7d38c

Please sign in to comment.