Check only_path is present before modifying it

This commit is contained in:
Harry Marr 2023-06-10 14:31:46 -04:00
parent 747d3aaaba
commit d2b17e29ef
No known key found for this signature in database
GPG Key ID: EC359447F66859CC

View File

@ -835,9 +835,11 @@ class GitDownloadStrategy < VCSDownloadStrategy
# constructor calls `cache_tag` and sets the cache path.
@only_path = meta[:only_path]
# "Cone" mode of sparse checkout requires patterns to be directories
@only_path = "/#{@only_path}" unless @only_path.start_with?("/")
@only_path = "#{@only_path}/" unless @only_path.end_with?("/")
if @only_path.present?
# "Cone" mode of sparse checkout requires patterns to be directories
@only_path = "/#{@only_path}" unless @only_path.start_with?("/")
@only_path = "#{@only_path}/" unless @only_path.end_with?("/")
end
super
@ref_type ||= :branch