diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index faf3bb135a905..92c8faff3162a 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -776,18 +776,10 @@ def clone_repo(timeout: nil) # # @api public class GitDownloadStrategy < VCSDownloadStrategy - SHALLOW_CLONE_ALLOWLIST = [ - %r{git://}, - %r{https://github\.com}, - %r{http://git\.sv\.gnu\.org}, - %r{http://llvm\.org}, - ].freeze - def initialize(url, name, version, **meta) super @ref_type ||= :branch @ref ||= "master" - @shallow = meta.fetch(:shallow, true) end # @see AbstractDownloadStrategy#source_modified_time @@ -827,18 +819,10 @@ def update(timeout: nil) update_submodules(timeout: timeout) if submodules? end - def shallow_clone? - @shallow && support_depth? - end - def shallow_dir? (git_dir/"shallow").exist? end - def support_depth? - @ref_type != :revision && SHALLOW_CLONE_ALLOWLIST.any? { |regex| @url =~ regex } - end - def git_dir cached_location/".git" end @@ -865,7 +849,6 @@ def submodules? sig { returns(T::Array[String]) } def clone_args args = %w[clone] - args << "--depth" << "1" if shallow_clone? case @ref_type when :branch, :tag @@ -902,7 +885,8 @@ def config_repo def update_repo(timeout: nil) return if @ref_type != :branch && ref? - if !shallow_clone? && shallow_dir? + # Convert any shallow clone to full clone + if shallow_dir? command! "git", args: ["fetch", "origin", "--unshallow"], chdir: cached_location,