From 6219cd0a9279989caf56eb1f6c530c69ae5dd713 Mon Sep 17 00:00:00 2001 From: Harry Marr Date: Sun, 12 Jun 2022 10:48:47 -0400 Subject: [PATCH] Use different cache tag for sparse checkouts --- Library/Homebrew/download_strategy.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index b062ca362f..3d917eb7f6 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -811,10 +811,13 @@ end # @api public class GitDownloadStrategy < VCSDownloadStrategy def initialize(url, name, version, **meta) + # Needs to be before the call to `super`, as the VCSDownloadStrategy's + # constructor calls `cache_tag` and sets the cache path. + @only_paths = meta[:only_paths] + super @ref_type ||= :branch @ref ||= "master" - @only_paths = meta[:only_paths] end # @see AbstractDownloadStrategy#source_modified_time @@ -837,7 +840,11 @@ class GitDownloadStrategy < VCSDownloadStrategy sig { returns(String) } def cache_tag - "git" + if partial_clone_sparse_checkout? + "git-sparse" + else + "git" + end end sig { returns(Integer) }