6060 Commits

Author SHA1 Message Date
Michael Cho
a30f6c48f2
Merge pull request #16865 from cho-m/cask-audit-@
cask/audit: allow @ for versioned casks
2024-03-11 09:07:28 -04:00
apainintheneck
11b67e04c2 untap: add tests for finding formulae/casks in each tap
These are regression tests to make sure that this logic is reproducible.
If this logic is not working, it might mean that someone removes a tap
accidentally that still includes a formula or cask that they currently
have installed.

The tests are extravagant and over-engineered but I'm not sure that
there's an easier way to do this without massive integration tests.
2024-03-10 22:33:44 -07:00
Michael Cho
29175df63f
cleanup: track removed links & dirs during dry-run
This allows dry-run to display any directories that will be removed
as a result of previous removal steps.

Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-10 19:02:49 -04:00
Michael Cho
74f310577f
cleaner: remove RECORD and modify INSTALLER
According to [Python specification][1], we should remove `RECORD` file
to prevent changes to installed formula files via other tools, e.g. pip.
This also improves chances of generating an `all` bottle as it avoids
diff due to checksums of HOMEBREW_PREFIX present files. Also modify
`INSTALLER` file to indicate that brew is managing the Python package.

[1]: https://packaging.python.org/en/latest/specifications/recording-installed-packages/#intentionally-preventing-changes-to-installed-packages

Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-10 10:22:55 -04:00
apainintheneck
08442734ab s/Tap.reverse_tap_migrations_renames/Tap.tap_migration_oldnames/ 2024-03-09 10:27:22 -08:00
apainintheneck
e6a453a20d tap: add some tests
- Add tests for:
  - `Tap.each`
  - `Tap.installed`
  - `Tap.all`
  - `Tap#reverse_tap_migrations_renames`
  - `Tap.reverse_tap_migrations_renames`
2024-03-09 10:27:22 -08:00
Michael Cho
85a08bcdc4
cask/audit: allow @ for versioned casks
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-09 12:20:27 -05:00
apainintheneck
3834ef1b73 tap: cache more things at the Tap level
I added two new methods to cache both installed and all taps.
All taps includes core taps no matter if they're installed locally
since they're always provided by the API anyway.

This makes it easier to cache `Tap.each` while making the code
easier to reason about. It also will be useful because we'll
be able to avoid the `Tap.select(&:installed?` pattern that has
recently invaded the codebase.

Note: I also stopped clearing all tap instance caches before
tests. Running `Tap.each` would cache existing taps which would
lead to unexpected behavior since the only existing tap before
each test is the core tap. This is the only tap whose directory
is not cleaned up between tests so we just clear it's cache directly.
We also now clear all tap instances after tests as well regardless
of whether the API was used that time.
2024-03-08 23:22:00 -08:00
Mike McQuaid
9ac31827a0
Various brew update behaviour improvements
- Output a message every time auto-update is run rather than a 3 second
  timer. This makes it more obvious that Homebrew isn't just sitting
  doing nothing for 2.9 seconds.
- Output a message when running `brew update` so Homebrew doesn't just
  sit there silently doing nothing.
- Update all taps when `brew update` is run, not just those hosted on
  GitHub. This makes it more obvious that people don't need to explictly
  run `brew update` "just in case".
- As a result of this, remove `brew tap --force-auto-update` as it's no
  longer necessary.
2024-03-08 16:21:09 +00:00
Mike McQuaid
b70884a474
Merge pull request #16848 from Homebrew/rubocop_default_hash_syntax
rubocop: default hash syntax.
2024-03-08 07:55:33 +00:00
apainintheneck
e0cea903ec s/to_api_hash/to_internal_api_hash/ 2024-03-07 20:29:58 -08:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Mike McQuaid
3802d113ae
Merge pull request #16846 from Homebrew/analytics_cleanup
utils/analytics: general cleanup.
2024-03-07 15:53:23 +00:00
Mike McQuaid
9259c345cc
utils/analytics: general cleanup.
We have plans to add analytics for commands and `brew test-bot`

This requires a certain amount of refactoring which I've done here.

There was also a bunch of legacy `*_influx_?` usage from when we used
both InfluxDB and Google Analytics that made sense to clean up and
excessive indirection.
2024-03-07 15:19:04 +00:00
Markus Reiter
be9c0b8787
Simplify TapConfig. 2024-03-07 15:31:37 +01:00
Markus Reiter
a24da6b072
Remove FromDefaultNameLoader to avoid warning twice. 2024-03-06 23:14:28 +01:00
Mike McQuaid
03e583e746
cask: read bundle version from Info.plist when sensible.
If you're trying to use `brew info --json=v2` to get an installed
version and figure out if it is outdated: you're going to have a bad
time with `auto_updates` casks because `installed_version` alone is not
enough to get the actually currently installed version of the app.

Instead, in these cases, try to read from `Info.plist` if there is one
and use that version.

While we're here, add a `blank?` method to `Version` so we can use it
for `present?` checks (making a `null?` `Version` object `blank?`).

Co-authored-by: Markus Reiter <me@reitermark.us>
2024-03-06 15:52:16 +00:00
Mike McQuaid
026ca68c5c
Merge pull request #16834 from reitermarkus/tap-new-private
Make `Tap::new` private.
2024-03-06 15:33:25 +00:00
Mike McQuaid
83c94df40d
Merge pull request #16832 from reitermarkus/tap-sig-fetch
Add type signature for `Tap::fetch`.
2024-03-06 15:32:45 +00:00
Markus Reiter
e3a102efd4
Make Tap::new private. 2024-03-06 15:10:14 +01:00
Markus Reiter
a851bb86ef
Add type signature for Tap::fetch. 2024-03-06 14:30:17 +01:00
Justin Klaassen
009ddd7036
dev-cmd/bump: add --tap= flag 2024-03-05 18:11:53 -08:00
Mike McQuaid
c5e7282985
Merge pull request #16807 from dduugg/numbered-params
Prefer numbered block params over proc conversion
2024-03-04 16:38:14 +00:00
Markus Reiter
e369689794
Add test for Tap#custom_remote?. 2024-03-04 15:32:27 +01:00
Douglas Eichelberger
c4db19232d git grep -lE '\(\&[A-Za-z._]+method\(:' | xargs gsed -i -E 's|\(\&([A-Za-z._]+)method\(:([a-z?_]+)\)\)| { \1\2(_1) }|g' 2024-03-03 18:55:56 -08:00
Markus Reiter
3da0f8c4a6
Fix loading casks/formulae from relative paths. 2024-03-01 04:05:15 +01:00
apainintheneck
cd5b93a2f2 internal json v3: parse ruby source checksum correctly
Currently we are including this in the API but not actually
parsing and loading it correctly from the JSON. I think this
was an oversight when addressing feedback and refactoring
the JSON shape. Not a big deal, of course, because I'm the
only person using it right now.

I found this out while testing installs using the API and I got
this error while running `brew reinstall tree`.

```
Warning: Cannot verify integrity of '60fc4212023d3fef00e6de4b9f3f0d63402cf3eca00778d09f4f2d3481b524a1--tree.rb'.
No checksum was provided.
```
2024-02-28 21:34:31 -08:00
Mike McQuaid
99c101bfc1
internal_tap_json/formula_spec: add comment. 2024-02-28 10:49:36 +00:00
apainintheneck
f1f2e24aec test fixture: pretty print JSON for readability 2024-02-27 20:55:16 -08:00
apainintheneck
bfe5e43ff4 api/formula: Fix failing specs
- clear the formula API cache
- make the API cache directory
- fix stubbed return values (thanks Sorbet!)
2024-02-27 20:55:16 -08:00
apainintheneck
200fe2a6b7 api/formula: Add tests for internal JSON v3
These tests cover both generating and loading formulae from the JSON
bundle. The tests are not comprehensive but they do provide a nice
sanity check that things are working as expected.
2024-02-27 20:55:16 -08:00
apainintheneck
f2c5f6723c test: clear tap instance caches between test runs again
The core taps exist outside of the normal cache busting cycle
so they need to clear explicitly at the instance level.
Just to be sure we should clear all of them each time.

This essentially reverts part of the change in this PR.
- https://github.com/Homebrew/brew/pull/16746
2024-02-27 19:35:30 -08:00
Markus Reiter
18571e8991
Merge pull request #16732 from reitermarkus/repo-var-suffix
Rename `Tap#repo_var` to `Tap#repo_var_suffix`.
2024-02-27 11:26:16 +01:00
Mike McQuaid
ca9405de5c
Merge pull request #16746 from apainintheneck/simplify-cache-clearing-in-tests
cachable: make sure to clear caches between tests
2024-02-27 08:35:38 +00:00
apainintheneck
5cc1c85a5f cachable: Move registry to test directory
Now we only include the cachable registry when running tests.
We basically just load it first and add a bunch of methods to
it before loading the rest of the formula files when we require
global.rb. I added a check to make sure this require order is
preserved.

I also made a bunch of methods private, stop excluding classes
that inherit from casks since it's unnecessary and add more docs.
2024-02-26 20:41:10 -08:00
apainintheneck
536ae08a44 cachable: make sure to clear caches between tests
This adds a registry for all modules and classes that
cachable is included in. The registry allows us to
programmatically clear all caches in between tests
so that we don't forget to do that when adding a new
class or refactoring code. The goal here is to reduce
the number of flaky tests in the future.
2024-02-25 17:47:30 -08: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
Markus Reiter
132a87aff5
Rename Tap#repo_var to Tap#repo_var_suffix. 2024-02-23 16:02:29 +01:00
Markus Reiter
96f861e947
Merge pull request #16729 from reitermarkus/warn-from-name-loader
Pass `warn` in `FromNameLoader`.
2024-02-23 01:27:55 +01:00
Markus Reiter
0684a16293
Pass warn in FromNameLoader. 2024-02-22 22:12:07 +01:00
Markus Reiter
ed07203f9e
Fix tap constants. 2024-02-22 22:03:54 +01:00
Markus Reiter
e0743a1436
Reapply "Refactor Formulary::loader_for."
This reverts commit 24683525cb5abf3cc79a9e0e268fa6efd0af558b.
2024-02-22 18:24:57 +01:00
Markus Reiter
9cfc7ef9bd
Clear all tap caches before each test. 2024-02-22 17:56:47 +01:00
Mike McQuaid
b8243d0e9e
Merge pull request #16717 from jesboat/fix-chmod-message2
[brew audit] fix "Incorrect file permissions" message
2024-02-22 08:51:52 +00:00
Issy Long
a895496982
rubocop: The pyyaml resource requires depends_on "libyaml" 2024-02-20 23:22:15 +00:00
Jade Elizabeth Sailor
94aeabfc8a [brew audit] fix "Incorrect file permissions" message
When the file isn't world-readable, `brew audit` prints a failure
message including a suggestion to `chmod +r` the file. Unfortunately,
this isn't quite right: with both macOS and coreutils, leaving out the
"who" in a chmod only affects bits which would be set in the umask. So,
if the umask doesn't allow world-readable (which might be why the file
wasn't world-readable in the first place), the suggested chmod command
does nothing.

Change to print `chmod a+r` instead; that does have the intended effect.

No other `chmod` suggestions in this file have the same problem.
2024-02-20 16:26:21 -05:00
Mike McQuaid
14ba271533
Merge pull request #16705 from issyl0/lxml-resource-needs-uses-from-macos
rubocop: Formulae with the "lxml" resource have required dependencies
2024-02-20 12:54:19 +00:00
Issy Long
ff23de4766
Formatting and cope with more modern RSpec config changes
Co-authored-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2024-02-20 12:17:27 +00:00
Issy Long
33c33b5338
rubocop: Formulae with the "lxml" resource have required dependencies
- We're moving from `depends_on "python-lxml"` to `resource "lxml" ...` as part
  of the new Python vendoring plan.
- For `resource "lxml"` to work, `uses_from_macos "libxml2"` and
  `uses_from_macos "libxslt"` are needed in the formulae.
- This new RuboCop rule enforces that a formula including the "lxml" resource
  also include those dependencies.
2024-02-19 22:50:55 +00:00
Douglas Eichelberger
e7e4ecc405 Change return type 2024-02-19 13:29:49 -08:00