402 Commits

Author SHA1 Message Date
Kevin Montag
74a84a0d12 Fix missing requires for tap-info command
Previously, running `brew tap-info --installed --json` in a github
actions linux runner would throw:

```
Error: uninitialized constant Homebrew::API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/tap.rb:1359:in `formula_names'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/tap.rb:868:in `to_hash'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/tap-info.rb:87:in `map'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/tap-info.rb:87:in `print_tap_json'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/tap-info.rb:37:in `run'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:95:in `<main>'
```

After the setup steps:
```
    steps:
      - name: Set up Homebrew
        id: set-up-homebrew
        uses: Homebrew/actions/setup-homebrew@master
        with:
          token: ${{ github.token }}

      - name: Cache Homebrew Bundler RubyGems
        id: cache
        uses: actions/cache@v3
        with:
          path: ${{ steps.set-up-homebrew.outputs.gems-path }}
          key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
          restore-keys: ${{ runner.os }}-rubygems-

      - name: Install Homebrew Bundler RubyGems
        if: steps.cache.outputs.cache-hit != 'true'
        run: brew install-bundler-gems
```
2024-07-16 21:19:37 +02:00
Mike McQuaid
c5dbd3ca24
Rearrange requires
This improves the load time of most brew commands. For an example of
one of the simplest commands this speeds up:

Without Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     525.0 ms ±  35.8 ms    [User: 229.9 ms, System: 113.1 ms]
  Range (min … max):   465.3 ms … 576.6 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     383.3 ms ±  25.1 ms    [User: 133.0 ms, System: 72.1 ms]
  Range (min … max):   353.0 ms … 443.6 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.37 ± 0.13 times faster than git checkout master; brew help
```

With Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     386.0 ms ±  30.9 ms    [User: 130.2 ms, System: 93.8 ms]
  Range (min … max):   359.5 ms … 469.3 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     330.2 ms ±  32.4 ms    [User: 93.4 ms, System: 73.0 ms]
  Range (min … max):   302.9 ms … 413.9 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.17 ± 0.15 times faster than git checkout master; brew help
```
2024-07-14 08:49:39 -04:00
Mike McQuaid
c13700af00
Use repository consistently instead of repo
The documentation linting job doesn't like `repo` so let's fix this
globally rather than naming it differently in documentation and code.
2024-06-10 09:31:53 +01:00
Bevan Kay
1b286befed
tap: fix sharding for font-* casks 2024-05-16 11:29:59 +10:00
Patrick Linnane
50b65aa891
tap: adjust font cask path
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-05-12 08:58:35 -07:00
Justin Krehel
836d819c43
Support font sharding in Homebrew/cask 2024-05-10 11:48:56 -04:00
apainintheneck
5005916093 tap: update core tap --force messaging
Per this suggestion: https://github.com/Homebrew/brew/pull/17227#discussion_r1590630520
2024-05-07 20:07:27 -07:00
Mike McQuaid
310c75fab1
Merge pull request #17233 from Homebrew/deprecate_disable_remove
Homebrew 4.3.0 deprecation/disable/removals.
2024-05-07 12:30:03 +01:00
Mike McQuaid
222fe8ef0b
Homebrew 4.3.0 deprecation/disable/removals.
The usual pass of deprecating/disabling/removing code for the next
minor Homebrew release.
2024-05-07 12:18:04 +01:00
Mike McQuaid
ab845ef22e
tap: allow/forbid installation of taps from environment variables.
Extend the allow/forbid of taps during formula installation to allow or
forbid the installation of taps themselves based on the values of the
`HOMEBREW_ALLOWED_TAPS` and `HOMEBREW_FORBIDDEN_TAPS` environment
variables.

Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2024-05-07 10:52:19 +01:00
Mike McQuaid
fc13eb83c8
Merge pull request #17213 from Homebrew/allowed-taps
env_config: add `HOMEBREW_ALLOWED_TAPS`
2024-05-07 08:47:57 +01:00
Carlo Cabrera
be29afa5f7
Fix brew style 2024-05-06 15:26:29 +01:00
Carlo Cabrera
078a328e8e
tap: avoid class vars
Avoiding them also allows us to write proper tests.
2024-05-06 15:05:06 +01:00
apainintheneck
373b7d1dbb tap: tweak core tap warning
Most users don't need the core taps to be installed locally but the
current message doesn't communicate that they're sometimes necessary
for local development. This just tweaks the message to be more
informative.

```console
$ brew tap homebrew/cask
Error: Tapping homebrew/cask is no longer typically necessary.
Add --force if you are sure you need it for local development.
```
2024-05-04 09:59:47 -07:00
Carlo Cabrera
5222c9e32d
Improve error message for allowed and forbidden taps 2024-05-03 16:15:37 +01:00
Carlo Cabrera
7c9e8927e9
tap: memoize allowed and forbidden taps 2024-05-03 16:08:22 +01:00
Carlo Cabrera
6663516e79
tap: define #allowed_by_env? 2024-05-03 14:50:47 +01:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
f7361c8d29
Remove disabled extend. 2024-04-30 11:01:12 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Markus Reiter
c76170a456
Hide #to_s in docs. 2024-04-26 14:04:55 +02:00
Markus Reiter
732bd52c72
Fix typo.
Co-authored-by: Eric Knibbe <enk3@outlook.com>
2024-04-23 02:07:42 +02:00
Markus Reiter
4b432c7ea4
Explicitly mark non-private APIs. 2024-04-22 21:16:49 +02:00
Mike McQuaid
56fc9a1fb2
Merge pull request #17047 from Homebrew/block-params
Prefer numbered block params over proc conversion, cont'd
2024-04-08 19:13:01 +01:00
Douglas Eichelberger
c59d9fa833 Prefer numbered block params over proc conversion, cont'd 2024-04-08 09:47:27 -07:00
Mike McQuaid
1474806527
Add more HOMEBREW_FORBIDDEN_* configuration
We already had `HOMEBREW_FORBIDDEN_LICENSES` but this commit adds
`HOMEBREW_FORBIDDEN_CASKS`, `HOMEBREW_FORBIDDEN_FORMULAE` and
`HOMEBREW_FORBIDDEN_TAPS` for also forbidding those.

Relatedly, add `HOMEBREW_FORBIDDEN_OWNER` and
`HOMEBREW_FORBIDDEN_OWNER_CONTACT` to allow customising these
messages.

There were no existing tests for `HOMEBREW_FORBIDDEN_LICENSES` so have
added more tests for all of these checks.

Co-authored-by: Bo Anderson <mail@boanderson.me>
2024-04-08 16:38:32 +01:00
Kevin
58b84c3979
Merge pull request #16867 from Homebrew/stop-using-full-name-as-key-in-cask-json-v3
cask: always return short cask tokens from core cask tap
2024-03-12 22:51:10 -07:00
Mike McQuaid
b1990ed4b6
Merge pull request #16863 from apainintheneck/memoize-installed-tap-loading-v2
Memoize installed tap loading v2
2024-03-12 08:36:09 +00:00
apainintheneck
6e0e78cadd tap: CoreCaskTap#cask_tokens should always return short names
This seems to be a bug with how we handle name shortening for the
core cask tap. The core tap always returns short formula names
and returning long names from the core cask tap when not using
the API leads to unexpected behavior.

Specifically this can trick the `brew untap` command into thinking
that there aren't any installed casks in the core cask tap and that
it can be removed even when that is not the case.

One risk here is that the full names were used when caching
descriptions so descriptions could be out of date for people in
the short term though hopefully that's not the end of the world.
2024-03-09 18:59:31 -08:00
apainintheneck
08442734ab s/Tap.reverse_tap_migrations_renames/Tap.tap_migration_oldnames/ 2024-03-09 10:27:22 -08:00
apainintheneck
d4a273443c tap: add #reverse_tap_migrations_renames to speed things up
This gets used by `Tap.reverse_tap_migrations_renames` and reduces
the amount of information that needs to be calculated on the fly
every time.
2024-03-09 10:25:47 -08:00
apainintheneck
3834ef1b73 tap: cache more things at the Tap level
I added two new methods to cache both installed and all taps.
All taps includes core taps no matter if they're installed locally
since they're always provided by the API anyway.

This makes it easier to cache `Tap.each` while making the code
easier to reason about. It also will be useful because we'll
be able to avoid the `Tap.select(&:installed?` pattern that has
recently invaded the codebase.

Note: I also stopped clearing all tap instance caches before
tests. Running `Tap.each` would cache existing taps which would
lead to unexpected behavior since the only existing tap before
each test is the core tap. This is the only tap whose directory
is not cleaned up between tests so we just clear it's cache directly.
We also now clear all tap instances after tests as well regardless
of whether the API was used that time.
2024-03-08 23:22:00 -08:00
Mike McQuaid
9ac31827a0
Various brew update behaviour improvements
- Output a message every time auto-update is run rather than a 3 second
  timer. This makes it more obvious that Homebrew isn't just sitting
  doing nothing for 2.9 seconds.
- Output a message when running `brew update` so Homebrew doesn't just
  sit there silently doing nothing.
- Update all taps when `brew update` is run, not just those hosted on
  GitHub. This makes it more obvious that people don't need to explictly
  run `brew update` "just in case".
- As a result of this, remove `brew tap --force-auto-update` as it's no
  longer necessary.
2024-03-08 16:21:09 +00:00
Mike McQuaid
b70884a474
Merge pull request #16848 from Homebrew/rubocop_default_hash_syntax
rubocop: default hash syntax.
2024-03-08 07:55:33 +00:00
apainintheneck
e0cea903ec s/to_api_hash/to_internal_api_hash/ 2024-03-07 20:29:58 -08:00
apainintheneck
12d5a40262 dev-cmd/generate-cask-api: start generating cask internal JSON v3
This adds a new file to the output of `brew generate-cask-api` which
represents the new internal JSON v3 file. It involves removing
a bunch of unneeded hash keys while removing blank ones as well.

I've made some slight changes to the cask loader as well but more
might be necessary before this starts loading things correctly.
The full loader code will be added in a separate PR.
2024-03-07 20:29:58 -08:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Mike McQuaid
3654c1ad2c
Merge pull request #16844 from reitermarkus/tap-clear-all-caches
Actually clear all tap caches.
2024-03-07 15:36:25 +00:00
Markus Reiter
47ff0b76c8
Actually clear all tap caches. 2024-03-07 15:43:16 +01:00
Markus Reiter
be9c0b8787
Simplify TapConfig. 2024-03-07 15:31:37 +01:00
Michael Cho
12d1e56ff5
dev-cmd/bump: skip autobump formulae & casks
Instead output a message that corresponding formula/cask is on the
autobump list. This avoids deferring the information to the error
message within `bump-{formula,cask}-pr`.

Signed-off-by: Michael Cho <michael@michaelcho.dev>
2024-03-06 12:34:29 -05:00
Mike McQuaid
3ea74ea417
Merge pull request #16835 from reitermarkus/tap-config-private
Don't store tap config when value is unknown.
2024-03-06 15:33:54 +00:00
Mike McQuaid
026ca68c5c
Merge pull request #16834 from reitermarkus/tap-new-private
Make `Tap::new` private.
2024-03-06 15:33:25 +00:00
Markus Reiter
c7f4e006f4
Don't store tap config when value is unknown. 2024-03-06 15:18:52 +01:00
Markus Reiter
e3a102efd4
Make Tap::new private. 2024-03-06 15:10:14 +01:00
Markus Reiter
a851bb86ef
Add type signature for Tap::fetch. 2024-03-06 14:30:17 +01:00
Kevin
a86094d794
Merge pull request #16808 from reitermarkus/tap-sig-alias-table
Simplify `Tap#alias_table`.
2024-03-04 21:33:07 -08:00
Mike McQuaid
a9f655b515
Merge pull request #16811 from reitermarkus/tapconfig-sig
Add type signatures for `TapConfig`.
2024-03-04 16:27:15 +00:00
Markus Reiter
00d69284e4
Add type signatures for TapConfig. 2024-03-04 17:14:02 +01:00