402 Commits

Author SHA1 Message Date
Mike McQuaid
07091cfbea
Simplify pluralisation of common words
Formulae, dependencies, tries are all used in multiple places so let's
simplify them
2025-09-12 09:02:43 +01:00
Mike McQuaid
a31fb2a6c2
Add additional brew contributions functionality.
- Add an `--organisation` flag to search a specific organisation.
- Wait for the GitHub API rate limit to reset before automatically
  retrying.
- Use (much) fewer API calls by using organisation-wide API PR searches
  rather than per-repository. This makes the rate limit easier to avoid
  and also makes things much faster (with the trade-off of showing a max
  PR count per-user rather than per-repository).
- Improve output to clarify when the max PR/commit count is reached.
- Move more logic and add more Sorbet signatures to the `GitHub` and
  `Utils::Git` modules.
- Rename a few GitHub API methods.
- Remove a lot of (now unused) `GitHub` module methods.
- Add, use a `Tap#full_repository` method.
- Add `formula-analytics` as a deprecated tap.
2025-09-10 15:32:06 +01:00
Ruoyu Zhong
78227dc924
tap: actively check repo visibility
We shouldn't assume that the visibility of a tap keeps unchanged by
storing it into `TapConfig`. Instead, let's actively check that to avoid
e.g. collecting unwanted analytics.

Also, speed up the check for known official public taps so that we don't
waste our GitHub API token limit in CI.
2025-08-31 22:59:21 +08:00
Mike McQuaid
a1f112f3fe
Move o* output methods to Utils::Output
This reduces the surface area of our `Kernel` monkeypatch and removes
the need to `include Kernel` in a bunch of modules.

While we're here, also move `Kernel#require?` to `Homebrew` and fully
scope the calls to it.
2025-08-20 19:20:19 +01:00
Bevan Kay
97b1683466
cask: replace unsigned deprecation reason with fails_gatekeeper_check 2025-08-18 18:04:57 +10:00
Patrick Linnane
2605529a90
brew style --fix 2025-08-13 12:23:12 -07:00
copilot-swe-agent[bot]
9328a55c54
Fix overzealous /usr/local prefix replacement
Co-authored-by: MikeMcQuaid <125011+MikeMcQuaid@users.noreply.github.com>
2025-08-13 16:22:09 +01:00
Rylan Polster
0f9fb4f29a
Use API helper methods 2025-08-12 17:04:15 -04:00
Eric Knibbe
626b6aca2d
RubyDoc output fixes 2025-08-05 17:13:42 -04:00
Douglas Eichelberger
40c58a883d
Enable strict typing in Tap 2025-08-04 13:11:15 -07:00
Eric Knibbe
6255263b51
output: express environment variables consistently 2025-08-04 09:50:06 -04:00
Mike McQuaid
e3c3f5a356
Deprecate/disable/remove code for Homebrew 4.6
The next minor release will be Homebrew 4.6.0 so let's do the usual
deprecation/disable/remove code cycle.
2025-07-31 12:13:01 +01:00
Bevan Kay
5a04b55e56
tap: continue to autobump deprecated unsigned casks 2025-07-24 10:10:01 +10:00
Mike McQuaid
36c7f4950c
Optionally parallelise API file downloads
This assumes that all should be downloaded (at least once) on `brew`
commands being run.

Requires a certain amount of cleanup and refactoring around our API
handling and Tap migration methods (which were both weirdly placed and
in some cases broken).

Behaviour without `HOMEBREW_DOWNLOAD_CONCURRENCY` set should
be unchanged.
2025-07-18 15:01:34 +01:00
botantony
d0345513e2
tap: rely on new autobump list
Signed-off-by: botantony <antonsm21@gmail.com>
2025-06-18 16:16:08 +02:00
Mike McQuaid
dc71b7c8f6
Cleanup extend/ directory usage.
- move some things out of `extend` that don't really fit there e.g.
  `Module`s that are included but not doing any
  overriding/monkeypatching
- move some code into `extend/os` to fix all remaining
  `rubocop:todo Homebrew/MoveToExtendOS`s
- remove some unneeded `bundle` skipper code that doesn't really make
  sense given our current bottling strategy
- extract some `Pathname` extensions to `extend/pathname` for separate
  files
- move a `ENV` `Kernel` extension into `kernel.rb`
- `odeprecate` a seemingly unused backwards compatibility method
- move `readline_nonblock` from a monkeypatch to a
  `ReadlineNonblock.read` method as its only used in one place
- fix up a link in documentation
2025-06-09 19:06:16 +01:00
Kristján Oddsson
972414cec7 add a T.must after fetching tap 2025-05-27 16:55:00 +00:00
Kristján Oddsson
7476f09672 format 2025-05-27 16:43:54 +00:00
Kristján Oddsson
0480411c6f
use conditional assignment operator
Co-authored-by: Bo Anderson <mail@boanderson.me>
2025-05-27 16:35:50 +00:00
Kristján Oddsson
24d9524bbd remove T.must to avoid full fetch 2025-05-27 16:01:35 +00:00
Kristján Oddsson
9e05995299 move git fetch before getting origin_branch_name 2025-05-27 14:54:57 +00:00
botantony
56d91aaf28
tap: get autobump list from autobump.txt file
Signed-off-by: botantony <antonsm21@gmail.com>
2025-05-09 15:32:30 +02:00
botantony
a043e7bbf8
tap: fix autobump logic for unofficial taps
Signed-off-by: botantony <antonsm21@gmail.com>
2025-04-29 22:10:33 +02:00
botantony
11652a7a62 tap: exclude deprecated and disabled packages from autobump list
Signed-off-by: botantony <antonsm21@gmail.com>
2025-04-29 18:04:59 +02:00
botantony
a10b635fe9 no_autobump!: suggestions from contributors and docs
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Signed-off-by: botantony <antonsm21@gmail.com>
2025-04-29 18:04:59 +02:00
botantony
ad66e0c418 tap: get autobump list from formula/cask API
Signed-off-by: botantony <antonsm21@gmail.com>
2025-04-29 18:04:59 +02:00
Mike McQuaid
c9a7b62b1d
Homebrew 4.5 deprecations/disables/removals
The usual cycle of deprecating, disabling, and removing things in
Homebrew major/minor releases.
2025-04-22 17:15:23 +01:00
apainintheneck
f916f27d82 remove all references to JSON v3
The logic has now been removed in previous commits. This just
removes some references to the `HOMEBREW_INTERNAL_JSON_V3`
environment variable along with reverting the changes to the
`Cachable` class that were originally added in
bd72ec812c3ed656dfcf8e24f77df142a1fe9cc1.
2025-02-06 21:04:08 -08:00
apainintheneck
839198d21e Remove JSON v3 formula logic 2025-02-05 23:36:57 -08:00
apainintheneck
042d6cc97e Remove JSON v3 cask logic 2025-02-05 23:32:32 -08:00
Issy Long
6ada9a9665
Add clarifying comments to rubocop:disables
- Needed for PR 18842 that adds a `DisableComment` RuboCop to ensure that all RuboCop disables have comments.
2025-01-12 16:59:07 +00:00
Mike McQuaid
ffd9d686cb
tap: tweak Ruby style for readability. 2024-11-06 09:11:33 +00:00
Bevan Kay
b2dff27f0c
tap: allow an array of values for an audit exception 2024-11-06 11:00:33 +11:00
Douglas Eichelberger
521c463e36
Manually resolve Style/SafeNavigationChainLength violations 2024-11-05 16:44:12 +00:00
Dawid Dziurla
02cef968a2
dev-cmd/bump-formula-pr: always use full git repo as tap remote 2024-10-15 10:20:58 +02:00
Patrick Linnane
c2e2b23c50
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-10-02 10:03:12 -07:00
Mike McQuaid
54d484d428
Merge pull request #18464 from benknoble/bk/tap-info-commit
feat(tap-info): display Git information about non-Core/non-API taps
2024-10-01 09:25:44 +01:00
D. Ben Knoble
3429e74d7e feat(tap-info): display Git information about non-Core/non-API taps
Copy and tweak code from Library/Homebrew/system_config.rb:110 to commit
and date information. This information can be useful when debugging
formulae in custom taps to ensure the tap has been correctly updated
recently or to suss out important differences from one version of a tap
to another.

This removes the need to ask users to run something like

    git -C $(brew --repository)/Library/Taps/<tap> show -s --decorate

Close https://github.com/Homebrew/brew/issues/18381
2024-09-30 11:27:35 -04:00
Mike McQuaid
5c8ff7788f
tap: add repository key.
Follow up from #18445 that may allow us to
deprecate the old name in future.
2024-09-30 07:52:02 +01:00
Carlo Cabrera
4ab8f485d5
tap: restore old repo key
Fixes #18444
2024-09-28 02:02:09 +08: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
Mike McQuaid
638a3dc3a3
Merge pull request #18167 from Homebrew/fix-cask-formula-file-validation-v2 2024-08-29 08:50:44 +01:00
apainintheneck
60b8878f21 tap: share components of formula and cask file path regexes
The goal here is to make things easier to read by better
describing how different regexes are similar to each other.
2024-08-28 19:12:02 -07:00
apainintheneck
62a4734c90 tap: add tests for formula_file? and cask_file? 2024-08-27 00:36:23 -07:00
apainintheneck
2d6d080f32 Simplify globbing for casks and formula in taps
This is yet another approach to f3a5a3c449cf004aee662966e6c8dd2ebe122c0f
which got merged in over the weekend. It is much simpler than what we've
got now with almost exactly the same performance characteristics. A great
combination of maintability and performance.

```console
$ hyperfine --parameter-list branch master,speed-up-loading-cask-and-formula-file-names_v4 --warmup 5 --setup 'git switch {branch}' 'brew cat gimp'
Benchmark 1: brew cat gimp (branch = master)
  Time (mean ± σ):      1.459 s ±  0.012 s    [User: 0.892 s, System: 0.536 s]
  Range (min … max):    1.448 s …  1.483 s    10 runs

Benchmark 2: brew cat gimp (branch = speed-up-loading-cask-and-formula-file-names_v4)
  Time (mean ± σ):      1.456 s ±  0.009 s    [User: 0.889 s, System: 0.536 s]
  Range (min … max):    1.445 s …  1.468 s    10 runs

Summary
  brew cat gimp (branch = speed-up-loading-cask-and-formula-file-names_v4) ran
    1.00 ± 0.01 times faster than brew cat gimp (branch = master)
```
2024-08-26 23:22:15 -07:00
apainintheneck
cd430c4d34 cmd/update-report: improve formula file validation
Currently, ruby files that are not in the Cask directory are
considered to be formulae if a Formula or HomebrewFormula directory
doesn't exist  which doesn't make sense. We know that these should
only be in a few directories so we can check for that explicitly.

Beyond that the `Tap#cask_file?` and `Tap.formula_file?` methods
were only used inside update-report so it doesn't make sense to
turn them into pathnames and expand things when we know that
each string will be a relative path from a tap that we can just
check with a regex.

This change will stop other tap changes like new commands or
changes to other directories like lib/ from showing up as new formulae.

I tried opening a PR for this a long time ago but I got busy
with other things and it got closed by the stale bot.

- https://github.com/Homebrew/brew/pull/15489
2024-08-25 18:32:04 -07:00
apainintheneck
f3a5a3c449 Speed up the Tap#formula_files and Tap#cask_files methods
These are slow because of some Pathname related reasons so it's been
changed up to use `Dir.glob` instead and that makes a large difference.

```
$ hyperfine --parameter-list branch master,speed-up-loading-cask-and-formula-file-names,speed-up-loading-cask-and-formula-file-names_v2 --warmup 5 --setup 'git switch {branch}' 'brew cat gimp'
Benchmark 1: brew cat gimp (branch = master)
  Time (mean ± σ):      2.150 s ±  0.014 s    [User: 1.369 s, System: 0.745 s]
  Range (min … max):    2.126 s …  2.174 s    10 runs

Benchmark 2: brew cat gimp (branch = speed-up-loading-cask-and-formula-file-names)
  Time (mean ± σ):      1.814 s ±  0.012 s    [User: 1.068 s, System: 0.711 s]
  Range (min … max):    1.797 s …  1.840 s    10 runs

Benchmark 3: brew cat gimp (branch = speed-up-loading-cask-and-formula-file-names_v2)
  Time (mean ± σ):      1.489 s ±  0.009 s    [User: 0.905 s, System: 0.550 s]
  Range (min … max):    1.478 s …  1.503 s    10 runs

Summary
  brew cat gimp (branch = speed-up-loading-cask-and-formula-file-names_v2) ran
    1.22 ± 0.01 times faster than brew cat gimp (branch = speed-up-loading-cask-and-formula-file-names)
    1.44 ± 0.01 times faster than brew cat gimp (branch = master)
```
2024-08-25 15:34:10 -07:00
apainintheneck
fff4e0a8f0 Speed up Tap#cask_files_by_name
This is most noticeable when you have a large local tap and it ends
up taking a nontrivial percentage of the overall run time for simple
commands like `brew info gimp`. The improvement here is to just
create paths later on in the loop which copies what we already do
for formulae.

See b1ddb05

```console
$ hyperfine --parameter-list branch master,speed-up-cask-files-by-name --warmup 5 --setup 'git switch {branch}' 'brew info gimp'
Benchmark 1: brew info gimp (branch = master)
  Time (mean ± σ):      2.737 s ±  0.010 s    [User: 1.958 s, System: 0.732 s]
  Range (min … max):    2.720 s …  2.748 s    10 runs

Benchmark 2: brew info gimp (branch = speed-up-cask-files-by-name)
  Time (mean ± σ):      2.597 s ±  0.017 s    [User: 1.828 s, System: 0.724 s]
  Range (min … max):    2.577 s …  2.624 s    10 runs

Summary
  brew info gimp (branch = speed-up-cask-files-by-name) ran
    1.05 ± 0.01 times faster than brew info gimp (branch = master)
```
2024-08-24 10:15:09 -07: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
apainintheneck
a3e917afe1 Refactor method to remove extra tap requires
We were selectively requiring the tap.rb file in a few places for
performance reasons. The main method we were referencing was the
`Tap.cmd_directories` method which uses `Pathname` and the `TAP_DIRECTORY`
constant internally. `Tap.cmd_directories` is mostly used in the `Commands`
module and that is loaded very early on in the program so it made sense
to move that command to that module. To facilitate that I moved the
`TAP_DIRECTORY` constant to the top-level and renamed it to
`HOMEBREW_TAP_DIRECTORY`. It now lies in the tap_constants.rb file.

A nice bonus of this refactor is that it speeds up loading external
commands since the tap.rb file is no longer required by default in
those cases.
2024-08-10 13:49:10 -07:00