86 Commits

Author SHA1 Message Date
Mike McQuaid
7345607ca0
a*.rb: move to strict Sorbet sigil.
Co-authored-by: Rylan Polster <rslpolster@gmail.com>
2025-06-17 08:18:33 +01:00
Mike McQuaid
9ac306e464
Remove alias generic_* definitions in favour of using super
This is the pattern we've been adopting for a while and it's a bit
cleaner. Let's remove all of the existing usage of the existing pattern
to avoid confusion when adopting the new one.
2025-06-16 08:10:08 +00:00
Mike McQuaid
af997ea2ad
Hide main branches from brew tap-info and brew info
These are basically as "default" as `master` now so we can hide them.
2025-06-13 12:09:02 +01:00
Adrian Ho
6eb2030b22 system_config: print brew branch 2024-11-25 23:06:40 +08: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
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
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
apainintheneck
857ab132a2 cmd/config: limit tap info output
We really only need to see info that is surprising or out of the norm.
For that reason, we can skip showing the tap remote and the tap branch
if they are what we expect them to be.
2023-12-22 10:39:29 -08:00
apainintheneck
536b37c766 cmd/config: Add core cask tap to output
This information is occasionally useful when debugging so we should
include it by default to make our lives easier.
2023-12-21 22:54:38 -08:00
Bo Anderson
688d87e839
Remove Ruby 2.6 & macOS system Ruby support code 2023-12-12 03:44:31 +00:00
Mike McQuaid
b7114651ac
utils/curl: include or use explicitly.
Include or use `Utils::Curl` explicitly everywhere it is used.
2023-09-04 22:17:57 -04:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Douglas Eichelberger
b90897e280 Create git_repo attr 2023-04-15 19:35:13 -07:00
Douglas Eichelberger
8307255ce8 Update call sites 2023-04-15 19:35:13 -07:00
Douglas Eichelberger
429f23dcc6 Create GitRepoPath 2023-04-15 19:35:12 -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
Mike McQuaid
c209c0403d
Fix references to formula.json and cask.json
These would be stranded after `formula.jws.json`.
2023-02-24 16:46:15 +00:00
Rylan Polster
672b8c036d
Fix error when showing brew config JSON update time 2023-02-05 16:07:00 +01:00
Mike McQuaid
fd18c7b0ac
Tweak cask-source API handling
- Use raw.githubusercontent.com to download cask source rather than
  formulae.brew.sh. This allows us to remove these files
- output the tap's current `HEAD` for both formulae and cask JSON
- use this `HEAD` for the cask-source API to get the exact file on
  raw.githubusercontent.com rather than just whatever is newest (which
  is what the previous API did)
- set the `Tap` correctly when creating a `Cask` from the API
- if the `formula.json` file exists: print its modified time include
  `brew config`
- memoize `tap.git_head` as we'll be calling it a lot in the same
  process with the same value
2023-01-26 17:36:40 +00:00
Mike McQuaid
1b75348ed4
Revert "show/check Homebrew branch" 2023-01-18 13:59:58 +00:00
Adrian Ho
c0331c9142 show/check Homebrew branch
Because anyone can forget they're on a different branch, and wonder
why `brew update` isn't pulling in the latest changes (https://github.com/orgs/Homebrew/discussions/4105#discussioncomment-4658869).
2023-01-12 18:20:47 +08:00
Carlo Cabrera
25fe428ed2
system_config: fix clang version output on Linux
If you have Homebrew LLVM installed, `brew config` will show

    Clang: 12.0.1 build (parse error)

because Homebrew LLVM does not give a build number. Some installations
from the system package manager do have this information, so let's show
it if it's available but skip complaining if not.

I've kept the original code for macOS because we always expect Apple's
build number to show there.
2021-10-07 11:24:20 +08:00
Carlo Cabrera
7dabb465b3
system_config: don't print path to curl shim
See discussion at #12191.
2021-10-06 23:58:04 +08:00
Bo Anderson
a06d136d2c
Move Sorbet gems into an optional group 2021-06-11 08:10:30 +01:00
Bo Anderson
8ff7b58cba system_config: remove describe_java 2021-02-09 20:58:30 +00:00
Markus Reiter
da9289eff0 Add more type signatures. 2020-11-13 12:26:36 +01:00
Markus Reiter
61b79318ed Move include Kernel into .rbi files again and split up existing .rbi files. 2020-10-10 19:10:58 +02:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Maxim Belkin
2c5eec509b system_config.rb: refactor code into worker functions
Break down `dump_verbose_config` function into "worker" functions that
display information for specific categories:

- `core_tap_config` for Core tap info
- `homebrew_config` for Homebrew/brew info
- `homebrew_env_config` for environment-related information
- `host_software_config` for Host software

Also, factor out code related to Clang into `describe_clang` function,
so that we can do:

```
f.puts "Clang: #{describe_clang}"
```
2020-09-04 18:27:12 +00:00
Mike McQuaid
8b97c27c21 brew style manual fixes 2020-09-01 14:26:45 +01:00
Markus Reiter
3118fedab9 Refactor and document Git. 2020-08-23 06:40:07 +02:00
Markus Reiter
e2c9e6d3c2 Refactor and document SystemConfig. 2020-08-23 04:15:35 +02:00
Bo Anderson
30a8df0f91 os/mac/system_config: simplify JVM version parsing 2020-08-11 18:51:36 +01:00
Dustin Rodrigues
ad29ee4550 config: include core branch in output 2020-08-02 00:09:52 -04:00
Mike McQuaid
aa81982aba
brew style --fix 2020-06-02 09:49:23 +01:00
Mike McQuaid
3381cbf5c7
Use Homebrew::EnvConfig. 2020-04-07 09:58:26 +01:00
Mike McQuaid
5f9c98176c
system_config: ignore HOMEBREW_*_GIT_REMOTE.
These aren't interesting enough to show in `brew config` as they
duplicate other data already displayed.
2020-01-18 14:25:38 +00:00
Cheng XU
66697d4290
ENV: add sensitive_environment function
ENV#sensitive_environment is used to list all sensitive environments.

Also refactor the code on determining whether an environment is sensitive.
2019-07-18 15:06:33 +08:00
Mike McQuaid
7c04c34a88
system_config: hide HOMEBREW_BUNDLE_* env vars.
These are being introduced in e.g.
https://github.com/Homebrew/homebrew-bundle/pull/486 and we don't care
about them in Homebrew bug reports.
2019-06-12 12:43:44 +01:00
Mike McQuaid
6b2dbbc96f
Merge pull request #6042 from MikeMcQuaid/boring_homebrew_display
config: don't show HOMEBREW_DISPLAY.
2019-04-22 13:07:20 -07:00
Mike McQuaid
58e57f2d49
config: don't show HOMEBREW_DISPLAY.
This is set by XQuartz and not needed information for us.
2019-04-20 16:22:10 +09:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
b03558e296
system_config: don’t output default HOMEBREW_LOGS.
This cuts down a bit on noise. While we’re here, optimise the checks too.
2019-04-17 17:02:33 +09:00
Mike McQuaid
d64429a736
rubocop: enable Style/IfUnlessModifier. 2019-02-21 12:55:49 +00:00
Mike McQuaid
737b84b54b
brew style --fix fixes. 2018-11-02 17:29:23 +00:00
EricFromCanada
0362e66a26 doctor: use minimum Git version set in brew.sh 2018-10-28 20:13:19 -04:00
EricFromCanada
7c9bea2703 system_config: skip HOMEBREW_GIT as its final path is shown further down 2018-10-26 23:47:59 -04:00
Mike McQuaid
78ddc34847
config: hide optional system packages.
Java, XQuartz and the CLT separate header package aren't required for
everyone's Homebrew usage or a default macOS development install.

As a result, only show then in `brew config` when they are actually
installed.
2018-09-30 10:50:37 +01:00
Mike McQuaid
5ac056fa52
system_config: don't print default HOMEBREW_GIT value.
This is `git` for most people.
2018-09-23 19:43:30 +01:00
commitay
2cb253520e system_config: add HOMEBREW_MACOS_VERSION_NUMERIC to boring_keys 2018-09-23 12:59:03 +10:00