Skip to content

Commit

Permalink
Merge pull request #16122 from EricFromCanada/caching-brewed-curl-deps
Browse files Browse the repository at this point in the history
dependency_collector: fix caching of deps requiring brewed curl
  • Loading branch information
EricFromCanada committed Oct 21, 2023
2 parents ee9766a + 4b33460 commit 55335e7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Library/Homebrew/dependency_collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def freeze

def add(spec)
case dep = fetch(spec)
when Array
dep.compact.each { |dep| @deps << dep }
when Dependency
@deps << dep
when Requirement
Expand All @@ -63,11 +65,14 @@ def fetch(spec)
end

def cache_key(spec)
if spec.is_a?(Resource) && spec.download_strategy <= CurlDownloadStrategy
File.extname(spec.url)
else
spec
if spec.is_a?(Resource)
if spec.download_strategy <= CurlDownloadStrategy
return "#{spec.download_strategy}#{File.extname(spec.url).split("?").first}"
end

return spec.download_strategy
end
spec
end

def build(spec)
Expand Down Expand Up @@ -128,7 +133,7 @@ def init_global_dep_tree_if_needed!; end

sig {
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)
raise ArgumentError, "Implicit dependencies cannot be manually specified" if tags.include?(:implicit)
Expand Down Expand Up @@ -177,8 +182,7 @@ def resource_dep(spec, tags)
strategy = spec.download_strategy

if strategy <= HomebrewCurlDownloadStrategy
@deps << curl_dep_if_needed(tags)
parse_url_spec(spec.url, tags)
[curl_dep_if_needed(tags), parse_url_spec(spec.url, tags)]
elsif strategy <= NoUnzipCurlDownloadStrategy
# ensure NoUnzip never adds any dependencies
elsif strategy <= CurlDownloadStrategy
Expand Down

0 comments on commit 55335e7

Please sign in to comment.