Merge pull request #11328 from cnnrmnn/stop-shallow-cloning
Stop using shallow clones
This commit is contained in:
commit
d49aa0580d
@ -776,18 +776,10 @@ end
|
|||||||
#
|
#
|
||||||
# @api public
|
# @api public
|
||||||
class GitDownloadStrategy < VCSDownloadStrategy
|
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)
|
def initialize(url, name, version, **meta)
|
||||||
super
|
super
|
||||||
@ref_type ||= :branch
|
@ref_type ||= :branch
|
||||||
@ref ||= "master"
|
@ref ||= "master"
|
||||||
@shallow = meta.fetch(:shallow, true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# @see AbstractDownloadStrategy#source_modified_time
|
# @see AbstractDownloadStrategy#source_modified_time
|
||||||
@ -827,18 +819,10 @@ class GitDownloadStrategy < VCSDownloadStrategy
|
|||||||
update_submodules(timeout: timeout) if submodules?
|
update_submodules(timeout: timeout) if submodules?
|
||||||
end
|
end
|
||||||
|
|
||||||
def shallow_clone?
|
|
||||||
@shallow && support_depth?
|
|
||||||
end
|
|
||||||
|
|
||||||
def shallow_dir?
|
def shallow_dir?
|
||||||
(git_dir/"shallow").exist?
|
(git_dir/"shallow").exist?
|
||||||
end
|
end
|
||||||
|
|
||||||
def support_depth?
|
|
||||||
@ref_type != :revision && SHALLOW_CLONE_ALLOWLIST.any? { |regex| @url =~ regex }
|
|
||||||
end
|
|
||||||
|
|
||||||
def git_dir
|
def git_dir
|
||||||
cached_location/".git"
|
cached_location/".git"
|
||||||
end
|
end
|
||||||
@ -865,7 +849,6 @@ class GitDownloadStrategy < VCSDownloadStrategy
|
|||||||
sig { returns(T::Array[String]) }
|
sig { returns(T::Array[String]) }
|
||||||
def clone_args
|
def clone_args
|
||||||
args = %w[clone]
|
args = %w[clone]
|
||||||
args << "--depth" << "1" if shallow_clone?
|
|
||||||
|
|
||||||
case @ref_type
|
case @ref_type
|
||||||
when :branch, :tag
|
when :branch, :tag
|
||||||
@ -902,7 +885,8 @@ class GitDownloadStrategy < VCSDownloadStrategy
|
|||||||
def update_repo(timeout: nil)
|
def update_repo(timeout: nil)
|
||||||
return if @ref_type != :branch && ref?
|
return if @ref_type != :branch && ref?
|
||||||
|
|
||||||
if !shallow_clone? && shallow_dir?
|
# Convert any shallow clone to full clone
|
||||||
|
if shallow_dir?
|
||||||
command! "git",
|
command! "git",
|
||||||
args: ["fetch", "origin", "--unshallow"],
|
args: ["fetch", "origin", "--unshallow"],
|
||||||
chdir: cached_location,
|
chdir: cached_location,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user