1579 Commits

Author SHA1 Message Date
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
e9b4979f40
Add support for Homebrew wrappers
Allow the ability for a system administrator to use
`HOMEBREW_BREW_WRAPPER` and `HOMEBREW_FORCE_BREW_WRAPPER` variables to
enforce the usage of a particular `brew` command for non-trivial (e.g.
`brew --prefix` is considered trivial, it doesn't need to write to the
prefix) Homebrew commands.

This also introduces a `HOMEBREW_ORIGINAL_BREW_FILE` variable for some
internal usage; `HOMEBREW_BREW_FILE` was being used internally for
both "how should we shell out to Homebrew" and "what should we use
to check permissions on Homebrew". `HOMEBREW_ORIGINAL_BREW_FILE` is
now used just for the latter case.

Inspired by conversation in
https://github.com/Homebrew/homebrew-bundle/pull/1551 which suggested
this was worth fixing in wider than just `brew bundle`.
2025-01-07 17:40:18 +00:00
Carlo Cabrera
9abfafbd40
formula: update pour_bottle? CLT error message
We have received multiple bug reports from users complaining that `brew`
tells them to install the CLT when they already have Xcode installed.
See, for example, #18976.

Let's try to avoid these issues from being opened by making the error
message more explicit that we require the CLT at a specific location,
and that installing Xcode does not suffice.
2024-12-21 20:16:43 +08:00
Mike McQuaid
39a40e9873
Merge pull request #18945 from daeho-ro/clap-completion
formula: add clap completion style
2024-12-17 12:01:33 +00:00
Daeho Ro
65fe5e24d0
formula: add clap completion style 2024-12-17 08:41:52 +09:00
Michael Cho
60b5e063e3
formula: conditionally use executable name as completion name
When running `generate_completions_from_executable` with a formula's
`bin`/`sbin` executable, the resulting completion is usually intended
for the executable itself.
2024-12-15 11:58:39 -05:00
Rui Chen
52569372bb
chore(formula): raise error if no universal binaries are found to deuniversalize
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-12-10 09:26:27 -05:00
Mike McQuaid
84225d0120
pkg_version: make typed: strict
This required:
- adding signatures/types where missing
- ensuring that we respect the signature of `Version.new`
- remove some non-Sorbet type checks
- fixing the exception in tests
- removing some tests now caught by Sorbet
- fixing `Formula#prefix` so it works as intended with correct type
  usage
2024-12-05 14:01:37 +00:00
Sam Ford
79e20b3512
Standardize livecheck block language formatting 2024-12-02 10:13:04 -05:00
Sam Ford
01cb74e525
livecheck: clarify livecheckable language
Formulae, casks, and resources have a `#livecheckable?` method that
indicates whether they contain a `livecheck` block. This is intended
to be read as "has a livecheckable?", not "is livecheckable?" (as
livecheck can find versions for some packages/resources without a
`livecheck` block). Unfortunately, correct understanding of this
method's behavior [outside of documentation] relies on historical
knowledge that few people possess, so this is often confusing to
anyone who hasn't been working on livecheck since 2020.

In the olden days, a "livecheckable" was a Ruby file containing a
`livecheck` block (originally a hash) with a filename that
corresponded to a related formula. The `livecheck` blocks in
livecheckable files were integrated into their respective formulae in
August 2020, so [first-party] livecheckables ceased to exist at that
time. From that point forward, we simply referred to these as
`livecheck` blocks.

With that in mind, this clarifies the situation by replacing
"livecheckable" language. This includes renaming `#livecheckable?` to
`#livecheck_defined?`, replacing usage of "livecheckable" as a noun
with "`livecheck` block", replacing "livecheckable" as a boolean with
"livecheck_defined", and replacing incorrect usage of "livecheckable"
as an adjective with "checkable".
2024-12-02 10:13:03 -05:00
Michael Cho
d22554cda2
formula: expose inreplace global parameter 2024-11-26 13:45:50 -05:00
Douglas Eichelberger
89e640c567 Remove OpenStruct from Uses cmd 2024-11-22 21:04:51 -08:00
Douglas Eichelberger
33d9267d7d Enforce finalized sorbet methods 2024-11-21 18:34:11 -08:00
Caleb Xu
215fc85579
deprecate_disable: support optional replacement parameter 2024-11-08 15:49:00 -05:00
Mike McQuaid
e910cb5985
Merge branch 'master' into formula-api 2024-11-08 08:44:19 +00:00
Douglas Eichelberger
521c463e36
Manually resolve Style/SafeNavigationChainLength violations 2024-11-05 16:44:12 +00:00
Neved4
219a937fc2 Add -gcflags to std_go_args 2024-10-23 19:19:45 +02:00
Michael Cho
b89d282d5c
formula: change some private API to public API
The following methods used in Homebrew/core are now public API:

* `system`
* `std_*_args`
* `any_version_installed?`
* `shared_library`
* `rpath`
* `loader_path`
* `deuniversalize_machos`
* `generate_completions_from_executable`

Also remove duplicate typing in `generate_completions_from_executable`
2024-10-17 11:40:20 -04:00
Michael Cho
ff1f6ecc63
mktemp: strict type and allow #run without chdir 2024-10-16 12:47:14 -04: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
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
eab322946a
formula: fix alias/generic/prepend std_cmake_args issue.
Seen in:
https://github.com/Homebrew/homebrew-core/pull/191090#issuecomment-2363215204

There's a missing signature issue here due to the `generic_*` aliasing
we're doing. With prepend, though: this is no longer needed and we can
use `super` instead which is more idiomatic and nicer overall.

This pattern should probably be applied in other places but: let's try
this targetting fix for here first.
2024-09-20 13:01:42 +01:00
Carlo Cabrera
a9591c712f
formula: make cargo respect Homebrew-managed parallelism
`cargo` doesn't follow setting `HOMEBREW_MAKE_JOBS` or
`ENV.deparallelize`. Let's fix that.
2024-09-12 02:16:01 +08:00
Rylan Polster
6cc232c205
Include formula name in no-URL error 2024-09-11 10:45:28 -04:00
Carlo Cabrera
4335e0f5ff
formula: update CMake log files
New versions of CMake no longer generate the log files that we look for.
Instead, they generate `CMakeConfigureLog.yaml`, so let's keep that
instead.
2024-09-11 14:57:16 +08:00
Mike McQuaid
c8e8aa5600
Merge pull request #17756 from reitermarkus/concurrent-downloads
Implement concurrent downloads in `brew fetch`.
2024-09-09 08:41:11 +01:00
Ruoyu Zhong
b03e0e4696
formula: update URL to SPDX license expr docs 2024-09-06 19:44:58 +08:00
Markus Reiter
a970065657
Fix wrong argument passing. 2024-09-05 17:20:20 +02:00
Markus Reiter
846cf25043
Fix wrong argument passing. 2024-09-05 17:19:07 +02:00
Markus Reiter
123a2ac84c
Comment deprecations.
Co-authored-by: Bo Anderson <mail@boanderson.me>
2024-09-05 17:18:00 +02:00
Markus Reiter
404176af1d
Implement Downloadable for more types. 2024-09-04 22:54:28 +02:00
Markus Reiter
b297be77a1
Implement concurrent downloads. 2024-09-04 22:54:20 +02:00
Carlo Cabrera
c73d08c75b
Update comment re #nil? vs #blank? 2024-09-02 16:02:35 +08:00
Carlo Cabrera
654a58237e
formula: make audit_result a kwarg in inreplace
This allows us to get rid of a RuboCop disable, and will make formulae
easier to read.
2024-09-01 05:05:13 +08:00
Douglas Eichelberger
fb2fdc5249 Minor type safety improvements 2024-08-18 18:16:39 -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
Branch Vincent
0c0b95fae5
formula: remove std_npm_args from system's pretty_args 2024-07-25 17:11:12 -07:00
Bo Anderson
5edcaf3f06
Merge pull request #17774 from branchvincent/std_npm_args
formula: add `std_npm_args`
2024-07-25 05:41:19 +01:00
Patrick Linnane
7b8d0e6b7f
Formula-Cookbook: add std_*_args explanations
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-07-17 17:36:51 -07:00
Branch Vincent
959bf283ae
formula: add std_npm_args 2024-07-15 23:43:37 -07:00
Branch Vincent
62b2786934
formula: fix missing require 2024-07-15 21:37:31 -07:00
Rylan Polster
c4dabb5527
Have tap_git_head return nil when no tap is installed 2024-07-15 13:47:21 -04:00
Mike McQuaid
8f863199bc
Merge pull request #17754 from Moisan/formula_utils_git_repository 2024-07-15 16:52:41 +02:00
Thierry Moisan
84b725f01f
formula: add require utils/gzip 2024-07-15 10:09:12 -04:00
Thierry Moisan
4f80ef3049
formula: require utils/git_repository 2024-07-15 09:50:14 -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
Mike McQuaid
f39b5c1426
Merge pull request #17554 from Homebrew/cask-install-receipt 2024-07-13 10:55:06 -04:00
Rylan Polster
acd60181c2
Add cask install receipts 2024-07-04 01:47:13 -04:00
Rylan Polster
c16a9b33b2
Use cached json API file for formulae and cask specified paths 2024-07-03 13:41:52 -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