This turns the ability to replace common paths with placeholders
into a mixin that can be used with both Casks and Formulae.
The idea here is to make formula hash generation more consistent.
Instead of doing so literally whenever we query for a formula, Instead
do so only when we're in an auto-updateable command.
This better fits the existing behaviour while still updating when it's
most important to do so.
- Use constants for placeholders
- Monkeypatch to set `HOMEBREW_PREFIX` consistently to placeholder
- Use environment variable to set `Dir.home` consistently to placeholder
- Use `appdir` short-circuit to set `Cask#appdir` consistently to placeholder
- Use `Cask.generating_hash!` to enable "generating mode" with these patches
- Fix `Formula#caveats` from JSON
Fixes#14505Fixes#14595
- Write a subset of the tab required for bottles as an annotation.
- Add option on new bottle creation to skip writing tab into bottle
and instead add it (and other useful metadata) to bottle JSON.
- Read formula information and tab from bottle JSON.
- Write prettier JSON to disk.
- Don't write `HEAD` to tab; this duplicates `HOMEBREW_VERSION`.
- Allow `brew bottle` to use `--json` to generate JSON files from a
local bottle file.
- make the description more generic/correct
- use "internet archive" over "archive"
- move some logic to a new `GitHubReleases` class (for consistency)
- remove some obvious comments
- extract out and move some constants
> Bootsnap is a library that plugs into Ruby, with optional support
> for ActiveSupport and YAML, to optimize and cache expensive
> computations.
https://github.com/Shopify/bootsnap
For our case that translates to "repeated calls to `brew` have
reductions in the time spend `require`ing speeding up the process
boot time".
For example:
```
$ hyperfine --warmup=2 "unset HOMEBREW_BOOTSNAP; brew info wget" "export HOMEBREW_BOOTSNAP=1; brew info wget"
Benchmark #1: unset HOMEBREW_BOOTSNAP; brew info wget
Time (mean ± σ): 2.417 s ± 0.032 s [User: 659.0 ms, System: 855.5 ms]
Range (min … max): 2.382 s … 2.464 s 10 runs
Benchmark #2: export HOMEBREW_BOOTSNAP=1; brew info wget
Time (mean ± σ): 1.862 s ± 0.064 s [User: 425.3 ms, System: 566.8 ms]
Range (min … max): 1.736 s … 1.952 s 10 runs
Summary
'export HOMEBREW_BOOTSNAP=1; brew info wget' ran
1.30 ± 0.05 times faster than 'unset HOMEBREW_BOOTSNAP; brew info wget'
```
We were previously only looking at the `cellar` value when pouring
bottles and ignoring the `prefix` and (implicit) `repository`.
Actually look at these values and set the defaults for each platform.
Also, when we're relocating to create or pour bottles when `prefix`
and `repository` are equal then skip relocating the `repository` and
always use references to the `prefix` instead.
Fixes#9453