55 Commits

Author SHA1 Message Date
Douglas Eichelberger
7acddd7eb2 Remove unused processed option element 2024-08-19 13:19:56 -07:00
Rylan Polster
0b5130937f
Update debugger to fail without portable ruby 2024-08-15 10:14:52 -04:00
Rylan Polster
3b63a7eff4
Add brew debugger command 2024-08-14 22:56:26 -04: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
1fe16a5e35 Address feedback
- Move HOMEBREW_TAP_DIRECTORY to startup/config.rb because this file
holds more of the directory constants
- Rename `Commands.cmd_directories` to `Commands.tap_cmd_directories`
to better express that the commands come from taps

This file has the directory constants while the other one has regexes.
Just better organization.
2024-08-10 17:52:26 -07: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
Ruoyu Zhong
3bc01a4d31
Fix completion generation for --repository 2024-07-14 14:46:59 -04: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
Douglas Eichelberger
c59d9fa833 Prefer numbered block params over proc conversion, cont'd 2024-04-08 09:47:27 -07:00
Douglas Eichelberger
7f78fed676 rm unnecessary description 2024-03-30 16:50:28 -07:00
Douglas Eichelberger
d25956668d Fix tests 2024-03-29 19:12:25 -07: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
Issy Long
f682147598
Fix RuboCop Style/RedundantFreeze offenses 2024-01-18 22:20:01 +00:00
Bo Anderson
5692c8ecbf
Fix style violations under newer RuboCop 2023-12-14 05:47:12 +00:00
Mike McQuaid
7801878c74
post_install: improvements and fixes.
- warn if running `brew postinstall` explicitly and there's no
  `post_install` defined in the formula
- add a `post_install` alias for `brew postinstall` to make life
  easier for those jumping between `postinstall` and `post_install` in
  e.g. Homebrew development
- refactor `post_install` formula path logic into a new method for
  improved readability
- handle the JSON API `post_install` formula path case
2023-07-28 11:26:09 +01:00
Douglas Eichelberger
09c679e75f Refactor module_function to reduce rbi need 2023-04-17 10:37:59 -07:00
Ruoyu Zhong
c7f3e72e6b
commands: make the description splitting pattern a constant 2023-04-05 15:16:38 +08:00
Ruoyu Zhong
5c9e073cd5
commands: fix completion descriptions for shell commands too
This was missed in #15146.

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2023-04-04 23:04:13 +08:00
Ruoyu Zhong
4305443c9c
commands: explain change in command description splitting
A comment here would help the reader to understand the need for this
splitting logic, which is not so straightforward.

Addresses review comment in
https://github.com/Homebrew/brew/pull/15146#discussion_r1157361656.

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2023-04-04 22:50:40 +08:00
Ruoyu Zhong
68b63427c6
commands: fix completion descriptions
Currently, zsh and fish shell completions show incomplete descriptions
for certain commands. For example:

    docs                         -- Open Homebrew's online documentation (https://docs
    rbenv-sync                   -- Create symlinks for Homebrew's installed Ruby versions in ~/

This is because `Commands.command_description` produces incomplete
short descriptions for the commands having a dot (from a URL or a path)
in the first sentence; the dot is misinterpreted as a full stop:

    brew(main):001:0> Commands.command_description("docs", short: true)
    => "Open Homebrew's online documentation (https://docs"
    brew(main):002:0> Commands.command_description("rbenv-sync", short: true)
    => "Create symlinks for Homebrew's installed Ruby versions in ~/"

We can improve the sentence splitting logic by only splitting at dots
either at the end or followed by a whitespace. Now With this change:

    brew(main):001:0> Commands.command_description("docs", short: true)
    => "Open Homebrew's online documentation (https://docs.brew.sh) in a browser"
    brew(main):002:0> Commands.command_description("rbenv-sync", short: true)
    => "Create symlinks for Homebrew's installed Ruby versions in ~/.rbenv/versions"

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2023-04-04 18:39:13 +08:00
Douglas Eichelberger
eb23a2c44a Enable typing in a couple more files 2023-03-03 08:30:15 -08:00
Rylan Polster
39097583b9
Set HOMEBREW_NO_INSTALL_FROM_API for certain commands 2023-02-06 16:17:04 +01:00
Dawid Dziurla
e1700178bd
brew.sh: add missing dev-cmd aliases 2023-02-01 13:51:18 +01:00
Bo Anderson
02164a35db
Use ORIGINAL_PATHS over envs; reject nil PATH 2022-06-17 19:47:57 +01:00
Rylan Polster
b896f6cb0d
Allow more developer commands with HOMEBREW_INSTALL_FROM_API 2022-06-16 21:31:15 -04:00
Nanda H Krishna
5ec685951e
commands: remove diy, add lc for livecheck 2021-07-14 21:55:38 +05:30
Rylan Polster
08b44afcdf
cli/parser: allow options to be hidden 2021-06-08 22:02:32 -04:00
Mike McQuaid
c6a9227e08
More official Homebrew taps
Make `brew alias`, `brew autoupdate` and `brew command-not-found-init`
official commands. This means we:
- make sure we don't break their style with `brew style` changes
- autotap them when you run the command and they aren't installed
- include them in the manpage
2021-04-23 13:43:55 +01:00
nandahkrishna
8e5451df2f
style: use parentheses for assignment in conditions 2021-02-12 18:33:37 +05:30
Mike McQuaid
d6957a3acb
Homebrew 3.0.0 deprecations/disables 2021-01-29 19:50:24 +00:00
Jonathan Chang
fdda2b3414 zsh: prevent autocompleting conflicting options 2021-01-27 14:54:39 +11:00
Rylan Polster
0c5edf4004
Cleanup description handling 2021-01-25 13:46:51 -05:00
Rylan Polster
3e8b91679d
completions: generate zsh completions 2021-01-25 13:46:51 -05:00
Rylan Polster
eebc161ea5 Incorporate suggestions from code review
Co-Authored-By: Seeker <meaningseeking@protonmail.com>
2021-01-15 00:13:30 -05:00
Rylan Polster
3af16832d9 Generate bash completions automatically 2021-01-15 00:03:28 -05:00
Mike McQuaid
b484f70572
Remove cask from man brew. 2020-11-25 09:37:21 +00:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
c74d54411b Add tc alias for typecheck. 2020-10-09 16:45:13 +02:00
Markus Reiter
540fa4e84b Pass quiet when tapping external commands. 2020-09-09 21:49:22 +02:00
Markus Reiter
608760908f Document Commands. 2020-08-26 03:13:58 +02:00
Mike McQuaid
3a91c37e66
Fix RuboCop checks. 2020-08-19 17:12:32 +01:00
William Ma
de4f5c1095 commands: Fix code review comments 2020-07-22 22:47:42 -04:00
William Ma
92953aa8e8 commands: Add unstable commands to cask commands 2020-07-20 15:06:29 -04:00
William Ma
0b613d2fe3 commands: Deduplicate command print logic 2020-07-20 14:00:16 -04:00
William Ma
3bbffdd1d7 commands: Print cask commands 2020-07-20 13:18:09 -04:00
Markus Reiter
71171f9cb0 Use atomic_write instead of deleting and writing file. 2020-07-03 04:35:42 +02:00
Caleb Xu
a53c92bd7f Cache commands list for faster shell completions 2020-06-18 11:06:31 -04:00
Mike McQuaid
8b479ea77b
manpage: update external commands.
- add more detailed manpage section for external commands (more
  information moved from their READMEs)
- add `brew test-bot` to the manpage
2020-05-30 14:19:56 +01:00