Use "cone" mode for sparse checkouts

This commit is contained in:
Harry Marr 2023-06-09 22:58:00 -04:00
parent ce96e0aafa
commit 2cd2076186
No known key found for this signature in database
GPG Key ID: EC359447F66859CC

View File

@ -1075,9 +1075,17 @@ class GitDownloadStrategy < VCSDownloadStrategy
command! "git",
args: ["config", "core.sparseCheckout", "true"],
chdir: cached_location
command! "git",
args: ["config", "core.sparseCheckoutCone", "true"],
chdir: cached_location
(git_dir/"info").mkpath
(git_dir/"info"/"sparse-checkout").atomic_write("#{@only_path}\n")
# "Cone" mode of sparse checkout requires patterns to be directories
path = @only_path
path = "/#{path}" unless path.start_with?("/")
path = "#{path}/" unless path.end_with?("/")
(git_dir/"info"/"sparse-checkout").atomic_write("#{path}\n")
end
end