summaryrefslogtreecommitdiff
path: root/lib/bundler/source/git
diff options
context:
space:
mode:
authorHiroshi SHIBATA <[email protected]>2022-12-20 09:43:53 +0900
committerHiroshi SHIBATA <[email protected]>2022-12-20 13:15:02 +0900
commit18ba89093a0b214cd89f1567c037c239f094496d ()
treebb4e07c66cca5fd2da04da297e8c66fbf883fdad /lib/bundler/source/git
parentad1f61fe80dea7a1b1e8d27a4232d7b10b820960 (diff)
Merge RubyGems/Bundler master
Pick from https://.com/rubygems/rubygems/commit/ba3adad4d80038ffd7bea015da2f11d3e8a2ff82
Notes: Merged: https://.com/ruby/ruby/pull/6966
-rw-r--r--lib/bundler/source/git/git_proxy.rb65
1 files changed, 36 insertions, 29 deletions
@@ -31,7 +31,6 @@ module Bundler
msg = String.new
msg << "Git error: command `#{command}` in directory #{path} has failed."
msg << "\n#{extra_info}" if extra_info
- msg << "\nIf this error persists you could try removing the cache directory '#{path}'" if path.exist?
super msg
end
end
@@ -47,7 +46,7 @@ module Bundler
# All actions required by the Git source is encapsulated in this
# object.
class GitProxy
- attr_accessor :path, :uri, :branch, :tag, :ref
attr_writer :revision
def initialize(path, uri, options = {}, revision = nil, git = nil)
@@ -56,6 +55,7 @@ module Bundler
@branch = options["branch"]
@tag = options["tag"]
@ref = options["ref"]
@revision = revision
@git = git
end
@@ -94,9 +94,7 @@ module Bundler
unshallow_needed = clone_needs_unshallow?
return unless extra_fetch_needed || unshallow_needed
- fetch_args = unshallow_needed ? ["--unshallow"] : depth_args
-
- git_retry(*["fetch", "--force", "--quiet", "--no-tags", *fetch_args, "--", configured_uri, refspec].compact, :dir => path)
end
def copy_to(destination, submodules = false)
@@ -132,6 +130,22 @@ module Bundler
private
def clone_needs_extra_fetch?
return true if path.exist?
@@ -216,11 +230,7 @@ module Bundler
def git_null(*command, dir: nil)
check_allowed(command)
- out, status = SharedHelpers.with_clean_git_env do
- capture_and_ignore_stderr(*capture3_args_for(command, dir))
- end
-
- [URICredentialsFilter.credential_filtered_string(out, uri), status]
end
def git_retry(*command, dir: nil)
@@ -234,15 +244,13 @@ module Bundler
def git(*command, dir: nil)
command_with_no_credentials = check_allowed(command)
- out, status = SharedHelpers.with_clean_git_env do
- capture_and_filter_stderr(*capture3_args_for(command, dir))
- end
- filtered_out = URICredentialsFilter.credential_filtered_string(out, uri)
- raise GitCommandError.new(command_with_no_credentials, dir || SharedHelpers.pwd, filtered_out) unless status.success?
- filtered_out
end
def has_revision_cached?
@@ -254,10 +262,9 @@ module Bundler
end
def find_local_revision
- options_ref = branch || tag || ref
- return head_revision if options_ref.nil?
- find_revision_for(options_ref)
end
def head_revision
@@ -318,17 +325,17 @@ module Bundler
command_with_no_credentials
end
- def capture_and_filter_stderr(*cmd)
- require "open3"
- return_value, captured_err, status = Open3.capture3(*cmd)
- Bundler.ui.warn URICredentialsFilter.credential_filtered_string(captured_err, uri) unless captured_err.empty?
- [return_value, status]
- end
- def capture_and_ignore_stderr(*cmd)
- require "open3"
- return_value, _, status = Open3.capture3(*cmd)
- [return_value, status]
end
def capture3_args_for(cmd, dir)