Merge pull request #13791 from Bo98/resource-frozen-version
resource: determine version before freezing
This commit is contained in:
commit
08c597d563
@ -239,13 +239,13 @@ class Resource
|
|||||||
@download_strategy = DownloadStrategyDetector.detect(url, using)
|
@download_strategy = DownloadStrategyDetector.detect(url, using)
|
||||||
@specs.merge!(specs)
|
@specs.merge!(specs)
|
||||||
@downloader = nil
|
@downloader = nil
|
||||||
|
@version = detect_version(@version)
|
||||||
end
|
end
|
||||||
|
|
||||||
def version(val = nil)
|
def version(val = nil)
|
||||||
@version ||= begin
|
return @version if val.nil?
|
||||||
version = detect_version(val)
|
|
||||||
version.null? ? nil : version
|
@version = detect_version(val)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def mirror(val)
|
def mirror(val)
|
||||||
@ -266,15 +266,15 @@ class Resource
|
|||||||
private
|
private
|
||||||
|
|
||||||
def detect_version(val)
|
def detect_version(val)
|
||||||
return Version::NULL if val.nil? && url.nil?
|
version = case val
|
||||||
|
when nil then url.nil? ? Version::NULL : Version.detect(url, **specs)
|
||||||
case val
|
|
||||||
when nil then Version.detect(url, **specs)
|
|
||||||
when String then Version.create(val)
|
when String then Version.create(val)
|
||||||
when Version then val
|
when Version then val
|
||||||
else
|
else
|
||||||
raise TypeError, "version '#{val.inspect}' should be a string"
|
raise TypeError, "version '#{val.inspect}' should be a string"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
version.null? ? nil : version
|
||||||
end
|
end
|
||||||
|
|
||||||
# A resource containing a Go package.
|
# A resource containing a Go package.
|
||||||
|
|||||||
@ -354,7 +354,7 @@ class Bottle
|
|||||||
@cellar = tag_spec.cellar
|
@cellar = tag_spec.cellar
|
||||||
@rebuild = spec.rebuild
|
@rebuild = spec.rebuild
|
||||||
|
|
||||||
@resource.version = formula.pkg_version
|
@resource.version = formula.pkg_version.to_s
|
||||||
@resource.checksum = tag_spec.checksum
|
@resource.checksum = tag_spec.checksum
|
||||||
|
|
||||||
@fetch_tab_retried = false
|
@fetch_tab_retried = false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user