499 Commits

Author SHA1 Message Date
Bo Anderson
f877fc5058
livecheck: remove module_function 2024-08-23 04:57:28 +01:00
Sam Ford
0a2e9661b6
Strategy#from_url: remove unused param
The `url_provided` parameter of the `Strategy#from_url` method was
originally introduced in #9529 but I removed it in a later commit in
that PR in favor of a different approach. Unfortunately, I forgot to
remove the `url_provided` parameter, as it was no longer needed after
that change. This removes the parameter and updates `#from_url` calls
accordingly.
2024-07-25 13:41:40 -04:00
Sam Ford
34fbf09841
Merge pull request #17842 from sazriel26/livecheck-for-head-only
[livecheck] Help to check head only formulae
2024-07-25 13:40:08 -04:00
Sam Ford
0de85120cb
Git: remove unused open3 require
I refactored the `Git` strategy to use `SystemCommand` instead of
`Open3#capture3` in #13387 but I forgot to remove `require "open3"`
at the time. `Git` doesn't use `open3` now, so this removes the
unused `require`.
2024-07-25 12:43:16 -04:00
Sam Ford
fcaeacd0da
livecheck: remove unused URI require
`URI#parse` was originally added in #9074 and replaced with
`Addressable::URI#parse` in #13306 but `require "uri"` wasn't removed
at the time. livecheck doesn't use `URI` now, so this removes the
unused `require`.
2024-07-25 12:41:34 -04:00
Sam Ford
f23d0ce373
livecheck: convert head-only strings to Versions
`brew livecheck` currently gives a Sorbet type error when run on a
HEAD-only formula: `Parameter 'version': Expected type Version, got
type String with value "c06c10d"`. This happens because the `current`
and `latest` values are strings but `LivecheckVersion#create` expects
a `Version` object.

This addresses the issue by creating a `Version` object from the
related commit strings. This ensures that the type of these variables
is more uniform, which makes them easier to reason about.
2024-07-25 10:23:39 -04:00
Sharon Azriel
31f4570cc2
[livecheck] Help to check head only formulae 2024-07-25 10:22:05 -04:00
Sam Ford
11d6785bea
Add utils/backtrace requires
This is primarily intended to resolve the `uninitialized constant
Utils::Backtrace` error in `formula_versions.rb:60` but I expanded it
to try to cover all existing usage of `Utils::Backtrace`.

I've followed the existing pattern, where `utils/backtrace` is
required in the context of where it's used. Many of these cases use
`Backtrace` in a conditional manner, so I've tried to ensure that the
`require` follows suit.
2024-07-15 17:48:47 -04:00
Mike McQuaid
c5dbd3ca24
Rearrange requires
This improves the load time of most brew commands. For an example of
one of the simplest commands this speeds up:

Without Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     525.0 ms ±  35.8 ms    [User: 229.9 ms, System: 113.1 ms]
  Range (min … max):   465.3 ms … 576.6 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     383.3 ms ±  25.1 ms    [User: 133.0 ms, System: 72.1 ms]
  Range (min … max):   353.0 ms … 443.6 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.37 ± 0.13 times faster than git checkout master; brew help
```

With Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     386.0 ms ±  30.9 ms    [User: 130.2 ms, System: 93.8 ms]
  Range (min … max):   359.5 ms … 469.3 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     330.2 ms ±  32.4 ms    [User: 93.4 ms, System: 73.0 ms]
  Range (min … max):   302.9 ms … 413.9 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.17 ± 0.15 times faster than git checkout master; brew help
```
2024-07-14 08:49:39 -04:00
Sam Ford
17d15615d8
livecheck: finish expanding typed: strict
I previously expanded use of `typed: strict` in livecheck files but
the exception was `livecheck/strategy.rb`. This addresses the
`@strategies` type errors in that file and upgrades it to
`typed: strict`.

Co-authored-by: apainintheneck <apainintheneck@gmail.com>
2024-07-07 22:04:25 -04:00
Sam Ford
7ba189a018
livecheck: expand typed: strict usage
This updates livecheck files to use `typed: script` where feasible.

The remaining exception is `livecheck/strategy.rb`, as I wasn't
able to figure out how to resolve the typing issues around the
`@strategies` variable (I tried a couple of approaches but couldn't
find a working solution). This includes changes to resolve the other
type errors in `strategy.rb` but leaves the file as `typed: true`
for now.
2024-07-04 20:22:14 -04:00
Rylan Polster
e07273a110
Remove redundant early return in livecheck skip_conditions 2024-06-29 11:42:24 -04:00
Issy Long
509fffab2b
Make more files Sorbet typed: strict
- According to Spoom, these could be bumped automatically with no errors.
2024-06-02 15:15:24 +01:00
Eric Knibbe
07e69b0ff2
livecheck/strategy: verify fail-with-body support 2024-05-23 13:08:25 -04:00
Bevan Kay
6c90e65f6f
livecheck/livecheck: fix passing an alternative url 2024-05-08 15:02:43 +10:00
Mike McQuaid
222fe8ef0b
Homebrew 4.3.0 deprecation/disable/removals.
The usual pass of deprecating/disabling/removing code for the next
minor Homebrew release.
2024-05-07 12:18:04 +01:00
Sam Ford
78c7ad747a
Pypi: Update strategy regex
livecheck is returning an `Unable to get versions` error for the
`ansible-lint`, `aws-sam-cli`, and `pyqt-builder` formulae. These use
the `Pypi` strategy without a `livecheck` block, so they use the
generated regex from the strategy. The `Pypi` strategy matches the
version from the tarball link on the pypi.org package page but this
fails for these packages because the formula's `stable` tarball uses
hyphens in the filename (e.g., `ansible-lint-...`) but the current
tarball filename uses underscores (e.g., `ansible_lint-...`).

This addresses the issue by updating the strategy regex to replace
[escaped] `-` or `_` characters in the package name with `[_-]`, so
the regex will match regardless of the delimiter used in the formula
filename.
2024-05-03 10:21:03 -04:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Sam Ford
111ac5810c
livecheck: Clean up whitespace, ordering 2024-03-31 21:01:40 -04:00
Sam Ford
a4134125f2
livecheck: Clarify --extract-plist behavior
From the description of the `--extract-plist` option, it would seem
that the `ExtractPlist` strategy is only enabled when the option is
used. Instead, livecheck automatically enables the strategy if the
command is run on only one cask. This rewords descriptions of the
option to clarify the behavior.
2024-03-31 21:01:40 -04:00
Sam Ford
a8d506fdda
livecheck: Add ExtractPlist skip to SkipConditions
When the `--extract-plist` option was added to livecheck, conditions
were added in `#run_checks` to skip casks using `ExtractPlist` if the
`--extract-plist` isn't used and the run involves multiple
formulae/casks. This integrates the skip into the `SkipConditions`
class.
2024-03-31 21:01:39 -04:00
Sam Ford
25d07c3838
livecheck: Add throttle info to debug, JSON output 2024-03-21 10:11:50 -04:00
Michael Cho
bfec6eecac
livecheck: support throttle DSL
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-21 10:11:49 -04:00
Razvan Azamfirei
4129200b96
livecheck: add --extract-plist switch 2024-03-21 11:50:27 +00:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Michael Cho
89b6d471e5
livecheck/strategy: fix **unused type 2024-02-28 12:32:21 -05:00
Issy Long
f4218a6316
Fix RuboCop Performance/MapCompact offenses
- Rename an iterator variable since it would make the line too long.
2024-02-25 22:59:59 +00:00
Issy Long
c86a402110
Fix RuboCop Lint/RedundantDirGlobSort offenses 2024-02-24 23:59:31 +00:00
Shreedhar Hegde
cf43d53ddc
strategy#page_content: align comments to future intentions
@samford is working on the ability to specify custom UA (among other things)
in livecheck blocks; "retrying" will cease to be relevant

Co-authored-by: Sam Ford <1584702+samford@users.noreply.github.com>
2024-02-25 02:30:33 +05:30
mavenor
be418d81e6
Strategy#page_content: allow cURL to --fail-with-body
since `curl_output` (introduced in #15351) sets `show_output: true`,
it doesn’t let it unless some form of --fail[...] is passed explicitly
2024-02-24 00:40:49 +05:30
Douglas Eichelberger
d6b3f5031a
Enable and fix warnings 2024-02-19 13:57:27 +00:00
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