435 Commits

Author SHA1 Message Date
Patrick Linnane
c56669e9cd
various: fix miscellaneous typos 2023-07-18 08:52:49 -07:00
Bo Anderson
54a1f2005a
livecheck: fix implicit no-api handling 2023-07-10 14:50:53 +01:00
Sam Ford
ba7cf9df7a
Bitbucket: Fix tag match
The `Bitbucket` strategy currently matches versions from tag
tarball links on a project's `downloads/?tab=tags` page. It appears
that Bitbucket now uses a hash as the filename on this page instead
of the tag name, so the existing regex no longer matches.

This adds an alternative regex to match versions from the tag name
element (e.g., `<td class="name">example-1.2.3</td>`), which will fix
version matching in this scenario.
2023-05-19 10:55:28 -04:00
Sam Ford
104d30d231
Finish renaming GithubRelease to GithubReleases 2023-05-16 16:08:18 -04:00
Sean Molenaar
940b63cad3
chore: rename GitHubRelease to GitHubReleases 2023-05-16 14:19:01 -04:00
Sam Ford
a2fb2b00fd
GithubRelease: Simplify block handling
The `#versions_from_content` method requires a regex and this will be
enforced by the type signature, so we don't have to check for the
presence of a regex when handling a `strategy` block.
2023-05-16 14:18:23 -04:00
Sam Ford
263f486806
GithubRelease: Add #generate_input_values method
Keeping the logic for generating the API URL in a method makes it
testable, aligns with other strategies, and will help to enable some
future work.
2023-05-16 14:18:23 -04:00
Sam Ford
701f7c5051
GithubRelease: Update type signature 2023-05-16 14:18:23 -04:00
Sam Ford
8a0f63e728
GithubRelease: Omit unnecessary prefix 2023-05-16 14:18:22 -04:00
Sam Ford
a29b5c34d2
GithubRelease: Rework documentation comments
The initial documentation comments contained some remaining text
referring to `GithubLatest` and hadn't been updated to incorporate
the recent changes to the aforementioned strategy. This also reworks
some of the language to better explain the strategy's function,
application, etc.
2023-05-16 14:18:22 -04:00
Sam Ford
1dd7556c74
GithubLatest: Tweak documentation comments 2023-05-16 14:18:22 -04:00
Sean Molenaar
5139b9b468
feat: add github_release strategy 2023-05-16 14:18:22 -04:00
Sam Ford
bcddf99838
Strategy: Pass --max-redirs to #curl_headers
The default curl args in `#curl_headers` cover most of
`Livecheck::Strategy::DEFAULT_CURL_ARGS` but `--max-redirs` was
overlooked. This adds an explicit `--max-redirs` argument in
the `#page_headers` `#curl_headers` call but it's worth mentioning
that this approach wouldn't benefit from any changes in
`DEFAULT_CURL_ARGS` and would need to be manually kept in parity.
2023-05-15 13:14:13 -04:00
Markus Reiter
f7168bf234
Merge pull request #15336 from reitermarkus/version-head-null
Merge `HeadVersion` and `NullVersion` into `Version`.
2023-05-10 01:01:21 +02:00
Markus Reiter
e493d0cb04
Rescue ErrorDuringExecution instead of changing curl_headers return type. 2023-05-09 07:25:00 +02:00
Markus Reiter
8274920217
Rename OS::Mac::Version to MacOSVersion. 2023-05-09 05:08:38 +02:00
Sam Ford
16f3a05e45
Strategy#page_headers: Update for #curl_headers
`#curl_headers` was recently introduced into `Strategy#page_headers`
but only the call was modified and the method wasn't updated to
correctly work with the new return value, so all `HeaderMatch` checks
immediately started failing with an error.

This commit includes changes that return `#page_headers` to a working
state. I've removed the `result.assert_success!` call because it
prevents a few checks from being retried with `GET` (`firefox-cn`,
`krisp`, `prepros`).
2023-05-08 23:08:05 -04:00
Markus Reiter
ff71668f0a
Fix type errors. 2023-05-09 01:13:55 +02:00
Markus Reiter
b05de929c6
Merge pull request #15351 from reitermarkus/livecheck-head
Use `curl_headers` and `curl_output` for `Livecheck` strategies.
2023-05-09 00:55:34 +02:00
Sam Ford
efccc5d4bb
GithubLatest: Update documentation 2023-05-08 17:21:19 +02:00
Sam Ford
303ac147a9
GithubLatest: Include URL in match_data
It's standard for the `match_data` to include the URL (e.g., as in
`PageMatch`). This uses the provided URL by default, switching to the
generated URL when available.
2023-05-07 10:21:48 +02:00
Sam Ford
cfba45fb56
GithubLatest: Use API URL as generated value
The generated URL should reflect what we're actually checking, which
is now the `/releases/latest` API URL.
2023-05-07 10:21:48 +02:00
Sam Ford
34e2779150
GithubLatest: Move #generate_input_values
`#generate_input_values` is called before `#versions_from_content`
(in `#find_versions`), so it makes sense to move it above the latter.
2023-05-07 10:21:48 +02:00
Sean Molenaar
573d87cdfa
feat: use API for GitHub latest release strategy 2023-05-07 10:21:48 +02:00
Markus Reiter
353818f508
Rename curl_head to curl_headers. 2023-05-06 03:41:35 +02:00
Markus Reiter
545a332fef
Use curl_head and curl_output for Livecheck strategies. 2023-05-06 03:40:09 +02:00
Sam Ford
a2e966c186
Xml: Move require outside of #parse_xml
Since we use `REXML::Document` in the type signature for `#parse_xml`,
we can encounter an `uninitialized constant
Homebrew::Livecheck::Strategy::Xml::REXML` error in strategies like
`Sparkle` that use `Xml#parse_xml` internally when the Sorbet runtime
is used. Moving the related require outside of the `#parse_xml` method
and into the `Xml` strategy proper resolves this issue.
2023-04-29 10:16:47 -04:00
Sam Ford
6597ee6fd3
Sparkle: Account for nil content value
`content` can be `nil` when a request doesn't succeed but
`#versions_from_content` expects a `String` value, so we need to
guard against a `nil` value like we do in other strategies.
2023-04-29 10:16:47 -04:00
Sam Ford
1c03018b6a
Launchpad: Use DEFAULT_REGEX as default regex arg
Using `DEFAULT_REGEX` as the default value of the `#find_versions`
`regex` parameter allows us to tighten the type.
2023-04-29 10:16:46 -04:00
Sam Ford
a28e1aa422
livecheck: Selectively pass args to #find_versions
The existing way of passing values to `#find_versions` methods in
strategies leads to type issues when the Sorbet runtime is enabled.
We've also recently talked about moving away from nilable args when
we can specify a default value but this doesn't work if we pass in a
`nil` value (like we're currently doing).

This commit aims to address both of those areas by better controlling
which arguments we're passing to `#find_versions`. This approach
naively handles `cask`/`url` arguments by special-casing
`ExtractPlist`.

However, we should be checking the strategy's `#find_versions`
method for a `cask` or `url` keyword parameter. The issue is that
`strategy.method(:find_versions).parameters` is returning
`[[:rest, :args], [:block, :blk]]` instead of the actual parameters
like `[[:keyreq, :url], [:key, :regex], [:keyrest, :unused],
[:block, :block]]`.
2023-04-29 10:16:45 -04:00
Douglas Eichelberger
08af78a2a5 brew style --fix 2023-04-25 09:26:24 -07:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Mike McQuaid
63d8de3600
brew style --fix 2023-04-07 19:10:22 +01:00
Douglas Eichelberger
47ffcd5cb7 Add types to block params 2023-04-04 22:42:27 -07:00
Douglas Eichelberger
f3a8241e69 Remove useless T.unsafe wrappers 2023-04-03 17:34:39 -07:00
Douglas Eichelberger
6397229f68 Enable types in extensions, etc. 2023-04-01 18:56:42 -07:00
Mike McQuaid
ec15acf7dc
Revert "Remove --request GET workaround for HEAD requests." 2023-03-31 09:07:02 +01:00
Markus Reiter
593c37de26
Merge pull request #15085 from reitermarkus/appcast
Deprecate `appcast`.
2023-03-31 00:13:08 +02:00
Markus Reiter
c876530eff
Remove --request GET workaround for HEAD requests. 2023-03-30 05:02:51 +02:00
Markus Reiter
bdd6523ce8
Deprecate appcast. 2023-03-30 03:29:06 +02:00
Douglas Eichelberger
544960b4fc Replace String#underscore with util 2023-03-07 10:13:38 -08:00
Sam Ford
f997557c3f
livecheck: Skip #preprocess_url for new strategies
I forgot to add the new `Json`, `Xml`, and `Yaml` strategies to the
list of strategies where `#preprocess_url` should be skipped and this
was causing issues for a user in their tap. This is unfortunately
another bug that wasn't surfaced when I tested all the related checks
in our first-party taps.
2023-03-05 10:05:06 -05:00
Mike McQuaid
066a8afe61
Merge pull request #14868 from samford/livecheck/add-yaml-strategy
livecheck: Add Yaml strategy
2023-03-04 00:06:11 +00:00
Sam Ford
74370fe604
ElectronBuilder: Update to use Yaml#find_versions
This updates `ElectronBuilder` to use `Yaml#find_versions`, as the
only code unique to that strategy is to restrict regex usage and
use default version-finding logic when a `strategy` block isn't
provided. This is similar to how we have various strategies that
use `PageMatch#find_versions` internally.

This allows us to remove `ElectronBuilder#versions_from_content`
entirely, along with the related tests. I've added support for
`provided_content` to `ElectronBuilder#find_versions` as a way of
adding tests and maintaining code coverage.
2023-03-02 16:23:32 -05:00
Sam Ford
33268e4fb0
livecheck: Add Yaml strategy
This adds a generic `Yaml` strategy to livecheck that requires a
`strategy` block to operate. The YAML-parsing code is taken from the
existing approach in the `ElectronBuilder` strategy.

We don't currently have any `strategy` blocks in first-party taps
that manually parse YAML. However, creating a generic `Yaml` strategy
allows us to simplify `ElectronBuilder` (and any future strategy
that works with YAML) while making it easy to create custom `Yaml`
`strategy` blocks in formulae/casks as needed.
2023-03-02 16:20:39 -05:00
Sam Ford
7f0a735828
Json: Fix a whitespace oversight in comment 2023-03-01 17:27:33 -05:00
Sam Ford
cebb951baf
Json: Add #parse_json method
This setup mimics the `#parse_xml` method that was implemented in the
`Xml` strategy. Isolating the parsing code means that other strategies
can take only what they need from `Json` (i.e., it's not required for
them to use `Json#find_versions`).
2023-03-01 17:27:33 -05:00
Sam Ford
7d9e1a50e8
livecheck: Add Xml strategy
This adds a generic `Xml` strategy to livecheck that requires a
`strategy` block to operate. The XML-parsing code is taken from the
existing approach in the `Sparkle` strategy. As such, `Sparkle` has
been updated to use the `Xml#parse_xml` method instead.

Unlike the `Json` strategy, we don't currently have any `strategy`
blocks in first-party taps that manually parse XML. However, we had a
user request support for something like this and I was already working
on an `Xml` strategy (as a way of extracting the XML-parsing code
from `Sparkle` into something general-purpose), so here we are.

Future strategies that parse simple XML data can potentially use the
`Xml#find_versions` method (similar to how we have strategies that
leverage `PageMatch#find_versions`) instead of having to implement
something bespoke like `Sparkle`.
2023-02-28 14:58:11 -05:00
Mike McQuaid
4986a1aa26
Merge pull request #14830 from samford/livecheck/rework-json-match
Strategy#from_url: Amend conditions for Json
2023-02-28 11:41:41 +00:00
Douglas Eichelberger
f9f73f3ef6 Tidy up 2023-02-27 21:42:47 -08:00