Merge pull request #16122 from EricFromCanada/caching-brewed-curl-deps

dependency_collector: fix caching of deps requiring brewed curl
This commit is contained in:
Eric Knibbe 2023-10-20 23:25:45 -04:00 committed by GitHub
commit 55335e70e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,6 +45,8 @@ class DependencyCollector
def add(spec) def add(spec)
case dep = fetch(spec) case dep = fetch(spec)
when Array
dep.compact.each { |dep| @deps << dep }
when Dependency when Dependency
@deps << dep @deps << dep
when Requirement when Requirement
@ -63,11 +65,14 @@ class DependencyCollector
end end
def cache_key(spec) def cache_key(spec)
if spec.is_a?(Resource) && spec.download_strategy <= CurlDownloadStrategy if spec.is_a?(Resource)
File.extname(spec.url) if spec.download_strategy <= CurlDownloadStrategy
else return "#{spec.download_strategy}#{File.extname(spec.url).split("?").first}"
spec end
return spec.download_strategy
end end
spec
end end
def build(spec) def build(spec)
@ -128,7 +133,7 @@ class DependencyCollector
sig { sig {
params(spec: T.any(String, Resource, Symbol, Requirement, Dependency, Class), params(spec: T.any(String, Resource, Symbol, Requirement, Dependency, Class),
tags: T::Array[Symbol]).returns(T.any(Dependency, Requirement, NilClass)) tags: T::Array[Symbol]).returns(T.any(Dependency, Requirement, Array, NilClass))
} }
def parse_spec(spec, tags) def parse_spec(spec, tags)
raise ArgumentError, "Implicit dependencies cannot be manually specified" if tags.include?(:implicit) raise ArgumentError, "Implicit dependencies cannot be manually specified" if tags.include?(:implicit)
@ -177,8 +182,7 @@ class DependencyCollector
strategy = spec.download_strategy strategy = spec.download_strategy
if strategy <= HomebrewCurlDownloadStrategy if strategy <= HomebrewCurlDownloadStrategy
@deps << curl_dep_if_needed(tags) [curl_dep_if_needed(tags), parse_url_spec(spec.url, tags)]
parse_url_spec(spec.url, tags)
elsif strategy <= NoUnzipCurlDownloadStrategy elsif strategy <= NoUnzipCurlDownloadStrategy
# ensure NoUnzip never adds any dependencies # ensure NoUnzip never adds any dependencies
elsif strategy <= CurlDownloadStrategy elsif strategy <= CurlDownloadStrategy