416 Commits

Author SHA1 Message Date
Sam Ford
55ec4c483c
Crate: Rework conditions
Co-authored-by: Douglas Eichelberger <dduugg@gmail.com>
Co-authored-by: Markus Reiter <me@reitermark.us>
2024-02-11 21:53:21 -05:00
Sam Ford
98f3258ff4
Livecheck: Add Crate strategy
We discussed the idea of adding a livecheck strategy to check crate
versions years ago but decided to put it off because it would have
only applied to one formula at the time (and it wasn't clear that a
crate was necessary in that case). We now have a few formulae that
use a crate in the `stable` URL (`cargo-llvm-cov`, `pngquant`,
`oakc`) and another formula with a crate resource (`deno`), so
there's some value to the idea now.

I established a standard approach for checking crate versions in a
somewhat recent `pngquant` `livecheck` block update and this commit
reworks it into a strategy, so we won't have to duplicate that
`livecheck` block in these cases. With this strategy, we usually
won't even need a `livecheck` block at all.

Under normal circumstances, a regex and/or strategy block shouldn't
be necessary but the strategy supports them when needed. The response
from the crates.io API is a JSON object, so this uses
`Json#versions_from_content` internally and a `strategy` block will
receive the parsed `json` object and a regex (the strategy default or
the regex from the `livecheck` block).
2024-02-11 21:53:21 -05:00
Douglas Eichelberger
eb7c3e52a0 Require SystemInclude only where needed 2024-01-31 11:42:01 -08:00
Douglas Eichelberger
f99d39faf9 Vendor CompactBlank cop 2024-01-26 15:03:59 -08:00
Douglas Eichelberger
df140b329f brew style --fix 2024-01-22 10:52:43 -08:00
Douglas Eichelberger
2e21efff46 Add ActiveSupport String#exclude? to extend/ 2024-01-19 13:35:34 -08:00
Issy Long
f682147598
Fix RuboCop Style/RedundantFreeze offenses 2024-01-18 22:20:01 +00:00
Douglas Eichelberger
caf8259ae6 Code review changes 2023-12-27 15:29:33 -08:00
Douglas Eichelberger
3abbf4447e Some minor regexp match perf improvements 2023-12-27 13:16:36 -08:00
Rylan Polster
25b753fe51
Re-add some discontinued? checks for casks 2023-12-17 19:07:37 -05:00
Rylan Polster
7eb3f1a314
Replace discontinued? with deprecated? 2023-12-16 20:01:47 -05:00
Bo Anderson
89531e9ff3
Update all dependencies 2023-12-15 16:24:46 +00:00
Bo Anderson
5692c8ecbf
Fix style violations under newer RuboCop 2023-12-14 05:47:12 +00:00
Mike McQuaid
79a6091d08
Cask#full_name: properly output Homebrew org names
This was not returning the full name correctly for e.g. anything in
Homebrew/homebrew-fonts.

While we're here, fix up a few other places where `tap.core_cask_tap?`
can be used more appropriately.
2023-12-13 13:17:12 +00:00
Douglas Eichelberger
4a062b117c Rename block var 2023-12-12 10:19:58 -08:00
Douglas Eichelberger
e8d87fe256 Strict type livecheck/livecheck 2023-12-12 10:10:18 -08:00
Douglas Eichelberger
c75fc63d61 refactor out except! calls 2023-12-12 10:09:49 -08:00
Bo Anderson
b42256d286
Deprecate, disable & delete code for Homebrew 4.2.0 2023-12-07 23:42:13 +00:00
Sam Ford
9bfe423a5a
Xml: Add #element_text method
This refactors verbose code in the `Sparkle` strategy where we access
element text into a reusable `Xml#element_text` method, replacing
chained calls like `item.elements["title"]&.text&.strip&.presence`
with `Xml.element_text(item, "title")`.

`#element_text` is only used to retrieve the text of a child element
in the `Sparkle` strategy but it can also retrieve the text from the
provided element if the `child_path` argument is omitted (i.e.,
`Xml.element_text(item)`). This will allow us to also avoid similar
calls like `item.text.strip.presence` in the future.
2023-11-17 22:34:12 -05:00
Sam Ford
75ce7240fc
Sparkle: Refactor macOS os strings into constant 2023-11-16 12:05:25 -05:00
Sam Ford
bc2ce97e5d
Sparkle: Move sorting/filtering into methods
We need to be able to replicate the `Sparkle` strategy's sorting
and filtering behavior in a related cask audit, so this extracts
the logic into reusable methods.

This also stores `item.minimum_system_version` as a `MacOSVersion`
object (instead of a string), so we can do proper version comparison
(instead of naive string comparison) wherever needed.
2023-11-16 12:05:24 -05:00
Sam Ford
4f469234d0
Sparkle: Ensure empty strings become nil
Sometimes appcasts contain empty elements/attributes and the `Item`
values end up as an empty string because of how they're handled in
`#items_from_content`. It's reasonable to expect that empty values
would be `nil` instead, so this adds `#presence` calls to ensure this
is the case.
2023-11-16 12:05:24 -05:00
Sam Ford
86c702abcd
Sparkle: Surface more Item values
Historically, the `Sparkle` strategy's `Item` struct has only
included basic values from the appcast that are commonly useful.
Over time we've selectively added/surfaced more values as we've
encountered outliers that require use of different values in a
`strategy` block.

We now need to use `minimumSystemValue`, so this expands the `Item`
struct to include any appcast value that we could conceivably want
to use in the future. This will hopefully save us from having to make
more modifications to the struct (and related tests) before we can
use a previously-unused value in a `strategy` block.
2023-10-28 14:55:47 -04:00
Bo Anderson
26ea6b7f9e
Pull in REXML gem as it doesn't ship with Ruby 3 2023-10-27 20:24:10 +01:00
Bo Anderson
582049454f
vendor/bundle/ruby: cleanup unneeded files 2023-09-26 18:39:57 +01:00
apainintheneck
85bd4c7e1f utils/backtrace: scrub sorbet-runtime from backtrace
Ever since we started using this at runtime it's been polluting
the backtrace output. This makes it harder to debug errors and
increases the amount of info users have to paste into the box
when filing an issue.

This is a very direct approach. Essentially, we strip out
everything related to the `sorbet-runtime` gem whenever the top
line in the backtrace is unrelated to sorbet-runtime.

The hope is that this will allow errors related to sorbet to
be diagnosed easily while also reducing the backtrace size
for all other types of errors.

Sometimes it is useful to see the full backtrace though.
For those cases, we include the full backtrace when
`--verbose` is passed in and print a warning that the
Sorbet lines have been removed from the backtrace the
first time they are removed.

Note: This requires gems to be set up so that the call to
`Gem.paths.home` works correctly. For that reason, it must
be included after `utils/gems` which is included in
`standalone/load_path` already.
2023-09-21 21:07:22 -07:00
Eric Knibbe
931f762598
docs+rubydoc: various grammar/wording fixes 2023-09-11 02:26:37 -04:00
Sam Ford
88109b16c3
Livecheck#preprocess_url: compare with URI host
We now have a `gitea` formula in homebrew/core and its `stable` URL
uses a dl.gitea.com tarball. Since the URL's domain is gitea.com,
livecheck tries to preprocess the URL into a `.git` URL but the
resulting URL doesn't work because it's not a Git repository.

Gitea repositories use gitea.com (with no subdomain), so
`#preprocess_url` should be comparing the URI host (`dl.gitea.com`)
instead of the domain (`gitea.com`). This change allows gitea.com
repository URLs to continue to be preprocessed into a `.git` URL
while dl.gitea.com URLs are left untouched.

This makes the same change for the other domains, as they don't use
a subdomain either.
2023-09-04 00:49:23 -04:00
Patrick Linnane
1c4073df38
Livecheck: allow quiet output with --newer-only 2023-08-15 17:43:36 -07:00
Douglas Eichelberger
d01cda2815 Turn up the types 2023-08-12 22:01:22 -07:00
Douglas Eichelberger
08e46c18cd Add type to Formula attrs 2023-07-24 14:12:36 -07:00
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