summaryrefslogtreecommitdiff
path: root/lib/bundler/source
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2023-02-15 21:25:55 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-02-21 19:28:12 +0900
commita47e1328e662b5c095b560b842687ed1901fd7b1 (patch)
treee695b4f5a2b342697136f03c38a41dac869836e0 /lib/bundler/source
parentb5eb9ebd5d4eef4ef2c1a4d32b70c17807b834bb (diff)
[rubygems/rubygems] Give a better message when Gemfile branch does not exist
https://github.com/rubygems/rubygems/commit/cb4fc41cbc
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7345
Diffstat (limited to 'lib/bundler/source')
-rw-r--r--lib/bundler/source/git/git_proxy.rb20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb
index 2a2b48053a..3a6a666627 100644
--- a/lib/bundler/source/git/git_proxy.rb
+++ b/lib/bundler/source/git/git_proxy.rb
@@ -28,8 +28,9 @@ module Bundler
def initialize(command, path, extra_info = nil)
@command = command
- msg = String.new
- msg << "Git error: command `#{command}` in directory #{path} has failed."
+ msg = String.new("Git error: command `#{command}`")
+ msg << " in directory #{path}" if path
+ msg << " has failed."
msg << "\n#{extra_info}" if extra_info
super msg
end
@@ -153,9 +154,20 @@ module Bundler
SharedHelpers.filesystem_access(path.dirname) do |p|
FileUtils.mkdir_p(p)
end
- git_retry "clone", "--bare", "--no-hardlinks", "--quiet", *extra_clone_args, "--", configured_uri, path.to_s
- extra_ref
+ command = ["clone", "--bare", "--no-hardlinks", "--quiet", *extra_clone_args, "--", configured_uri, path.to_s]
+ command_with_no_credentials = check_allowed(command)
+
+ Bundler::Retry.new("`#{command_with_no_credentials}`", [MissingGitRevisionError]).attempts do
+ _, err, status = capture(command, nil)
+ return extra_ref if status.success?
+
+ if err.include?("Could not find remote branch")
+ raise MissingGitRevisionError.new(command_with_no_credentials, nil, explicit_ref, credential_filtered_uri)
+ else
+ raise GitCommandError.new(command_with_no_credentials, path, err)
+ end
+ end
end
def clone_needs_unshallow?