Merge pull request #13791 from Bo98/resource-frozen-version

resource: determine version before freezing
This commit is contained in:
Bo Anderson 2022-09-01 19:16:56 +01:00 committed by GitHub
commit 08c597d563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View File

@ -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.

View File

@ -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