Cask::Audit: fix key not found: :latest
error
`Cask::Audit.audit_livecheck_version` can raise a `key not found: :latest` error when a hash from livecheck's `latest_version` method doesn't have a `:latest` value. This error means that livecheck was unable to identify the latest upstream version but it can only be understood if the reader knows how this audit is implemented (and it may also depend on knowing the structure of livecheck's `latest_version` hash). Without that knowledge, the error doesn't make it clear which audit is failing and why. This addresses the issue by using `nil` as the default value for this `fetch` call and accounting for a `nil` `latest_version` value. This allows the audit to surface the usual "Version '1.2.3' differs from '' retrieved by livecheck" failure, which makes it more clear that livecheck isn't returning a version.
This commit is contained in:
parent
4343324468
commit
dce220e518
@ -755,9 +755,9 @@ module Cask
|
|||||||
latest_version = Homebrew::Livecheck.latest_version(
|
latest_version = Homebrew::Livecheck.latest_version(
|
||||||
cask,
|
cask,
|
||||||
referenced_formula_or_cask: referenced_cask,
|
referenced_formula_or_cask: referenced_cask,
|
||||||
)&.fetch(:latest)
|
)&.fetch(:latest, nil)
|
||||||
|
|
||||||
return :auto_detected if cask.version.to_s == latest_version.to_s
|
return :auto_detected if latest_version && (cask.version.to_s == latest_version.to_s)
|
||||||
|
|
||||||
add_error "Version '#{cask.version}' differs from '#{latest_version}' retrieved by livecheck."
|
add_error "Version '#{cask.version}' differs from '#{latest_version}' retrieved by livecheck."
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user