It's not sufficient to do this merely on `brew upgrade` because
`brew install` and `brew reinstall` can also result in formulae being
upgraded.
This requires moving logic from `cmd/upgrade.rb` to `upgrade.rb`. To
save you searching the diff the changes that resulted from doing that:
- Query the installed formulae from class state in `FormulaInstaller`
rather than the (incomplete) list that we passed into it.
- Don't output the "Checking dependents" message. It was there for
systems and configurations where this is slow but for most users
and most installations this will be a (annoying, noisy) no-op.
Fixes https://github.com/Homebrew/brew/issues/7860
- Make `brew extract` strip out bottle blocks
- Make `brew extract` output the path in a readable fashion
- Warn about building from source before fetching (not installing)
- If fetching a bottle fails, refetch and build from source.
- Trying to test out a user-submitted `brew bump-formula-pr` for
`app-engine-java` gave an error locally that [hasn't shown up on
CI](https://github.com/Homebrew/homebrew-core/pull/55798/checks?check_run_id=740165542),
oddly.
```
➜ brew install app-engine-java -s && brew test app-engine-java
Error: Calling Formula#installed? is deprecated! Use Formula#latest_version_installed? (or Formula#any_version_installed? ) instead.
/usr/local/Homebrew/Library/Homebrew/compat/formula.rb:6:in `installed?'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:421:in `block (2 levels) in check_requirements'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:420:in `each'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:420:in `block in check_requirements'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:419:in `each_pair'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:419:in `check_requirements'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:392:in `compute_dependencies'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:149:in `verify_deps_exist'
/usr/local/Homebrew/Library/Homebrew/formula_installer.rb:143:in `prelude'
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:328:in `install_formula'
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:261:in `block in install'
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:259:in `each'
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:259:in `install'
/usr/local/Homebrew/Library/Homebrew/brew.rb:110:in `<main>'
```
This ensures that dependencies are verified and tapped before they are
fetched. `FormulaInstaller#lock` has been moved into
`FormulaInstaller#install` to avoid locking until necessary.
While we're here, don't compute dependencies before fetching if we're
not going to use them.
Only prune test dependencies from the tree when they aren't also build
dependencies (and vice-versa with build dependencies) and the include
test argument hasn't been passed.