cmd/fetch: handle nil cask urls

These urls can be nil if there is an unsatisfied macos version
requirement. We check for false here because either the macos
requirement can be satisfied and return true or can not be
specified and return nil. If it's not specified, it means it
can run on any macos version.

The change in Cask::Download should provide better error messages
in Downloadable but honestly we're better off just checking for
the missing url higher up the call stack which is why I made
the changes in the fetch command. Either way it seemed like
a good idea while I'm here.
This commit is contained in:
apainintheneck 2023-09-02 01:33:39 -07:00
parent 51387287f7
commit 8c2f101138
2 changed files with 7 additions and 0 deletions

View File

@ -24,6 +24,8 @@ module Cask
sig { override.returns(T.nilable(::URL)) } sig { override.returns(T.nilable(::URL)) }
def url def url
return if cask.url.nil?
@url ||= ::URL.new(cask.url.to_s, cask.url.specs) @url ||= ::URL.new(cask.url.to_s, cask.url.specs)
end end

View File

@ -167,6 +167,11 @@ module Homebrew
SimulateSystem.with os: os, arch: arch do SimulateSystem.with os: os, arch: arch do
cask = Cask::CaskLoader.load(ref) cask = Cask::CaskLoader.load(ref)
if cask.depends_on.macos&.satisfied? == false
opoo "#{cask.token}: #{cask.depends_on.macos.message(type: :cask)}"
next
end
quarantine = args.quarantine? quarantine = args.quarantine?
quarantine = true if quarantine.nil? quarantine = true if quarantine.nil?