82 Commits

Author SHA1 Message Date
Mike McQuaid
0940fb78dc
Fix usage of Tab#installed_(on_request|as_dependency)
These can return `true`, `false` or `nil` so adjust the signature to
note this and fix the call sites to ensure we don't accidentally pass
through `nil` values when we shouldn't.

While we're here, make a `TODO` to fix this bad API up in future.

Fixes https://github.com/Homebrew/brew/issues/19076
2025-01-13 09:24:42 +00:00
Mike McQuaid
4d4531c19d
Revamp installed_on_request handling
- `reinstall` and `upgrade` no longer mark as installed on request,
  with or without names specified, but preserve the version from the
  tab instead
- default `install_on_request` to `false` rather than `true`
- only set installed in request in a tab if it's missing rather than
  false

Co-authored-by: Michael Cho <michael@michaelcho.dev>
2024-11-19 08:39:55 +00:00
Bo Anderson
e91ed65aef
upgrade: remove module_function 2024-08-20 15:33:08 +01:00
Bo Anderson
77204e01da
reinstall: move to submodule 2024-08-20 03:58:01 +01:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
Bo Anderson
993a0aec3a
upgrade: fix missed upgrades when an alias is changed to a formula 2024-08-03 01:49:40 +01:00
Markus Reiter
0b56d0be4a
Document Tab.for_keg and use Keg#tab where possible. 2024-04-28 20:50:13 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Nate Whetsell
ed3072646f Output version upgrade info using puts 2024-03-27 17:44:09 -04:00
Mike McQuaid
f1f92d28bf
Merge branch 'master' into lail/add-overwrite-flag-to-brew-upgrade 2024-03-08 08:27:04 +00:00
Bob
3d24da1904 Add support for the --overwrite flag to brew upgrade to govern the keg-linking step
`FormulaInstaller` already supports this (https://github.com/Homebrew/brew/pull/12691) but I didn't wire it up via `brew upgrade` and the two can be used largely interchangeably
2024-03-07 13:13:28 -08:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00: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
Bo Anderson
5692c8ecbf
Fix style violations under newer RuboCop 2023-12-14 05:47:12 +00:00
apainintheneck
b3a6e59f96 cmd/pin: Update pinned formula messaging
The hope is that this will be clearer and less annoying for users.

A user came to us a couple weeks ago stating that it was confusing
that the `brew upgrade` command printed an error when a pinned
formula had a new version available and didn't get upgraded.

This PR changes that message to a warning from an error. While looking
into this we found that there is another message that gets printed
when a package dependency doesn't get upgraded because it is pinned
and that got turned into a warning from a normal message. Honestly,
that should be more worrying for the user anyway; it could lead to
a program not working correctly in the worst case.

I also added a message to the `brew pin` command warning about
potential unintended behavior if a dependency gets pinned and another
package requires a newer version of it.

Lastly, I added a commented out deprecation notice for the
`brew upgrade --ignore-pinned` command since it's now the default.
2023-12-07 23:43:02 -08:00
Bo Anderson
7c20e1ef7c
Don't reinstall dependency when latest already installed 2023-11-14 17:13:34 +00:00
Bo Anderson
19f27f9a20
Store and use revision, where possible, in tab runtime dependencies.
Let's start storing `revision` and `pkg_version` for tab runtime
dependencies and use them when available.

When the `revision` is not available, use a conservative approach to
deciding whether dependencies need to be upgrade.

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2023-11-10 18:24:43 +00:00
Mike McQuaid
72ded32393
upgrade: more liberal formula upgrade changes.
Download the bottle manifests for the potential formulae we are going to
upgrade and, if they are have all their `runtime_dependencies` versions
currently met, don't try to download the bottle or upgrade the formula.
2023-09-04 22:18:55 -04:00
Mike McQuaid
8a2a16d521
WIP 2023-09-03 15:07:48 -04:00
Mike McQuaid
1d4a24d226
Make more warnings quiet with environment hints disabled.
Combined with https://github.com/Homebrew/homebrew-test-bot/pull/963
this should make `brew test-bot` output a bit quieter and less annoying.
2023-08-04 09:36:27 +01:00
Dustin Rodrigues
b776fb32de
change includecount to include_count for readability 2023-03-20 07:23:17 -04:00
Dustin Rodrigues
e5fba88035
use includecount argument in pluralize 2023-03-19 23:35:47 -04:00
Issy Long
60d93310af
rubocop: Drop "a" and "b" from Naming/MethodParameterName allowlist 2023-03-11 00:17:28 +00:00
Douglas Eichelberger
0eccc0e987 git grep -l Utils::Inflection | xargs gsed -i 's|Utils::Inflection|Utils|g' 2023-02-27 20:18:27 -08:00
Douglas Eichelberger
3da68651e5 Port more call sites 2023-02-27 20:18:08 -08:00
Douglas Eichelberger
7fb87abefd
Enable typing in Homebrew::Upgrade 2023-02-15 14:24:58 +00:00
hyuraku
5491f7b1bd share Install.print_dry_run_dependencies 2022-09-03 16:01:55 +09:00
hyuraku
66817c0c32 repair how to show formula to be installed 2022-08-17 22:14:20 +09:00
hyuraku
634fcad1b2 add dry-run option to formula#install 2022-08-16 21:01:07 +09:00
Lukas Oberhuber
d195f22522 Connecting up --debug-symbols flag
This connects the calling of dsymutil and the retention of temporary
files. Still need to connect compilation to flag.
2022-07-26 12:15:53 +01:00
rogerdpack
e360b9c6fd
cmd/upgrade: clarify why it is upgrading dependents.
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2022-02-25 15:59:48 +00:00
Bo Anderson
6e116ffbf3
Merge pull request #12484 from Bo98/core-versioned-dependent-check
upgrade: skip dependent check on core versioned formulae
2021-12-02 02:09:18 +00:00
Carlo Cabrera
ea72daf7bb
upgrade: fix undefined method error
Fixes Homebrew/discussions#2567.
2021-12-01 00:42:06 +08:00
Carlo Cabrera
b30d821a9c
Tweak warning message wording
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2021-11-29 20:42:41 +08:00
Carlo Cabrera
4b36a0eee5
upgrade: don't upgrade unbottled dependents of upgraded formulae
We upgrade dependents of upgraded formulae to make sure that an upgrade
doesn't break anything. However, this reasoning applies only when a
dependent is bottled, since attempting a source build is just as likely
to break things, if not more.

I've opted not to restrict this to, say, users only on outdated versions
of macOS in order to cleanly handle other cases where this change should
also apply: Linux, or current versions of macOS in a non-default prefix.
2021-11-27 15:51:57 +08:00
Mike McQuaid
6913c7c84e
Output environment variable hints.
Output hints for disabling automatic `brew update`, `brew cleanup` and
`brew upgrade`/`brew reinstall` of dependents. Also provide a
`HOMEBREW_NO_ENV_HINTS` to disable this messaging.
2021-11-26 13:14:10 +00:00
Bo Anderson
d47344b1e8
upgrade: skip dependent check on core versioned formulae 2021-11-26 13:05:50 +00:00
Mike McQuaid
11c5f8f05a
Improve discovery of some environment variables
There's a few bits of functionality that Homebrew has changed over the
years, makes sense as a sensible default but some people find really
annoying:

- automatically running `brew update`
- automatically running `brew cleanup`
- automatically upgrading outdated dependents
- automatically reinstalling broken dependents

For each of these: let's improve the documentation of the commands
whose behaviour is changed and the environment variables themselves.
2021-11-25 09:10:59 +00:00
Bo Anderson
9d5f4e8ed5
Fix undefined method error following CannotInstallFormulaError 2021-09-14 10:43:38 +01:00
fn ⌃ ⌥
5a94c43b3f install, upgrade: fix installation attempt check 2021-09-13 10:28:13 -07:00
Mike McQuaid
1a904af264
Merge pull request #12018 from FnControlOption/upgrade-tsort
upgrade: use topological sort to upgrade formulae
2021-09-12 19:26:22 +01:00
fn ⌃ ⌥
c0795b5029 upgrade: raise error if developer and there are cyclic dependencies 2021-09-12 07:56:37 -07:00
fn ⌃ ⌥
15e8852128 upgrade: add install_formula helper method 2021-09-10 08:39:36 -07:00
fn ⌃ ⌥
0c3afa5837 install, upgrade: run formula installer prelude before fetching 2021-09-10 06:15:55 -07:00
fn ⌃ ⌥
0c3e49092c upgrade: use topological sort to upgrade formulae 2021-09-09 13:41:50 -07:00
fn ⌃ ⌥
eec60c4086 install, upgrade: don't print message if formula already installed 2021-09-09 10:54:18 -07:00
FnControlOption
03177b5906 upgrade: revert renaming of create_formula_installer 2021-09-01 05:48:12 -07:00
EricFromCanada
c234d1ea03
upgrade: list upgradeable dependencies/migrations/cleanups on dry run 2021-08-31 12:27:14 -04:00
Mike McQuaid
3e1c8ea877
Apply suggestions from code review 2021-08-31 16:35:09 +01:00
FnControlOption
16594c5521 upgrade: fetch_formula_installer -> create_formula_installer 2021-08-31 07:08:24 -07:00