416 Commits

Author SHA1 Message Date
Nanda H Krishna
4ff88385f8
brew typecheck --fix 2022-01-27 12:23:40 -05:00
Sam Ford
cb537eae52
Strategy: Add --silent flag to DEFAULT_CURL_ARGS
Currently, only `Livecheck::Strategy::PAGE_HEADERS_CURL_ARGS` uses
the `--silent` option and `PAGE_CONTENT_CURL_ARGS` does not (though
there's no intention behind this omission). However, the
`#page_content` method should also use the `--silent` flag, to
prevent progress bar text (`#=#=#`, etc.) from appearing in output.

This is an issue because the regex that's used to identify `curl`
error messages in `stderr` (`^curl:.+$/`) will fail if leading
progress bar text is present. This leads to an ambiguous "cURL
failed without a detectable error" message instead of the actual
error message(s) from `curl`.

This commit addresses the issue by adding `--silent` to
`Livecheck::Strategy::DEFAULT_CURL_ARGS`, which both
`PAGE_HEADERS_CURL_ARGS` and `PAGE_CONTENT_CURL_ARGS` inherit.
2022-01-10 11:59:07 -05:00
Rylan Polster
2e6b6ab3a2
Fix style 2021-12-24 21:15:21 -05:00
Sam Ford
bd4124c10f
Livecheck: Avoid duplicate URLs
Some formulae/casks contain duplicate checkable URLs or contain
URLs that become duplicates after `#preprocess_url` is used. With
the former, a formula's `stable` and `head` URLs can be the same if
they both use the Git repository. With the latter, a formula's
`homepage` and `stable` URLs are different but `#preprocess_url` can
return the same Git repository URL for each (which can also be
a duplicate of the `head` URL).

The `fabric-completion` formula is a worst case scenario, as it
contains both of these conditions but the repository has no tags.
By default, livecheck would needlessly check the repository three
times (i.e., no versions are found so livecheck tries the next URL,
which happens to be the same URL).

This commit avoids duplicate URLs in `#checkable_urls` and keeps
track of checked URLs in `#latest_version` to avoid a duplicate
caused by `#preprocess_url`. This should effectively resolve the
issue of checking the same URL more than once for a given
formula/cask. Checking the same URL only once across all the
formulae/casks in a given livecheck run will be handled in a later
commit (though I've done most of the groundwork already in previous
PRs).
2021-12-14 10:31:15 -05:00
EricFromCanada
ed3042c37a
livecheck: use brewed curl if called for by download URL 2021-11-28 12:57:24 -05:00
Sam Ford
f8ded0a435
PageMatch: Enforce requirements in #find_versions
This aligns `PageMatch` with how cask strategies handle requirements
in their `#find_versions` methods. This moves related logic from
`Livecheck#latest_version` into the `PageMatch` strategy, which feels
a bit more appropriate.
2021-11-20 00:39:00 -05:00
Sam Ford
085827f605
Handle variable strategy block arguments
There are times where a regex isn't needed in a `strategy` block and
these changes explicitly handle that situation.

This allows the Symbol Proc format used in some `Sparkle` `livecheck`
blocks (e.g., `strategy :sparkle, &:version`) to continue working
instead of failing with a "wrong number of arguments (given 1,
expected 0)" error. This error would occur because a Symbol Proc only
only expects one argument (e.g., an `Item`, not an `Item` and a
regex/nil).

There's an argument to be made for avoiding the Symbol Proc format
for `strategy` blocks but I haven't found a way of selectively
disabling the Style/SymbolProc cop only for a `strategy` DSL method
call. That is to say, if we don't use the Symbol Proc format, `brew
style` will give a "Pass &:version as an argument to strategy instead
of a block." offense.

Besides that, this also replaces the `block` type signatures in
livecheck strategies with `T.untyped`. Sorbet doesn't know how to
handle a `Proc` with a variable number of arguments and can't be
taught how (i.e., `T.any` with a `Proc` signature for each variation
doesn't work). The aforementioned changes cause Sorbet to complain
about there being both too many and too few arguments, so the only
way to win is not to play the game. Hopefully we can restore the
`block` type signatures in the future (if upstream resolves this
years-old issue) but `T.untyped` seems to be our only option for now.
2021-11-19 23:58:55 -05:00
Sam Ford
e73524b093
livecheck: Fix debug strategy info printing
The `ExtractPlist` strategy doesn't return certain values (e.g.,
`:url`), so it's necessary to also ensure these values are present
before printing related debug info. Without these changes, we end up
printing info for a blank value (e.g., "URL (strategy):").
2021-11-19 23:58:55 -05:00
Sam Ford
9e8900fb6e
Allow regex to be passed into all strategy blocks
This modifies cask-related livecheck strategies to allow passing a
regex into a `strategy` block, when appropriate. These strategies
were outliers that explicitly rejected a regex even if a `strategy`
block was used, forcing any regex to be inlined in the `strategy`
block (instead of being defined using `#regex`).

With these changes, all `strategy` blocks will be able to accept a
regex, further simplifying the mental model. This also helps to
better align the various `find_versions` and `versions_from_*`
methods across strategies.
2021-11-19 23:58:54 -05:00
Sam Ford
94bf67b5df
Merge pull request #12314 from samford/livecheck/apache-support-dlcdn-urls
Apache: Support additional mirror/backup URLs
2021-11-03 11:55:54 -04:00
Mike McQuaid
d43555dd75
brew style --fix 2021-11-02 11:16:10 +00:00
Sam Ford
a1277ee1b0
Apache: Support additional mirror/backup URLs 2021-11-01 15:58:04 -04:00
Sam Ford
8ce6059544
Gnu: Update generated URL to use HTTPS 2021-10-21 09:28:54 -04:00
Sam Ford
e709917cd5
Apache: Extend URL_MATCH_REGEX
Some Apache URLs use a `filename` query string parameter instead of
`path` and the `Apache` strategy isn't applied. The parameter value
is the same as `path` (i.e., a path to a file), so this updates the
strategy's `URL_MATCH_REGEX` to handle this URL format as well.
2021-10-20 10:52:49 -04:00
Bo Anderson
861dea9ada
Bump various type strictnesses 2021-09-11 01:00:23 +01:00
Sam Ford
f88966a8a5
Use curl options where appropriate 2021-09-07 14:13:19 -04:00
Sam Ford
d44979fa67
Curl#curl_args: Fix and refactor options 2021-09-07 14:13:17 -04:00
Sam Ford
6b66ec9e62
Strategy: Improve curl error message finding
The existing regex wasn't able to match errors like:
  curl: option --something: is unknown

Additionally, the existing approach wouldn't capture multi-line
errors, whereas this captures all the `curl:` lines from `stderr`.
2021-09-07 00:15:08 -04:00
Sam Ford
e65c9d02ab
PageMatch: Expand #find_versions tests 2021-08-19 16:07:53 -04:00
Sam Ford
b4adf2a42e
PageMatch#find_versions: Fix return conditions 2021-08-19 09:01:11 -04:00
Sam Ford
8940d198fe
Make tarball extension regex explicit 2021-08-17 19:15:07 -04:00
Sam Ford
26821301e7
livecheck: move url/regex generation into methods 2021-08-17 18:03:40 -04:00
Sam Ford
13b349b4ae
Refactor #find_versions parameters in strategies 2021-08-16 12:01:32 -04:00
Sam Ford
c59d5db631
Remove unnecessary require statements 2021-08-11 19:06:00 -04:00
Sam Ford
c936a9420e
Improve documentation comments 2021-08-11 19:05:59 -04:00
Sam Ford
f2bd39ccef
Add additional method signatures to strategies 2021-08-11 19:05:59 -04:00
Sam Ford
56dd89114d
Standardize valid strategy block return types
Valid `strategy` block return types currently vary between
strategies. Some only accept a string whereas others accept a string
or array of strings. [`strategy` blocks also accept a `nil` return
(to simplify early returns) but this was already standardized across
strategies.]

While some strategies only identify one version by default (where a
string is an appropriate return type), it could be that a strategy
block identifies more than one version. In this situation, the
strategy would need to be modified to accept (and work with) an
array from a `strategy` block.

Rather than waiting for this to become a problem, this modifies all
strategies to standardize on allowing `strategy` blocks to return a
string or array of strings (even if only one of these is currently
used in practice). Standardizing valid return types helps to further
simplify the mental model for `strategy` blocks and reduce cognitive
load.

This commit extracts related logic from `#find_versions` into
methods like `#versions_from_content`, which is conceptually similar
to `PageMatch#page_matches` (renamed to `#versions_from_content`
for consistency). This allows us to write tests for the related code
without having to make network requests (or stub them) at this point.
In general, this also helps to better align the structure of
strategies and how the various `#find_versions` methods work with
versions.

There's still more planned work to be done here but this is a step
in the right direction.
2021-08-11 19:05:57 -04:00
Sam Ford
cf79ced740
Rework how strategy constants are identified
Up to this point, we've had to rely on making `Strategy` constants
private to ensure that the only available constants are strategies.
With the current setup, the existence of a constant that's not a
strategy would break `Strategy#strategies` and
`Livecheck#livecheck_strategy_names`.

Instead, we can achieve the same goal by skipping over constants
that aren't a class. Other than saving us from having to make these
constants private, this is necessary to be able to create a
`Strategy` constant that can be used in all strategies.
2021-08-11 18:25:34 -04:00
Sam Ford
83f261b6f2
HeaderMatch: Refactor default header logic 2021-08-02 18:33:59 -04:00
Sam Ford
af2c45b297
Git: compact, uniq array from strategy block 2021-08-02 18:33:59 -04:00
Sam Ford
a970780851
livecheck: allow nil return from strategy blocks 2021-08-02 18:33:34 -04:00
Sam Ford
ddde0f7589
livecheck: allow inheriting from a formula/cask 2021-08-02 09:12:22 -04:00
Bevan Kay
c28db0424d
livecheck: allow query parameter in electron_builder strategy url
Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
2021-07-28 13:20:15 +10:00
Sam Ford
7b864e0aaa
Sourceforge: Do not modify RSS URLs
This allows a `livecheck` block to check the RSS feed for a given
path in a SourceForge project. For example:
https://sourceforge.net/projects/example/rss?path=/directory
2021-07-19 15:15:27 -04:00
Sam Ford
87564b6ccb
Sparkle: Use OS::Mac::Version#prerelease? 2021-06-28 16:54:53 -04:00
Sam Ford
4433f4a985
Sparkle: Update minimumSystemVersion condition 2021-06-28 15:48:35 -04:00
Michael Cho
823dc28c21
livecheck/strategy/sparkle: check minimumSystemVersion for compatibility 2021-06-28 15:39:19 -04:00
Sam Ford
2c4a7ae2cb
Sparkle: Replace Nokogiri with REXML 2021-06-25 17:45:25 -04:00
Sam Ford
23f8cb9f4a
Sparkle: Handle ArgumentError from Time#parse 2021-06-22 10:02:57 -04:00
Sam Ford
a5768de0c3
Sparkle: Account for empty pubDate 2021-06-22 09:23:56 -04:00
Sam Ford
e7d3b2cb31
Sparkle: Move default pub_date value 2021-06-22 09:14:56 -04:00
hyuraku
6720f8bd1e
repair pub-date in livecheck 2021-06-22 09:14:55 -04:00
Mike McQuaid
30a65342e8
Deprecate, disable, delete code for Homebrew 3.2.0
Do the usual deprecation, disable, delete dance for Homebrew 3.2.0.
2021-06-17 11:34:32 +01:00
nthumann
e6a18803ea
Try getting page content with both headers 2021-06-10 00:12:26 +02:00
Sam Ford
a6769ae7cd
Strategy: Better align curl usage in methods 2021-06-04 16:16:06 -04:00
Sam Ford
793ea17749
Strategy: Create constant for HTTP separator 2021-06-04 16:16:06 -04:00
Sam Ford
ccfd01ba38
Strategy: Replace open-uri with curl 2021-06-04 16:16:05 -04:00
Nanda H Krishna
b920949693
Improve Gnome strategy explanatory comment
Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
2021-05-31 19:47:08 +05:30
Nanda H Krishna
471ce1541d
Modify Gnome strategy and update comments
Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
2021-05-31 16:07:56 +05:30
Nanda H Krishna
e5cfc0f37b
livecheck/strategy/gnome: handle new GNOME versioning 2021-05-30 22:23:07 +05:30