mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
e405aede09
commit
4b1395ab4a
2 changed files with 16 additions and 9 deletions
|
@ -26,7 +26,11 @@ module Bundler
|
||||||
end
|
end
|
||||||
|
|
||||||
class GitCommandError < GitError
|
class GitCommandError < GitError
|
||||||
|
attr_reader :command
|
||||||
|
|
||||||
def initialize(command, path = nil, extra_info = nil)
|
def initialize(command, path = nil, extra_info = nil)
|
||||||
|
@command = command
|
||||||
|
|
||||||
msg = String.new
|
msg = String.new
|
||||||
msg << "Git error: command `git #{command}` in directory #{SharedHelpers.pwd} has failed."
|
msg << "Git error: command `git #{command}` in directory #{SharedHelpers.pwd} has failed."
|
||||||
msg << "\n#{extra_info}" if extra_info
|
msg << "\n#{extra_info}" if extra_info
|
||||||
|
@ -35,10 +39,10 @@ module Bundler
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class MissingGitRevisionError < GitError
|
class MissingGitRevisionError < GitCommandError
|
||||||
def initialize(ref, repo)
|
def initialize(command, path, ref, repo)
|
||||||
msg = "Revision #{ref} does not exist in the repository #{repo}. Maybe you misspelled it?"
|
msg = "Revision #{ref} does not exist in the repository #{repo}. Maybe you misspelled it?"
|
||||||
super msg
|
super command, path, msg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,8 +67,8 @@ module Bundler
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@revision ||= find_local_revision
|
@revision ||= find_local_revision
|
||||||
rescue GitCommandError
|
rescue GitCommandError => e
|
||||||
raise MissingGitRevisionError.new(ref, URICredentialsFilter.credential_filtered_uri(uri))
|
raise MissingGitRevisionError.new(e.command, path, ref, URICredentialsFilter.credential_filtered_uri(uri))
|
||||||
end
|
end
|
||||||
|
|
||||||
@revision
|
@revision
|
||||||
|
@ -135,8 +139,8 @@ module Bundler
|
||||||
|
|
||||||
begin
|
begin
|
||||||
git "reset --hard #{@revision}"
|
git "reset --hard #{@revision}"
|
||||||
rescue GitCommandError
|
rescue GitCommandError => e
|
||||||
raise MissingGitRevisionError.new(@revision, URICredentialsFilter.credential_filtered_uri(uri))
|
raise MissingGitRevisionError.new(e.command, path, @revision, URICredentialsFilter.credential_filtered_uri(uri))
|
||||||
end
|
end
|
||||||
|
|
||||||
if submodules
|
if submodules
|
||||||
|
|
|
@ -136,8 +136,11 @@ RSpec.describe Bundler::Source::Git::GitProxy do
|
||||||
expect(subject).not_to receive(:git)
|
expect(subject).not_to receive(:git)
|
||||||
|
|
||||||
expect { subject.copy_to(destination, submodules) }.
|
expect { subject.copy_to(destination, submodules) }.
|
||||||
to raise_error(Bundler::Source::Git::MissingGitRevisionError,
|
to raise_error(
|
||||||
"Revision #{revision} does not exist in the repository #{uri}. Maybe you misspelled it?")
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue