416 Commits

Author SHA1 Message Date
Mohammad Zain Abbas
9c4b9b7e14 Refactored a bit + brew style --fix 2022-08-02 00:27:53 +02:00
Mohammad Zain Abbas
e718318eaf Fixed issue with info[:meta] for resources 2022-08-01 23:50:18 +02:00
Mohammad Zain Abbas
6daa22bc8e Fixed issue with print_latest_version 2022-08-01 23:34:53 +02:00
Mohammad Zain Abbas
b651fe475c Added newer_than_upstream and outdated in resource info 2022-07-31 10:24:55 +02:00
Mohammad Zain Abbas
ce202dc61c Updated livecheck: Refactored for resources' output 2022-07-31 10:17:15 +02:00
Mohammad Zain Abbas
4de6509906 Removed print_latest_resource_version 2022-07-31 10:09:20 +02:00
Mohammad Zain Abbas
4f8f852fbc Refactored print_latest_version for resources as well 2022-07-31 10:08:39 +02:00
Mohammad Zain Abbas
40bbbd601e Refractored resource_version to work for a single resource 2022-07-31 09:49:19 +02:00
Mohammad Zain Abbas
4088c4683e
Indenting resources by two spaces
Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
2022-07-31 12:39:23 +05:00
Mohammad Zain Abbas
c074e8c020
Aligned output with the existing style seen in #latest_version
Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
2022-07-31 12:38:40 +05:00
Mohammad Zain Abbas
fe94bfb0f1
Updated livecheck_version
Co-authored-by: Nanda H Krishna <me@nandahkrishna.com>
2022-07-31 12:38:00 +05:00
Mohammad Zain Abbas
5beb7c1772 Simplified check resources' condition for Formulae 2022-07-31 09:35:41 +02:00
Mohammad Zain Abbas
6ec81ac31c No need to show that no resources exists for formulae 2022-07-31 09:33:01 +02:00
Mohammad Zain Abbas
806f0be69a Refactoring in progress 2022-07-27 21:28:28 +02:00
Mohammad Zain Abbas
0b5a68ca9b After brew style --fix for livecheck command 2022-07-27 20:43:07 +02:00
Mohammad Zain Abbas
3dc1b9c231 Refactored run_checks and resource_version methods for livecheck command 2022-07-27 18:25:12 +02:00
Mohammad Zain Abbas
1f55f15d66 Removed extra bits 2022-07-27 16:51:26 +02:00
Mohammad Zain Abbas
8e3e9743ac Basic structure completed for livecheckable resources 2022-07-27 16:37:31 +02:00
Mohammad Zain Abbas
73cf8fd205 Updated latest version for resources 2022-07-27 15:24:33 +02:00
Mohammad Zain Abbas
e72487c8b0 Updated for current and latest versions for resources 2022-07-27 15:13:55 +02:00
Mohammad Zain Abbas
2777610095 Work in progress for resource_version 2022-07-27 13:54:20 +02:00
Mohammad Zain Abbas
e84cc8d116 Work in progress for livecheckable resources 2022-07-27 13:27:21 +02:00
Mohammad Zain Abbas
43fcb5e563 Added support for resources in LivecheckVersion 2022-07-27 13:26:48 +02:00
Mohammad Zain Abbas
7ce15eaa60 Basic debug info 2022-07-25 00:56:36 +02:00
Mohammad Zain Abbas
a60cd00973 Minor: added version_info for resources 2022-07-24 19:54:00 +02:00
Mohammad Zain Abbas
1ee4f1a696 Work in progress for extending livecheck command for resources 2022-07-24 17:39:07 +02:00
Mohammad Zain Abbas
f4a42d7d66 Added method resource_version to check for resources 2022-07-24 15:47:40 +02:00
Mohammad Zain Abbas
7575170a0b Work in progress for livecheckable resources 2022-07-21 20:02:54 +02:00
Sam Ford
2194f6e12b
Only require livecheck block URL when appropriate
`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`).
2022-06-24 00:08:54 -04:00
Sam Ford
d7a26cd6d3
ExtractPlist: Modify #find_versions url usage 2022-06-24 00:08:53 -04:00
Sam Ford
077fb350a5
ExtractPlist: Add url to #find_versions object 2022-06-24 00:08:53 -04:00
Bevan Kay
916c980676
livecheck: allow custom url in extract_plist strategy 2022-06-24 00:08:53 -04:00
Bo Anderson
f5dc7a571f
Fix Style/ObjectThen offences 2022-06-17 19:47:55 +01:00
Sam Ford
5930880920
Gnome: Update default regex and version filtering
The `Gnome` strategy's default regex uses the `+` form of the standard
regex for matching versions like 1.2.3. However, with the switch to
the new version scheme, some packages had a release that omits a
minor and patch (i.e., `40` instead of `40.0`). The default regex
fails to match versions like this but the looser `*` form will match
both. [When creating regexes, we generally start with the `+` form
and only switch to the looser `*` form when it's necessary and
contextually-appropriate.]

This also updates the default version filtering logic that's applied
to versions using the old GNOME version scheme (below version 40).
Outside of the refactoring changes, this also filters out versions
where the patch number is 90+, as these are also unstable.
2022-06-13 18:17:56 -04:00
Sam Ford
d600b662e2
Expand documentation comments 2022-06-10 18:25:25 -04:00
Sam Ford
590aabe9d7
livecheck: update default match_data
This updates these strategies to better align with the default
`match_data` value in other strategies.
2022-06-10 18:25:25 -04:00
Sam Ford
52cd5dde9c
Respect --newer-only and --quiet in JSON output 2022-06-08 15:50:11 -04:00
Sam Ford
802a430300
livecheck: omit skipped when --newer-only is used 2022-06-08 15:50:11 -04:00
Sam Ford
a909be581b
Merge pull request #13387 from samford/livecheck/git-use-system_command
Git: Use system_command instead of Open3.capture3
2022-06-07 14:14:53 -04:00
Sam Ford
64a7c1f821
Git: Remove tags_only_debian logic
The `tags_only_debian` code in livecheck's `Git` strategy was
originally introduced in Homebrew/homebrew-livecheck#131 when
livecheck was in a less mature state and relied more on internal
special-casing like this (i.e., while we worked to add appropriate
`livecheck` blocks). This logic only has the potential to be
beneficial when a formula/cask doesn't contain a `livecheck` block
but I would argue that we shouldn't be making assumptions in the
strategy around whether tags with a `debian/` prefix should be
matched or omitted. The answer depends upon the context of a given
formula/cask and should be handled with a `livecheck` block, as we
do with other situations like this.
2022-06-07 09:02:03 -04:00
Sam Ford
bdd35efed8
Git: Use system_command instead of Open3.capture3
In a past discussion, it was preferred that we use `system_command`
in livecheck's `Git` strategy instead of `Open3.capture3` but it
wasn't feasible at the time because we couldn't prevent
`#system_command` from printing certain output. I resolved the
`SystemCommand` shortcoming long ago in Homebrew/brew#10066, so this
finally migrates the `Git` strategy to `system_command`.
2022-06-06 12:14:40 -04:00
Sam Ford
c6907f911f
Sparkle: Provide channel information in Item
Making `channel` information available in the `Item` is necessary
to be able to filter out unstable items using a `strategy` block. If
an item doesn't specify a channel, then it uses the default channel
(this is what Sparkle itself uses for updates). Channels like `beta`
are something we want to avoid for stable casks and this allows for
that type of [cask-specific] filtering.

It's technically possible to automatically filter out items that
aren't using the default channel (i.e., `channel != nil`) in
`#items_from_content` but some casks use an unstable version, so we
can't do this internally. That is to say, we wouldn't be able to
override internal filtering in a `strategy` block, as any omitted
items wouldn't be provided to the block. Conversely, if we pass all
items to a `strategy` block, we can easily filter by channel there.
We haven't been filtering by channel internally and we've only found
one cask where this has been a problem, so it seems fine for now.
2022-06-02 10:35:00 -04:00
Sam Ford
b4cb47815f
Sparkle: Pass all items into strategy block
It's sometimes necessary to work with all the items in a Sparkle feed
to be able to correctly identify the newest version but livecheck's
`Sparkle` strategy only passes the `item` it views as newest into a
`strategy` block.

This updates the `Sparkle` strategy to optionally pass all items into
a `strategy` block, so we can manipulate them (e.g., filtering,
sorting). This is enabled by naming the first argument of the
strategy block `items` instead of `item`. `Sparkle` `strategy` blocks
where the first argument is `item` will continue to work as expected.

This necessarily updates `#item_from_content` (now
`items_from_content`) to return all items. I've decided to move the
sorting out of `#items_from_content`, so it simply returns the items
in the order they appear. If there is ever an exceptional situation
where we need the original order, this will technically allow for it.

The sorting has instead been moved into the `#versions_from_content`
method, to maintain the existing behavior. I thought about passing
the items into the `strategy` block in their original order but it
feels like sorting by default is the better approach for now (partly
from the perspective of maintaining existing behavior) and we can
always revisit this in the future if a cask ever requires the
original order.

Lastly, this expands the `Sparkle` tests to increase coverage. The
only untested parts are `#find_versions` (which currently
requires a network request) and a couple safeguard `raise` calls
when there's a `REXML::UndefinedNamespaceException` (which shouldn't
be encountered unless something is broken).
2022-06-01 18:29:37 -04:00
Bo Anderson
38ae98cbcd
livecheck: improve host checks to instead check domains 2022-05-20 01:43:00 +01:00
Sam Ford
2f0a53c0da
Livecheck: Use Homebrew curl based on root domain
At the moment, `#use_homebrew_curl?` can only be true for a
`homepage` or `stable`/cask `url` with `using: :homebrew_curl`. If
the checked URL differs from these URLs, livecheck won't use brewed
curl. This limitation prevents livecheck from using brewed curl for a
`livecheck` block URL that's a string literal (not a symbol for a
`#checkable_url` like `:stable`, `:head`, `:url`). `libzip` was the
original formula referenced in the related brew issue and it meets
this criterion, so it doesn't appear to be handled by the existing
`#use_homebrew_curl?` implementation.

Additionally, the existing behavior can cause livecheck to
unnecessarily use brewed curl for a completely different website
(e.g., `cubelib`, `otf2`). For example, if the `stable` URL has
`using: :homebrew_curl` and the `livecheck` block has `url
:homepage`, livecheck will use brewed curl when checking the
`homepage`. If these are completely different domains/servers, it's
unlikely that we would need to use brewed curl when checking the
`homepage`, so this particular behavior may not be beneficial.

This commit reimplements `use_homebrew_curl?` to apply brewed curl
when the checked URL's root domain is the same as the root domain of
an aforementioned formula/cask URL with `using: :homebrew_curl`. For
example, this looser approach would allow a `livecheck` block
checking `https://www.example.com/downloads/` to use brewed curl if
the `stable` URL was `https://downloads.example.com/example.zip` with
`using: :homebrew_curl`. These could be different servers but, based
on related formulae, this looseness is necessary for the moment.

This approach aims to resolve both issues, allowing brewed curl to be
applied to a slightly broader range of URLs (i.e., not limited to
just the `#checkable_urls`) while also helping to avoid unnecessarily
applying brewed curl when it's less likely to be useful (completely
different domains). Neither approach is perfect but this one may be
more useful in the interim time.

Depending on how this looser approach works in practice, we may want
to consider returning to a stricter approach once we have something
like `using: :homebrew_curl` in `livecheck` blocks (this is
forthcoming). Being explicit in a `livecheck` block is the most
reliable approach (i.e., only use brewed curl when needed), so we
could favor that and pare down the automated approach to only what's
needed to support implicit checks (i.e., with no `livecheck` block).
Of course, it's also possible to drop the automated approach entirely
and simply require a `livecheck` block in this scenario but we can
decide on how to handle this when the time comes.
2022-05-18 18:48:17 -04:00
Mike McQuaid
95213893a6
Revert "Livecheck: Use Homebrew curl based on root domain" 2022-05-18 15:36:12 -04:00
Sam Ford
fb8a4e5658
Livecheck: Use Homebrew curl based on root domain
At the moment, `#use_homebrew_curl?` can only be true for a
`homepage` or `stable`/cask `url` with `using: :homebrew_curl`. If
the checked URL differs from these URLs, livecheck won't use brewed
curl. This limitation prevents livecheck from using brewed curl for a
`livecheck` block URL that's a string literal (not a symbol for a
`#checkable_url` like `:stable`, `:head`, `:url`). `libzip` was the
original formula referenced in the related brew issue and it meets
this criterion, so it doesn't appear to be handled by the existing
`#use_homebrew_curl?` implementation.

Additionally, the existing behavior can cause livecheck to
unnecessarily use brewed curl for a completely different website
(e.g., `cubelib`, `otf2`). For example, if the `stable` URL has
`using: :homebrew_curl` and the `livecheck` block has `url
:homepage`, livecheck will use brewed curl when checking the
`homepage`. If these are completely different domains/servers, it's
unlikely that we would need to use brewed curl when checking the
`homepage`, so this particular behavior may not be beneficial.

This commit reimplements `use_homebrew_curl?` to apply brewed curl
when the checked URL's root domain is the same as the root domain of
an aforementioned formula/cask URL with `using: :homebrew_curl`. For
example, this looser approach would allow a `livecheck` block
checking `https://www.example.com/downloads/` to use brewed curl if
the `stable` URL was `https://downloads.example.com/example.zip` with
`using: :homebrew_curl`. These could be different servers but, based
on related formulae, this looseness is necessary for the moment.

This approach aims to resolve both issues, allowing brewed curl to be
applied to a slightly broader range of URLs (i.e., not limited to
just the `#checkable_urls`) while also helping to avoid unnecessarily
applying brewed curl when it's less likely to be useful (completely
different domains). Neither approach is perfect but this one may be
more useful in the interim time.

Depending on how this looser approach works in practice, we may want
to consider returning to a stricter approach once we have something
like `using: :homebrew_curl` in `livecheck` blocks (this is
forthcoming). Being explicit in a `livecheck` block is the most
reliable approach (i.e., only use brewed curl when needed), so we
could favor that and pare down the automated approach to only what's
needed to support implicit checks (i.e., with no `livecheck` block).
Of course, it's also possible to drop the automated approach entirely
and simply require a `livecheck` block in this scenario but we can
decide on how to handle this when the time comes.
2022-05-17 00:34:32 -04:00
mhmdanas
37c46e1acd Remove space before colon in livecheck output 2022-04-27 01:09:16 +03:00
Sam Ford
ef5d8ed8b0
Strategy: Add --max-redirs to DEFAULT_CURL_ARGS
The default redirection maximum for `curl` is 50 but we should use
something more reasonable in livecheck. It's rare but a misconfigured
server with an endless redirection loop will hit the 50 redirection
limit. Unfortunately, we've encountered this in the wild (e.g., the
server for `getmail` and `memtester` endlessly redirects), so it's
not an idle concern. This commit basically adds `--max-redirs 5` to
`Livecheck::Strategy::DEFAULT_CURL_ARGS` to enforce a more reasonable
redirection maximum.

To be clear, the `max_iterations` logic in `#parse_curl_output`
(which was previously found in `Strategy#page_content`) doesn't
restrict the number of redirections that `curl` follows. At the point
the `curl` output is being parsed, the requests have already been
made and `max_iterations` simply restricts the number of responses
`#parse_curl_output` is willing to parse. If we use `--max-redirs`
and properly set `max_iterations` to `max-redirs + 1`, we shouldn't
encounter the "Too many redirects" error in `#parse_curl_output`.
2022-04-22 13:39:02 -04:00
Sam Ford
1c4faaa5d5
Strategy: Use Curl output parsing methods 2022-04-20 23:49:18 -04:00