summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2019-04-10 11:58:30 +0200
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-06-27 13:16:41 +0200
commitb47d23edf5fd7a0c7236c2bc66e5b132a5aa55ae (patch)
tree78461ecc0778724764e02e728966e82b1688c89c
parent391b11966efb140a9ba204ca4e05ec7694296ce0 (diff)
downloadbundler-b47d23edf5fd7a0c7236c2bc66e5b132a5aa55ae.tar.gz
Clearer MissingRevision git errors
-rw-r--r--lib/bundler/source/git/git_proxy.rb18
-rw-r--r--spec/bundler/source/git/git_proxy_spec.rb7
2 files changed, 16 insertions, 9 deletions
diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb
index f5af10f206..c383c5ecbb 100644
--- a/lib/bundler/source/git/git_proxy.rb
+++ b/lib/bundler/source/git/git_proxy.rb
@@ -26,7 +26,11 @@ module Bundler
end
class GitCommandError < GitError
+ attr_reader :command
+
def initialize(command, path = nil, extra_info = nil)
+ @command = command
+
msg = String.new
msg << "Git error: command `git #{command}` in directory #{SharedHelpers.pwd} has failed."
msg << "\n#{extra_info}" if extra_info
@@ -35,10 +39,10 @@ module Bundler
end
end
- class MissingGitRevisionError < GitError
- def initialize(ref, repo)
+ class MissingGitRevisionError < GitCommandError
+ def initialize(command, path, ref, repo)
msg = "Revision #{ref} does not exist in the repository #{repo}. Maybe you misspelled it?"
- super msg
+ super command, path, msg
end
end
@@ -63,8 +67,8 @@ module Bundler
begin
@revision ||= find_local_revision
- rescue GitCommandError
- raise MissingGitRevisionError.new(ref, URICredentialsFilter.credential_filtered_uri(uri))
+ rescue GitCommandError => e
+ raise MissingGitRevisionError.new(e.command, path, ref, URICredentialsFilter.credential_filtered_uri(uri))
end
@revision
@@ -135,8 +139,8 @@ module Bundler
begin
git "reset --hard #{@revision}"
- rescue GitCommandError
- raise MissingGitRevisionError.new(@revision, URICredentialsFilter.credential_filtered_uri(uri))
+ rescue GitCommandError => e
+ raise MissingGitRevisionError.new(e.command, path, @revision, URICredentialsFilter.credential_filtered_uri(uri))
end
if submodules
diff --git a/spec/bundler/source/git/git_proxy_spec.rb b/spec/bundler/source/git/git_proxy_spec.rb
index 016105ccde..8ac0ae4dd0 100644
--- a/spec/bundler/source/git/git_proxy_spec.rb
+++ b/spec/bundler/source/git/git_proxy_spec.rb
@@ -136,8 +136,11 @@ RSpec.describe Bundler::Source::Git::GitProxy do
expect(subject).not_to receive(:git)
expect { subject.copy_to(destination, submodules) }.
- to raise_error(Bundler::Source::Git::MissingGitRevisionError,
- "Revision #{revision} does not exist in the repository #{uri}. Maybe you misspelled it?")
+ to raise_error(
+ Bundler::Source::Git::MissingGitRevisionError,
+ "Git error: command `git command` in directory #{destination} has failed.\n" \
+ "Revision #{revision} does not exist in the repository #{uri}. Maybe you misspelled it?" \
+ )
end
end
end