187 Commits

Author SHA1 Message Date
Bo Anderson
1168ec1feb
Reset Bootsnap after installing gems 2025-03-27 03:37:17 +00:00
Mike McQuaid
38fc1afacc
cleanup: fix handling of bottle manifest rebuilds.
We need to handle these slightly different as otherwise they can be
cleaned up incorrectly.
2025-03-25 17:48:26 +00:00
Douglas Eichelberger
39843b5d40
Resolve violations 2025-03-13 12:16:11 -07:00
Douglas Eichelberger
fcf18912fe
Inline use of attr_predicate 2025-03-02 21:36:03 -08:00
Mike McQuaid
fa8ada31b8
cleanup: improve cleanup version detection.
We're using `formula.eligible_kegs_for_cleanup` to figure out which
formula should be kept or removed based on e.g. `brew pin` status but
we didn't use this sufficiently in `brew cleanup` to avoid cleaning up
all cached files related to a pinned keg.

Instead, let's use a (cached) call to
`formula.eligible_kegs_for_cleanup` to ensure that we check all
related resources, manifests, etc. for pinned bottles rather than just
the latest version.
2025-01-23 16:04:31 +00:00
Douglas Eichelberger
a2612e23dc
Apply suggestions from code review
Co-authored-by: Kevin <apainintheneck@gmail.com>
2024-11-05 16:44:12 +00:00
Douglas Eichelberger
521c463e36
Manually resolve Style/SafeNavigationChainLength violations 2024-11-05 16:44:12 +00:00
Douglas Eichelberger
2d16333bbc Replace removable constants with overridable methods 2024-10-07 18:33:03 -07:00
Mike McQuaid
94416e82f0
Add new odeprecated, odisabled, remove disabled code.
Prepare the usual deprecation cycle for Homebrew 4.4.0.
2024-09-24 10:15:34 +01:00
Bo Anderson
99ce3094e9
Invalidate Bootsnap cache on Gemfile.lock changes 2024-09-04 04:05:10 +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
Mike McQuaid
e3a1a9dccf
Improve locking UX
My experience recently playing around with our locking behaviour is
that, while mostly seamless and not seen by users, it's leaks
implementation details a bit too heavily.

As a result, the following improvements are in this commit:
- Ensure that, whenever possible, we tell the user the actual command
  that is holding a given lock instead of the lock name (an internal
  implementation detail)
- Make the locking error output a little more consistent and user
  friendly
- Add a `DownloadLock` class to simplify locking downloads
- Add a `HOMEBREW_LOCK_CONTEXT` variable to allow adding additional
  context for logging error messages
- Lock paths and leave deciding how this translates to lock names up
  to the locking code itself
- Lock the Cellar/Caskroom paths explicitly rather than implicitly

Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2024-07-30 17:51:02 +01:00
Bo Anderson
1962a37e94
version: enable strict typing 2024-06-11 23:03:53 +01:00
Mike McQuaid
ba6ec7066b
Revert "Revert "Enable HOMEBREW_AUTOREMOVE by autoremove_default"" 2024-05-26 15:39:45 +01:00
Carlo Cabrera
ffd6c1f5c3
Revert "Enable HOMEBREW_AUTOREMOVE by autoremove_default"
`autoremove` is destructive, and it can be difficult for users to
recover from it occuring when they weren't expecting it.

Fixes #17363
Fixes Homebrew/discussions#5395

This reverts commit 3d114161b3c3f1a95b94e8530f5bc45bb44bbbd9.
This reverts commit efb14a0ec264c4ef408dbbd5330905dd230e979c.
2024-05-25 23:19:42 +08:00
Mike McQuaid
9586473f77
brew style --fix 2024-05-17 14:25:54 +09:00
apainintheneck
efb14a0ec2 fix no autoremove suggestion typo
This suggests setting an environment variable that is different
than the one we end up checking so I've updated the warning so
now things match. If the goal was to have the name in the warning,
the environment variable checking logic could be updated. I have
no personal preference.

```console
$ brew irb
==> Interactive Homebrew Shell
Example commands available with: `brew irb --examples`
brew(main):001:0> ENV["HOMEBREW_NO_AUTO_REMOVE"] = "1"
=> "1"
brew(main):002:0> Homebrew::EnvConfig.no_autoremove?
=> false
brew(main):003:0> ENV["HOMEBREW_NO_AUTOREMOVE"] = "1"
=> "1"
brew(main):004:0> Homebrew::EnvConfig.no_autoremove?
=> true
```
2024-05-09 20:14:16 -07:00
Mike McQuaid
3d114161b3
Enable HOMEBREW_AUTOREMOVE by autoremove_default
Enabled `HOMEBREW_AUTOREMOVE` by default, and added
`HOMEBREW_NO_AUTOREMOVE` to disable it.

Co-authored-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2024-05-09 13:47:52 +01:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02: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
Douglas Eichelberger
c59d9fa833 Prefer numbered block params over proc conversion, cont'd 2024-04-08 09:47:27 -07:00
Bo Anderson
bc7c274e17
cleanup: handle some edge cases 2024-04-01 14:47:52 +01:00
Mike McQuaid
87bf4af3fc
Merge pull request #16872 from cho-m/cleanup-cask-broken-symlinks
cleanup: remove broken symlink for uninstalled migrated Casks
2024-03-31 19:30:02 +01:00
Bo Anderson
58de9e0dda
cleanup: better support bottle manifests 2024-03-30 03:30:58 +00:00
Bo Anderson
92d44912e2
cleanup: better handle version_scheme scenarios 2024-03-30 03:30:31 +00:00
Michael Cho
3ddc196f11
cleanup: remove broken symlink for uninstalled migrated Casks
Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-21 17:52:48 -04: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
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Markus Reiter
e0743a1436
Reapply "Refactor Formulary::loader_for."
This reverts commit 24683525cb5abf3cc79a9e0e268fa6efd0af558b.
2024-02-22 18:24:57 +01:00
Mike McQuaid
24683525cb
Revert "Refactor Formulary::loader_for." 2024-02-16 13:41:54 +00:00
Markus Reiter
b717f5d954
Remove unused TapFormulaWithOldnameAmbiguityError. 2024-02-14 22:56:25 +01:00
Issy Long
0e27dc2564
Fix RuboCop Style/ArrayIntersect offenses 2024-01-18 14:11:43 +00:00
Douglas Eichelberger
ffd761d2e9 Create dedicated Attrable mixin for attr_ methods 2023-12-28 11:46:27 -08:00
Bo Anderson
489879ff72
Enable Ruby 3 for all users 2023-11-29 15:30:17 +00:00
Branch Vincent
e58ed46195
formula: add PIP_CACHE_DIR to build env 2023-11-22 13:53:05 -08:00
Bo Anderson
5c819100fe
cleanup: smarter gem handling 2023-11-07 22:28:03 +00:00
Bo Anderson
4ec450823c
Portable Ruby 3.1.4 (opt-in beta) 2023-10-27 15:58:43 +01:00
Carlo Cabrera
43b6d79a4c
cleanup: handle GitHub Actions artifacts
Implemented based on feedback from #15440.
2023-05-17 21:11:16 +08:00
Markus Reiter
a3231a03fa
Implement cask renames. 2023-05-12 21:17:30 +02:00
Bo Anderson
0daa4d98cf
cleanup: fix version error for cache items without a version 2023-05-11 13:44:26 +01:00
Bo Anderson
44f058edb5
Refactor formula, cask and Ruby source downloads to use shared code 2023-04-27 23:23:07 +01:00
Douglas Eichelberger
08af78a2a5 brew style --fix 2023-04-25 09:26:24 -07:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Douglas Eichelberger
a7b80532bf Code review changes 2023-03-27 09:28:27 -07:00
Douglas Eichelberger
eaeceda31e Enable typing in Homebrew::Cleanup 2023-03-25 13:16:11 -07:00
Issy Long
e9d994622e
rubocop: Drop "f" from Naming/MethodParameterName allowlist
- This either stands for "file" but more often than not "formula".
2023-03-11 00:17:27 +00:00
Douglas Eichelberger
f9f73f3ef6 Tidy up 2023-02-27 21:42:47 -08:00
Douglas Eichelberger
1ab278f74c Fix style/type violations 2023-02-27 20:34:07 -08: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