From 911aa6ab186c5c871b89f22a75ef67178021a79f Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Thu, 1 Sep 2022 18:25:26 +0100 Subject: [PATCH 1/2] resource: determine version before freezing --- Library/Homebrew/resource.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/resource.rb b/Library/Homebrew/resource.rb index a8c98590c2..278b7a2f2d 100644 --- a/Library/Homebrew/resource.rb +++ b/Library/Homebrew/resource.rb @@ -239,13 +239,13 @@ class Resource @download_strategy = DownloadStrategyDetector.detect(url, using) @specs.merge!(specs) @downloader = nil + @version = detect_version(@version) end def version(val = nil) - @version ||= begin - version = detect_version(val) - version.null? ? nil : version - end + return @version if val.nil? + + @version = detect_version(val) end def mirror(val) @@ -266,15 +266,15 @@ class Resource private def detect_version(val) - return Version::NULL if val.nil? && url.nil? - - case val - when nil then Version.detect(url, **specs) + version = case val + when nil then url.nil? ? Version::NULL : Version.detect(url, **specs) when String then Version.create(val) when Version then val else raise TypeError, "version '#{val.inspect}' should be a string" end + + version.null? ? nil : version end # A resource containing a Go package. From 6c4245e29830c73a9fda66235668227bbd0692d6 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Thu, 1 Sep 2022 18:47:38 +0100 Subject: [PATCH 2/2] software_spec: fix bottle resource version type --- Library/Homebrew/software_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index e51f2fd275..29d1abfc54 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -354,7 +354,7 @@ class Bottle @cellar = tag_spec.cellar @rebuild = spec.rebuild - @resource.version = formula.pkg_version + @resource.version = formula.pkg_version.to_s @resource.checksum = tag_spec.checksum @fetch_tab_retried = false