Wrap guess_cask_version with timeout.

This commit is contained in:
Markus Reiter 2020-12-11 02:21:20 +01:00
parent 06c60b9892
commit a428aa6617

View File

@ -126,30 +126,40 @@ module Homebrew
onoe e onoe e
end end
if sha256.present? && last_sha256 != sha256 && (version = unversioned_cask_checker.guess_cask_version) if sha256.present? && last_sha256 != sha256
if cask.version == version version = begin
oh1 "Cask #{cask} is up-to-date at #{version}" Timeout.timeout(1.minute) do
else unversioned_cask_checker.guess_cask_version
bump_cask_pr_args = [
"bump-cask-pr",
"--version", version.to_s,
"--sha256", ":no_check",
"--message", "Automatic update via `brew bump-unversioned-casks`.",
cask.sourcefile_path
]
if dry_run
bump_cask_pr_args << "--dry-run"
oh1 "Would bump #{cask} from #{cask.version} to #{version}"
else
oh1 "Bumping #{cask} from #{cask.version} to #{version}"
end end
rescue Timeout::Error
onoe "Timed out guessing version for cask '#{cask}'."
end
begin if version
system_command! HOMEBREW_BREW_FILE, args: bump_cask_pr_args if cask.version == version
rescue ErrorDuringExecution => e oh1 "Cask #{cask} is up-to-date at #{version}"
onoe e else
return bump_cask_pr_args = [
"bump-cask-pr",
"--version", version.to_s,
"--sha256", ":no_check",
"--message", "Automatic update via `brew bump-unversioned-casks`.",
cask.sourcefile_path
]
if dry_run
bump_cask_pr_args << "--dry-run"
oh1 "Would bump #{cask} from #{cask.version} to #{version}"
else
oh1 "Bumping #{cask} from #{cask.version} to #{version}"
end
begin
system_command! HOMEBREW_BREW_FILE, args: bump_cask_pr_args
rescue ErrorDuringExecution => e
onoe e
return
end
end end
end end
end end