373 Commits

Author SHA1 Message Date
apainintheneck
37cbfc40bf Fix internal formula json v3 frozen hash parsing bug
This caused formulae with uses from macos bounds to not load correctly
because they tried to modify a frozen hash. It wasn't obvious from
the tests because I didn't replicate the real world JSON parsing
conditions closely enough. I also had to modify `Cachable#clear_cache`
so that it can clear frozen hashes.

Error:
```
Error: can't modify frozen Hash: {"since"=>"catalina"}
Warning: Removed Sorbet lines from backtrace!
Rerun with `--verbose` to see the original backtrace
/usr/local/Homebrew/Library/Homebrew/extend/hash/keys.rb:123:in `delete'
/usr/local/Homebrew/Library/Homebrew/extend/hash/keys.rb:123:in `block in _deep_transform_keys_in_object!'
/usr/local/Homebrew/Library/Homebrew/extend/hash/keys.rb:122:in `each'
/usr/local/Homebrew/Library/Homebrew/extend/hash/keys.rb:122:in `_deep_transform_keys_in_object!'
/usr/local/Homebrew/Library/Homebrew/extend/hash/keys.rb:48:in `deep_transform_keys!'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:230:in `block (2 levels) in load_formula_from_api'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:218:in `each'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:218:in `block in load_formula_from_api'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:304:in `instance_exec'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:304:in `block (2 levels) in load_formula_from_api'
/usr/local/Homebrew/Library/Homebrew/formula.rb:3664:in `instance_eval'
/usr/local/Homebrew/Library/Homebrew/formula.rb:3664:in `stable'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:293:in `block in load_formula_from_api'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:283:in `initialize'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:283:in `new'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:283:in `load_formula_from_api'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:962:in `load_from_api'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:955:in `klass'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:569:in `get_formula'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:1009:in `factory'
/usr/local/Homebrew/Library/Homebrew/dependency.rb:41:in `to_formula'
/usr/local/Homebrew/Library/Homebrew/utils/autoremove.rb:46:in `block (2 levels) in formulae_with_no_formula_dependents'
/usr/local/Homebrew/Library/Homebrew/utils/autoremove.rb:45:in `each'
/usr/local/Homebrew/Library/Homebrew/utils/autoremove.rb:45:in `block in formulae_with_no_formula_dependents'
/usr/local/Homebrew/Library/Homebrew/utils/autoremove.rb:39:in `each'
/usr/local/Homebrew/Library/Homebrew/utils/autoremove.rb:39:in `formulae_with_no_formula_dependents'
/usr/local/Homebrew/Library/Homebrew/utils/autoremove.rb:59:in `unused_formulae_with_no_formula_dependents'
/usr/local/Homebrew/Library/Homebrew/utils/autoremove.rb:16:in `removable_formulae'
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:693:in `autoremove'
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:291:in `clean!'
/usr/local/Homebrew/Library/Homebrew/cmd/cleanup.rb:52:in `run'
/usr/local/Homebrew/Library/Homebrew/brew.rb:92:in `<main>'
```
2024-05-01 21:36:37 -07:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Mike McQuaid
7c0b989740
Merge pull request #17153 from apainintheneck/new-formula-json-dependencies-format
New formula internal json v3 dependencies format
2024-05-01 08:45:18 +01:00
Markus Reiter
0b56d0be4a
Document Tab.for_keg and use Keg#tab where possible. 2024-04-28 20:50:13 +02:00
apainintheneck
541305ae98 Update internal json v3 formula tests 2024-04-27 18:07:54 -07:00
apainintheneck
ff0c24786b Unpack new internal json v3 dep format 2024-04-27 18:07:54 -07:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Markus Reiter
4b432c7ea4
Explicitly mark non-private APIs. 2024-04-22 21:16:49 +02:00
apainintheneck
db507be41a keg: update sorting by version logic
This updates logic to add a `#scheme_and_version` method to be used
with `.sort_by` and `.max_by`. Using `Keg#version` by itself can be
inaccurate when different version schemes are present. This also
updates the behavior of `Formula#eligible_kegs_for_cleanup` to match
the previous behavior. We were dropping the wrong keg based on the
sort being reversed in a previous PR.
2024-03-31 17:52:32 -07:00
Bo Anderson
dd382487c7
Sort kegs based on version scheme 2024-03-29 23:33:41 +00:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Markus Reiter
a24da6b072
Remove FromDefaultNameLoader to avoid warning twice. 2024-03-06 23:14:28 +01:00
Markus Reiter
a851bb86ef
Add type signature for Tap::fetch. 2024-03-06 14:30:17 +01:00
Mike McQuaid
f1eea64523
Merge pull request #16779 from reitermarkus/fix-load-from-path
Fix loading casks/formulae from relative paths.
2024-03-01 08:47:41 +00:00
Markus Reiter
3da0f8c4a6
Fix loading casks/formulae from relative paths. 2024-03-01 04:05:15 +01:00
Markus Reiter
2a78eba1ad
Simplify Tap#formula_files_by_name. 2024-02-29 22:48:50 +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
apainintheneck
670e2188d7 formulary: update api loader to load internal json v3 2024-02-27 20:55:16 -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
0684a16293
Pass warn in FromNameLoader. 2024-02-22 22:12:07 +01:00
Markus Reiter
964f005b3e
Only treat symlinks in taps as alias paths.
Fixes https://github.com/Homebrew/homebrew-core/issues/162946.
2024-02-22 18:28:53 +01:00
Markus Reiter
e0743a1436
Reapply "Refactor Formulary::loader_for."
This reverts commit 24683525cb5abf3cc79a9e0e268fa6efd0af558b.
2024-02-22 18:24:57 +01:00
Markus Reiter
ab27efbd9d
Make Tap::each respect the API. 2024-02-22 17:56:47 +01:00
Mike McQuaid
24683525cb
Revert "Refactor Formulary::loader_for." 2024-02-16 13:41:54 +00:00
Markus Reiter
fe1f6c95f5
Fix FromDefaultNameLoader. 2024-02-14 23:09:18 +01:00
Markus Reiter
b717f5d954
Remove unused TapFormulaWithOldnameAmbiguityError. 2024-02-14 22:56:25 +01:00
Markus Reiter
177e9163c2
Fix code style. 2024-02-14 22:47:29 +01:00
Markus Reiter
f4ac2996a7
Fix type signature. 2024-02-14 22:11:51 +01:00
Markus Reiter
ce60048192
Handle TapFormulaAmbiguityError in diagnostics. 2024-02-14 20:28:08 +01:00
Markus Reiter
9056613181
Add separate loader for default tap. 2024-02-14 20:28:08 +01:00
Markus Reiter
eb48d6be95
Always prefer the default tap. 2024-02-14 20:28:08 +01:00
Markus Reiter
562d5295f4
Remove unnecessary if. 2024-02-14 20:28:08 +01:00
Markus Reiter
22bb15748b
Simplify conditional. 2024-02-14 20:28:07 +01:00
Markus Reiter
ba29328b59
Avoid T.cast. 2024-02-14 20:28:07 +01:00
Markus Reiter
0626f62077
Remove redundant debug output. 2024-02-14 20:28:06 +01:00
Markus Reiter
0f4d912de5
Remove Formulary::tap_paths again. 2024-02-14 20:28:06 +01:00
Markus Reiter
ecee4aed35
Revert diagnostic change. 2024-02-14 20:28:06 +01:00
Markus Reiter
d70f719411
Fix code style. 2024-02-14 20:28:06 +01:00
Markus Reiter
4641690674
Refactor Formulary::loader_for. 2024-02-14 20:28:06 +01:00
Markus Reiter
1c4b06fce2
Merge pull request #16647 from reitermarkus/uses_from_macos_sig
Refactor and add type signature for `uses_from_macos`.
2024-02-13 19:36:11 +01:00
Markus Reiter
eaf7b38995
Allow tap migrations with renames. 2024-02-13 04:17:43 +01:00
Markus Reiter
c6788bb27e
Avoid T.unsafe. 2024-02-13 00:42:54 +01:00
Markus Reiter
d9712f4d50
Refactor and add type signature for uses_from_macos. 2024-02-13 00:31:10 +01:00
apainintheneck
70ffc31338 formulary: update logic and add regression test 2024-02-11 13:09:53 -08:00
Stephan Jorek
d01de7545c
refactor bugfix to satify brew audit 2024-02-11 11:40:49 +01:00
Stephan Jorek
863654e37c
remove accidentally added newline 2024-02-11 01:39:44 +01:00
Stephan Jorek
1570a4b8a3
Fix support of formulae aliases in taps
Resolves: #16636
2024-02-11 00:38:47 +01:00
Markus Reiter
3e61e3b428
Stop following recursive tap migrations. 2024-02-10 15:07:31 +01:00
Markus Reiter
f72038b116
Fix loading aliases from API. 2024-02-08 12:19:04 +01:00
Markus Reiter
29179e45a1
Refactor rename/migration handling in Formulary. 2024-02-06 00:52:38 +01:00