summaryrefslogtreecommitdiff
path: root/lib/bundler/source/git/git_proxy.rb
diff options
context:
space:
mode:
authorAgis- <corestudiosinc@gmail.com>2015-08-27 00:43:20 +0300
committerAgis- <corestudiosinc@gmail.com>2015-08-27 00:57:55 +0300
commitb8da6a9e498fbf7e2499a5cc45e5a7035890e43a (patch)
treeeaacbd408c5b4bb6aa34b7774cea193680bee342 /lib/bundler/source/git/git_proxy.rb
parent406e069b7a6c870fe7db4dc6d891adde85b96f47 (diff)
downloadbundler-b8da6a9e498fbf7e2499a5cc45e5a7035890e43a.tar.gz
Show friendly errors when ref is not found
Before: $ bundle install Fetching git://github.com/agis-/some_gem.git fatal: ambiguous argument 'FOO': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git [...] -- [...]' Git error: command `git rev-parse WRONG` in directory /cache/path has failed. Ref 'foo' was not found. Perhaps you mispelled it? If this error persists you could try removing the cache directory # ... After: $ bundle install Fetching git://github.com/agis-/some_gem.git fatal: Needed a single revision Git error: command `git rev-parse --verify WRONG` in directory /cache/path has failed. Ref 'foo' was not found. Perhaps you mispelled it? If this error persists you could try removing the cache directory # ... Closes #3897.
Diffstat (limited to 'lib/bundler/source/git/git_proxy.rb')
-rw-r--r--lib/bundler/source/git/git_proxy.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb
index f7de1a0a56..739f4e09a1 100644
--- a/lib/bundler/source/git/git_proxy.rb
+++ b/lib/bundler/source/git/git_proxy.rb
@@ -19,8 +19,9 @@ module Bundler
end
class GitCommandError < GitError
- def initialize(command, path = nil)
+ def initialize(command, path = nil, extra_info = nil)
msg = "Git error: command `git #{command}` in directory #{SharedHelpers.pwd} has failed."
+ msg << "\n#{extra_info}" if extra_info
msg << "\nIf this error persists you could try removing the cache directory '#{path}'" if path && path.exist?
super msg
end
@@ -43,7 +44,10 @@ module Bundler
end
def revision
- @revision ||= allowed_in_path { git("rev-parse #{ref}").strip }
+ @revision ||= allowed_in_path do
+ msg = "Ref '#{ref}' was not found. Perhaps you mispelled it?"
+ git("rev-parse --verify #{ref}", true, msg).strip
+ end
end
def branch
@@ -120,10 +124,10 @@ module Bundler
end
end
- def git(command, check_errors = true)
+ def git(command, check_errors = true, error_msg = nil)
raise GitNotAllowedError.new(command) unless allow?
out = SharedHelpers.with_clean_git_env { `git #{command}` }
- raise GitCommandError.new(command, path) if check_errors && !$?.success?
+ raise GitCommandError.new(command, path, error_msg) if check_errors && !$?.success?
out
end