-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
livecheck: allow custom url in extract_plist strategy #13346
Conversation
Review period will end on 2022-05-31 at 06:46:29 UTC. |
c8e6004
to
7b85717
Compare
I'm getting a typecheck error, I'd appreciate some direction on how to get it sorted.
|
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.
In general, the idea behind this PR makes sense to me. Checking a versioned url
with ExtractPlist
would be a waste of effort (as it would simply give the current version
) and, as you mentioned, it's necessary to check an unversioned url
in cases like speedify
to identify the latest version 👍
I'm getting a typecheck error, I'd appreciate some direction on how to get it sorted.
brew typecheck livecheck/strategy/extract_plist.rb:104: Method url does not exist on T.class_of(Homebrew::Livecheck::Strategy::ExtractPlist) https://srb.help/7003 104 | url url.to_s ^^^
I tinkered with this and the only way I found to avoid the typecheck error was to use Cask::CaskLoader.load
with a string, like we do in tests (e.g., livecheck/livecheck_spec.rb
). For example, the existing code would be like this:
Cask::CaskLoader.load(+<<-RUBY, config: cask.config)
cask "livecheck-url-cask" do
url "#{url}"
end
RUBY
That said, we can simplify this and avoid the UnversionedCaskChecker
changes if we can create a copy of the cask with a substitute url
(instead of passing in a supplementary livecheck_url
cask to use for UnversionedCaskChecker#installer
). It would be ideal if we could simply replace the underlying cask.url
URL::DSL
object but Cask::DSL#set_unique_stanza
won't allow this (e.g., cask.url { url }
produces a Cask::CaskInvalidError (Cask 'speedify' definition is invalid: 'url' stanza may only appear once.)
error).
However, if there aren't any objections to using #instance_variable_set
in this context, we can sidestep the issue by directly replacing the @url
instance variable (in the Cask::DSL
object). I've added a suggestion below that demonstrates this approach but it shouldn't be committed unless/until the approach is approved.
Review period ended. |
In the interest of merging this, I rebased the branch and pushed a couple commits. The first commit adds a missing documentation comment and adds |
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.
Need new API for this.
`ExtractPlist` doesn't require a URL like other strategies (it takes a `Cask` instead) but we've had to provide one in existing `livecheck` blocks to get past this requirement in livecheck. This commit makes it so this requirement is only enforced when a strategy's `#find_versions` method has a required `url` parameter (not an optional one, as in `ExtractPlist`).
I've rebased this and incorporated the previously-discussed Past that, I added a commit to ensure that livecheck only requires a URL when a [Regarding disabling the |
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.
Looks great, nice work @samford!
Thanks, everyone! |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?This allows a custom url to be passed to livecheck when using the
:extract_plist
strategy.This is useful in edge cases that meet a couple of criteria:
At the moment in these cases we are limited to using the unversioned url OR using the versioned url and skipping the livecheck.
An example of a cask that is currently not functioning as intended is the
speedify
cask.