mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
GitDownloadStrategy: allow disabling of shallow clone
Closes Homebrew/homebrew#25751. Closes Homebrew/homebrew#26730.
This commit is contained in:
parent
5ce4c2a3f8
commit
7eec2d8b5a
@ -474,6 +474,11 @@ class GitDownloadStrategy < VCSDownloadStrategy
|
|||||||
%r{http://llvm\.org},
|
%r{http://llvm\.org},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def initialize name, resources
|
||||||
|
super
|
||||||
|
@shallow = resource.specs.fetch(:shallow) { true }
|
||||||
|
end
|
||||||
|
|
||||||
def cache_tag; "git" end
|
def cache_tag; "git" end
|
||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
@ -513,6 +518,10 @@ class GitDownloadStrategy < VCSDownloadStrategy
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def shallow_clone?
|
||||||
|
@shallow && support_depth?
|
||||||
|
end
|
||||||
|
|
||||||
def support_depth?
|
def support_depth?
|
||||||
@ref_type != :revision && SHALLOW_CLONE_WHITELIST.any? { |rx| rx === @url }
|
@ref_type != :revision && SHALLOW_CLONE_WHITELIST.any? { |rx| rx === @url }
|
||||||
end
|
end
|
||||||
@ -535,7 +544,7 @@ class GitDownloadStrategy < VCSDownloadStrategy
|
|||||||
|
|
||||||
def clone_args
|
def clone_args
|
||||||
args = %w{clone}
|
args = %w{clone}
|
||||||
args << '--depth' << '1' if support_depth?
|
args << '--depth' << '1' if shallow_clone?
|
||||||
|
|
||||||
case @ref_type
|
case @ref_type
|
||||||
when :branch, :tag then args << '--branch' << @ref
|
when :branch, :tag then args << '--branch' << @ref
|
||||||
|
Loading…
x
Reference in New Issue
Block a user