-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generate-cask-api: fall back to previous URL if network fails #18390
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks @Rylan12! A few suggested style tweaks; optional and non-blocking.
prev_url = json_cask["url"] | ||
prev_specs = json_cask["url_specs"] || {} | ||
url = Cask::URL.new(prev_url, **prev_specs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prev_url = json_cask["url"] | |
prev_specs = json_cask["url_specs"] || {} | |
url = Cask::URL.new(prev_url, **prev_specs) | |
previous_url = json_cask["url"] | |
previous_specs = json_cask["url_specs"] || {} | |
url = Cask::URL.new(previous_url, **previous_specs) |
url.to_s | ||
rescue | ||
raise unless self.class.generating_hash? | ||
raise unless (json_cask = Homebrew::API::Cask.all_casks[token]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise unless (json_cask = Homebrew::API::Cask.all_casks[token]) | |
json_cask = Homebrew::API::Cask.all_casks.fetch(token).presence | |
raise unless json_cask |
This is OK but IMO we should ban There are only 4 casks that use it so feels weird to have workarounds for such a small number. I think it wouldn't be too unreasonable to try update them to not use |
I agree. Note that #18388 will be landing soon so now is a good change to get any deprecations straight into
This workaround feels good for unflaking things sooner rather than later, agreed it'd be nicer to remove the need for it soon though. |
Makes sense to me. What was the strategy we used for the casks that needed it before? |
Either:
For stable versions, usually one of the above exists so that "download" buttons on webpages work. For nightlies etc, this sometimes didn't work because they were usually well hidden and for experienced users only. Not sure if that applies to any of the remaining 4 or not. |
This would be for the formulae.brew.sh generation which happens every 15 minutes
I'll look and see what I can find
Yes, all of these are nightly or nightly-adjacent:
|
I mean instead of making the cask determine the URL dynamically: we should have livecheck do it so that it opens PRs with checksums that are reviewed properly. It's the more secure option if possible. |
I opened a PR to remove these from homebrew/cask: Homebrew/homebrew-cask#186501 I'll work on adding a rubocop to make sure we don't use any of these in official taps anymore. |
If casks have a
url
stanza with a block (liketransmission@nightly
),brew generate-cask-api
needs to go to that URL in order to determine the correct download URL for the cask. It's very common for this to fail when generating the API (especially withtransmission@nightly
), so this PR adds a fallback mechanism. Ifgenerate-cask-api
is unable to reach the URL specified in the block, it will simply fall back to whatever URL value existed previously in the API. This should hopefully reduce the number of generation failures we see in Homebrew/formulae.brew.sh.