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
PageMatch#find_versions: Fix return conditions #11888
PageMatch#find_versions: Fix return conditions #11888
Conversation
Review period skipped due to |
Going to go ahead and merge this, as it’s a simple change that fixes a bug. |
Thanks for the fix @samford! This also caused issues with some livechecks in custom taps for us too, which were using a workaround for auth: livecheck do
url 'https://example.com'
strategy :page_match do
# This is a workaround for not being able to provide the header to curl in the :page_match
# fetch itself.
content = curl_with_workarounds('--header',
"Authorization: Bearer #{CustomDownloadStrategy.get_auth_token(@url)}",
@url).stdout
JSON.parse(content)['releases']
.select { |release| release['latest'] == true }
.map { |release| release['version'] }
end
end |
Also worth noting that there's a block in the docs here that doesn't use the regex option: https://docs.brew.sh/Brew-Livecheck#pagematch-strategy-block livecheck do
url :homepage
strategy :page_match do |page|
page.scan(/href=.*?example[._-]v?(\d{4}-\d{2}-\d{2})\.t/i)
.map { |match| match&.first&.gsub(/\D/, "") }
end
end so if the regex argument to the block is preferred, might be worth updating that too. |
This particular setup will be better supported by forthcoming features in the near future ( I recently took a detour to do a bit of cleanup and refactoring of strategies (to support continuing development) and I'm hoping to get a PR for the Regarding the
There's some history here but the short version is that the documentation is incorrect (in my view) and there are some things that I need to get done before creating a PR to fix it. The example The current documentation's "inline" approach came about because a homebrew/cask maintainer didn't know that you could pass the regex into the Later, they created a PR to modify the documentation to use inline regexes in I've always planned to open a PR to revert the A majority of related cask With the technical issues resolved, I plan to create some bulk PRs to update the ~400 existing cask |
Exciting news about the Thanks for the diligence in making this part of homebrew easier to use! Also very helpful to update the core/cask repos, as people (or at least me 😁 ) tend to grep them for examples when writing tap formulae. |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Casks with a
livecheck
block usingPageMatch
but not using#regex
are currently failing (see #11882) because I recently introduced code inPageMatch#find_versions
that returns early when a regex isn't provided. I had tested this change on homebrew/core, where all the relatedstrategy
blocks use#regex
and pass it into thestrategy
block (i.e.,do |page, regex|
), but I didn't test it on homebrew/cask.This PR fixes the issue by updating the condition to require either a regex or
strategy
block. I'll create a follow-up PR to add a related test and maybe modifyPageMatch#find_versions
's parameters (makingregex
nilable again) but I wanted to push out this fix in the interim time.