Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

WIP

  • Loading branch information...
commit eaa91b9c088187c76d802c44005afc0225e4142f 1 parent c26b2c3
Carlhuda authored
View
5 lib/bundler/cli.rb
@@ -175,8 +175,9 @@ def show(gem_name = nil)
desc "cache", "Cache all the gems to vendor/cache", :hide => true
method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
def cache
- Bundler.load.cache
- Bundler.load.prune_cache unless options[:no_prune]
+ environment = Bundler.load
+ environment.cache
+ environment.prune_cache unless options[:no_prune]
rescue GemNotFound => e
Bundler.ui.error(e.message)
Bundler.ui.warn "Run `bundle install` to install missing gems."
View
28 lib/bundler/source.rb
@@ -553,12 +553,18 @@ def load_spec_files
private
def git(command)
- out = %x{git #{command}}
+ if allow_git_ops?
+ out = %x{git #{command}}
- if $? != 0
- raise GitError, "An error has occurred in git. Cannot complete bundling."
+ if $? != 0
+ raise GitError, "An error has occurred in git. Cannot complete bundling."
+ end
+ out
+ else
+ raise GitError, "Bundler is trying to run a `git #{command}` at runtime. You probably need to run `bundle install`. However, " \
+ "this error message could probably be more useful. Please submit a ticket at http://github.com/carlhuda/bundler/issues " \
+ "with steps to reproduce as well as the following\n\nCALLER: #{caller.join("\n")}"
end
- out
end
def base_name
@@ -627,8 +633,20 @@ def has_revision_cached?
$? == 0
end
+ def allow_git_ops?
+ STDERR.puts "----"
+ STDERR.puts [@allow_remote, @allow_cache].inspect
+ STDERR.puts caller
+ STDERR.puts "----"
+ @allow_remote || @allow_cache
+ end
+
def revision
- @revision ||= in_cache { git("rev-parse #{ref}").strip }
+ if allow_git_ops?
+ @revision ||= in_cache { git("rev-parse #{ref}").strip }
+ else
+ raise GitError, "The git source #{uri} is not yet checked out. Please run `bundle install` before trying to start your application"
+ end
end
def cached?
View
1  spec/cache/gems_spec.rb
@@ -68,6 +68,7 @@
system_gems []
bundle "install --local"
+ puts out
should_be_installed("rack 1.0.0", "foo 1.0")
end
View
50 spec/runtime/setup_spec.rb
@@ -165,16 +165,62 @@
end
describe "with git" do
- it "provides a useful exception when the git repo is not checked out yet" do
+ before do
build_git "rack", "1.0.0"
gemfile <<-G
- gem "foo", :git => "#{lib_path('rack-1.0.0')}"
+ gem "rack", :git => "#{lib_path('rack-1.0.0')}"
G
+ end
+ it "provides a useful exception when the git repo is not checked out yet" do
run "1", :expect_err => true
err.should include("#{lib_path('rack-1.0.0')} (at master) is not checked out. Please run `bundle install`")
end
+
+ it "does not hit the git binary if the lockfile is available and up to date" do
+ bundle "install"
+
+ break_git!
+
+ ruby <<-R
+ require 'rubygems'
+ require 'bundler'
+
+ begin
+ Bundler.setup
+ puts "WIN"
+ rescue Exception => e
+ puts "FAIL"
+ end
+ R
+
+ out.should == "WIN"
+ end
+
+ it "provides a good exception if the lockfile is unavailable" do
+ bundle "install"
+
+ FileUtils.rm(bundled_app("Gemfile.lock"))
+
+ break_git!
+
+ ruby <<-R
+ require "rubygems"
+ require "bundler"
+
+ begin
+ Bundler.setup
+ puts "FAIL"
+ rescue Bundler::GitError => e
+ puts e.message
+ end
+ R
+
+ run "puts 'FAIL'", :expect_err => true
+
+ err.should_not include "This is not the git you are looking for"
+ end
end
describe "when excluding groups" do
View
9 spec/support/helpers.rb
@@ -157,6 +157,15 @@ def with_gem_path_as(path)
ENV['GEM_HOME'], ENV['GEM_PATH'] = gem_home, gem_path
end
+ def break_git!
+ FileUtils.mkdir_p(tmp("broken_path"))
+ File.open(tmp("broken_path/git"), "w", 0755) do |f|
+ f.puts "#!/usr/bin/env ruby\nSTDERR.puts 'This is not the git you are looking for'\nexit 1"
+ end
+
+ ENV["PATH"] = "#{tmp("broken_path")}:#{ENV["PATH"]}"
+ end
+
def system_gems(*gems)
gems = gems.flatten
Please sign in to comment.
Something went wrong with that request. Please try again.