106 Commits

Author SHA1 Message Date
Mike McQuaid
ff710f8191
Improve completions (and elisp) output in caveats
Instead of repeatedly outputting the same identical messages across
multiple packages and repeating them all for every package after they
were all installed: just output the identical messages in the final
caveats output instead.
2025-06-06 17:09:28 +01:00
Heath Stewart
42caf20fa4
Add PowerShell (pwsh) completion support
Resolves #19403
2025-03-02 18:17:38 -08:00
Douglas Eichelberger
a81239ec2d
Enable strict typing in Formula 2025-02-24 10:23:42 -08:00
Patrick Linnane
c2e2b23c50
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-10-02 10:03:12 -07:00
Michael Cho
55fab8849c
caveats: typed: strict 2024-09-26 10:30:21 -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
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
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02: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
Markus Reiter
3472362ddd
Don't stub all Pathnames in tests. 2024-02-13 18:46:58 +01:00
Bo Anderson
b42256d286
Deprecate, disable & delete code for Homebrew 4.2.0 2023-12-07 23:42:13 +00:00
apainintheneck
1111706378 service: add custom service name DSL
The main thing is that this DSL allows us to provide an
interface that can be serialized to the JSON API.

Changes:
- Homebrew::Service
  - Adds `#service_name` and `#plist_name` methods
    - Each is now included in the `#serialize` method as well
  - Eval block on instantiation
    - Before we lazy evaluated this but the cost is not significant
      and it complicated the code a bunch. This only gets called
      during install, when evaluating caveats and in the `brew service`
      command. It skips this evaluation if the service block isn't there.
  - Add `#command?` helper to avoid `#command.blank?` and `#command.present?`
- Formula
  - `#service` now returns a service whenever it's called. This call is
    hidden behind a call to `#service?` most of the time anyway so this
    should be fine.
  - `#plist_name` and `#service_name` now call the methods of the same name
    on the service class. This should have already been in the service object
    to begin with and keeping these methods here helps preserve backwards
    compatibility with people who were overwriting these methods before.
- Caveats
  - Prefer `service#command?`
  - Add helpers for checking on service commands
    - This duplicates some of the work in `brew services`. Maybe we should
      merge that repo in at some point.
  - Check for installed service at `#plist_name` or `#service_name`. I think
    this should be used instead of `Keg#plist_installed?` which checked for any plist file.
    We should think about deprecating `#plist_installed?` in the future.
  - Stop using `ps aux | grep #{formula.plist_name}` to check for service files
    because it was inaccurate (it always returns true on my machine) because the grep
    process is started before the ps process.
  - Note: The behavior is the same as it was before. This means that caveats
    only show up for custom service files on install or if they're already installed.
    Otherwise it won't show up in `brew info`. This is because it has to check
    first if the service file has been installed.
- Utils::Service
  - Add utils for evaluating if a service is installed and running. This duplicates
    some of the work already found in `brew services`. We should seriously consider
    merging `brew services` with the main brew repo in the future since it's already
    tightly coupled to the code in the main repo.
- Formulary.load_formula_from_api
  - Be more explicit about which types can be deserialized into run params since
    it is now possible for run params to be nil.
- Update and add tests
2023-05-13 14:53:01 -07:00
Issy Long
f10b88ca85
caveats: Add a new line if there isn't one from previous conditions 2023-03-19 18:38:09 +00:00
Issy Long
7bb57612b7
caveats: Remove extra blank line between keg_only and other caveats
- This was pointed out by Carlo in
  https://github.com/Homebrew/brew/issues/14925#issuecomment-1473303922,
  it annoyed me the moment I saw it too, and it was a very quick fix.
- The caveats items are joined by "\n" before being displayed, so the
  extra `\n` here when generating the `keg_only_text` meant that there
  were two blank lines which looked weird. This `keg_only_text` method
  is only used here so it doesn't affect anywhere else we show the
  `keg_only` message, if there are any other places.
2023-03-18 12:21:10 +00: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
Dawid Dziurla
0d0c98de29
Allow defining service run command per platform 2023-01-19 11:36:37 +01:00
Sean Molenaar
0cd10ed65e
caveats: print sudo in caveats if service requires it 2022-12-05 12:12:51 +01:00
Issy Long
b7d997e80d
sorbet: Bump some files from typed: false to typed: true
- This was done with `brew typecheck --update --suggest-typed` which
  (as of the previous commit) uses Spoom, yet another gem. I thought I'd
  see how well it works. There are no Sorbet errors after these changes!
2022-10-11 01:09:03 +01:00
Bo Anderson
02164a35db
Use ORIGINAL_PATHS over envs; reject nil PATH 2022-06-17 19:47:57 +01:00
Sean Molenaar
73bc934c85
Caveats: suggest brew services for linux 2021-10-30 18:18:25 +02:00
Sean Molenaar
ef9c49c5b2
service: ensure environment variables are prefixed in command 2021-05-25 11:47:44 +02:00
Sean Molenaar
3ab21cc412
services: replace plist_options :manual with service command 2021-05-01 16:20:47 +02:00
EricFromCanada
6fc116318e fixes for grammar and wording 2021-01-26 16:19:47 -05:00
Seeker
b9854bd4cf rubocops: add unless_multiple_conditions 2021-01-08 10:33:54 -08:00
Mike McQuaid
1f8fd2a9ef
caveats: remove ZSH FPATH logic.
This is too error-prone and full of edge cases.

Fixes #9455
2020-12-09 11:47:48 +00:00
Mike McQuaid
ac84a4b051
Fix ZSH FPATH handling
Don't require it to be exported but shell out to `zsh` instead.

Fixes https://github.com/Homebrew/brew/issues/9387
2020-12-03 16:52:55 +00:00
Mike McQuaid
3002c810be
Improve ZSH completions handling
- Only display the completions caveats from the current shell (assuming
  it's one of Bash, ZSH or Fish)
- If the completions location isn't in the ZSH `FPATH` then link to the
  documentation explaining how to do so.

Fixes https://github.com/Homebrew/brew/issues/8984
2020-11-26 16:08:26 +00:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
8957422d86 Document Caveats. 2020-08-26 03:13:58 +02:00
Mike McQuaid
3a91c37e66
Fix RuboCop checks. 2020-08-19 17:12:32 +01:00
Issy Long
341ea60807
Auto-fix Style/RedundantBegin offenses
- This also required auto-fixes for Layout/EmptyLinesAroundBlockBody and
  Layout/InconsistentIndentation once the auto-fixer had got rid of the
  "redundant begin"s.
2019-10-13 16:04:27 +01:00
Mike McQuaid
fc6bd2ea1c
Fixup more frozen string handling. 2019-04-20 14:07:29 +09:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
2e7a3f3da2
caveats: tweak wording/formatting. 2019-03-13 08:56:16 +00:00
Morgan Tocker
a1f24748e6 caveats: non-macOS platforms warn on services
Only currently supported by macOS. Attempting to use services
should produce a warning for now.  It is possible it might be
supported in the future.
2019-03-12 13:47:54 -06:00
Mike McQuaid
d64429a736
rubocop: enable Style/IfUnlessModifier. 2019-02-21 12:55:49 +00:00
Mike McQuaid
b89367e6d9 caveats: tweak keg_only_text
- make it a public method
- allow skipping the reason
- output how to set the various variables in your current shell
2018-07-26 10:49:07 +01:00
Mike McQuaid
9fca172d03 Fix HOMEBREW_RUBY_WARNINGS="-w"
Fix various circular requirements, method redefinitions, etc.
2018-04-07 20:28:56 +01:00
Mike McQuaid
36dadbee47 caveats: remove python caveats.
These instructions are currently incorrect and need to be ported to
`python` 3.x and `python@2` formulae. Until then it's better to not have
them than have them be incorrect.

Closes #3890.
2018-03-08 08:34:20 +00:00
Mike McQuaid
d54e670a64 requirements: move more to compat. 2017-12-30 20:56:55 +00:00
Mike McQuaid
cacefb2b99
caveats: tweak root_dir definition style. 2017-12-24 07:59:17 +00:00
Dominyk Tiller
92e62ba583
caveats: correct completion/function paths for keg_only 2017-12-23 23:15:59 +00:00
Dominyk Tiller
55d9750056
caveats: fix fish caveats under env filtering 2017-12-11 09:16:39 +00:00
Dominyk Tiller
d70a406fe7
caveats: fix PKG_CONFIG_PATH nudge under env filtering 2017-12-11 06:26:56 +00:00
Markus Reiter
0ea855c6e6 Add missing require "forwardable". 2017-10-24 19:39:40 +02:00
Markus Reiter
9bee9ca575 Use “squiggly” heredocs. 2017-10-18 14:39:09 +02:00
Maxim Belkin
336fbb5db2
caveats: making plist_caveats macOS-only 2017-10-16 11:15:54 -05:00
Mike McQuaid
01e9ec9a9f Rubocop: automatic rule fixes. 2017-09-24 21:23:59 +01:00
Misty De Meo
2bd8091ae8 Merge pull request #2804 from mansimarkaur/caveats
Increasing test coverage for caveats.rb
2017-07-25 09:28:46 -07:00
mansimarkaur
ae02b9776a Added tests for python caveats 2017-07-25 21:00:37 +05:30