bump-cask-pr: rescue CaskUnreadableError

The `replace_version_and_checksum` method handles a `CaskInvalidError`
when loading a cask (handling casks that aren't valid on Linux) but
we can sometimes still encounter an error when bumping a cask with
on_system blocks. For example, bumping `displaylink` will produce a
`Cask 'displaylink' is unreadable: undefined method 'csv' for nil`
error when `SimulateSystem` runs as Linux, as the cask interpolates
`version.csv.first` in a `license` string but `version` isn't set on
Linux.

This adds `Cask::CaskUnreadableError` to the `rescue` arguments,
which accounts for this particular situation (allowing `displaylink`
to be bumped like before).
This commit is contained in:
Sam Ford 2025-04-03 17:35:26 -04:00
parent 38410f5432
commit 612fec47f3
No known key found for this signature in database
GPG Key ID: 7AF5CBEE1DD6F76D

View File

@ -220,7 +220,7 @@ module Homebrew
# Handle the cask being invalid for specific os/arch combinations
old_cask = begin
Cask::CaskLoader.load(cask.sourcefile_path)
rescue Cask::CaskInvalidError
rescue Cask::CaskInvalidError, Cask::CaskUnreadableError
raise unless cask.on_system_blocks_exist?
end
next if old_cask.nil?