193 Commits

Author SHA1 Message Date
Mike McQuaid
05c7b65f54
tab, cask/tab: add more Sorbet types and signatures.
I bailed before going all the way to `typed: strict` but this should at
least improve things and fix:

`Library/Homebrew/tab.rb:111: warning: The class Tab reached 8 shape variations, instance variables accesses will be slower and memory usage increased.`
2025-06-24 12:06:55 +01:00
Mike McQuaid
dc71b7c8f6
Cleanup extend/ directory usage.
- move some things out of `extend` that don't really fit there e.g.
  `Module`s that are included but not doing any
  overriding/monkeypatching
- move some code into `extend/os` to fix all remaining
  `rubocop:todo Homebrew/MoveToExtendOS`s
- remove some unneeded `bundle` skipper code that doesn't really make
  sense given our current bottling strategy
- extract some `Pathname` extensions to `extend/pathname` for separate
  files
- move a `ENV` `Kernel` extension into `kernel.rb`
- `odeprecate` a seemingly unused backwards compatibility method
- move `readline_nonblock` from a monkeypatch to a
  `ReadlineNonblock.read` method as its only used in one place
- fix up a link in documentation
2025-06-09 19:06:16 +01:00
Mike McQuaid
9e789279f5
tab: add bottle_rebuild to runtime_dependencies.
It can be useful to know, if a formula's dependencies were installed
from a bottle, what rebuild of the bottle was used for debugging.
2025-03-24 17:37:06 +00:00
Mike McQuaid
730c93e60f
Merge pull request #19087 from Homebrew/installed_on_request_true
Fix usage of `Tab#installed_(on_request|as_dependency)`
2025-01-13 09:36:05 +00:00
Mike McQuaid
0940fb78dc
Fix usage of Tab#installed_(on_request|as_dependency)
These can return `true`, `false` or `nil` so adjust the signature to
note this and fix the call sites to ensure we don't accidentally pass
through `nil` values when we shouldn't.

While we're here, make a `TODO` to fix this bad API up in future.

Fixes https://github.com/Homebrew/brew/issues/19076
2025-01-13 09:24:42 +00:00
Douglas Eichelberger
dbb731bce2 brew style --fix 2025-01-12 10:05:21 -08:00
Douglas Eichelberger
eed660e784 Move remaining OS extensions to prepend 2024-10-05 12:18:29 -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
Rylan Polster
d17da89382
Include recursive dependencies in cask tabs 2024-07-09 15:25:57 -04:00
Rylan Polster
119e02ceb0
Cleanup tap_git_head and uninstall_flight_blocks?
Co-authored-by: Kevin <apainintheneck@gmail.com>
2024-07-09 13:22:00 -04:00
Rylan Polster
79fd5ee2b7
Refactor tap and versions 2024-07-05 10:07:30 -04:00
Rylan Polster
e176159b23
Fix test 2024-07-04 12:27:45 -04:00
Rylan Polster
3a732460e9
Refactor Tab create method 2024-07-04 11:18:26 -04:00
Rylan Polster
acd60181c2
Add cask install receipts 2024-07-04 01:47:13 -04:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
0b56d0be4a
Document Tab.for_keg and use Keg#tab where possible. 2024-04-28 20:50:13 +02:00
Markus Reiter
c76170a456
Hide #to_s in docs. 2024-04-26 14:04:55 +02:00
Markus Reiter
4b432c7ea4
Explicitly mark non-private APIs. 2024-04-22 21:16:49 +02:00
Douglas Eichelberger
c4db19232d git grep -lE '\(\&[A-Za-z._]+method\(:' | xargs gsed -i -E 's|\(\&([A-Za-z._]+)method\(:([a-z?_]+)\)\)| { \1\2(_1) }|g' 2024-03-03 18:55:56 -08:00
Douglas Eichelberger
a87cdf0d21 Add Hash#deep_transform_values to extend/ 2024-01-19 13:36:16 -08:00
Douglas Eichelberger
08e12b2383 Remove ActiveSupport Array access core extensions 2024-01-19 13:34:52 -08:00
Patrick Linnane
9dee80cb2d
various: fix style errors 2023-12-18 09:34:01 -08:00
Bo Anderson
19f27f9a20
Store and use revision, where possible, in tab runtime dependencies.
Let's start storing `revision` and `pkg_version` for tab runtime
dependencies and use them when available.

When the `revision` is not available, use a conservative approach to
deciding whether dependencies need to be upgrade.

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2023-11-10 18:24:43 +00:00
Eric Knibbe
931f762598
docs+rubydoc: various grammar/wording fixes 2023-09-11 02:26:37 -04:00
Bo Anderson
289fb5b393
tab: fix typing of versions 2023-05-11 12:33:27 +01:00
Markus Reiter
a1efaf1864
Merge HeadVersion and NullVersion into Version. 2023-05-09 01:13:54 +02:00
Douglas Eichelberger
08af78a2a5 brew style --fix 2023-04-25 09:26:24 -07:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Douglas Eichelberger
4d32699f61 Placate rubocop 2023-03-14 23:01:09 -07:00
Douglas Eichelberger
3018793f93 Remove OpenStruct use in Tab 2023-03-14 23:01:08 -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
Rylan Polster
b44f715f82
Include loaded_from_api key in Tab 2022-09-14 22:23:01 -04:00
Rylan Polster
50fac1737a
install: fix HEAD installations with HOMEBREW_INSTALL_FROM_API 2021-09-17 23:46:28 -04:00
Bo Anderson
a5cb621fb8
tab: add declared_directly field for runtime deps 2021-05-10 05:50:08 +01:00
Mike McQuaid
d8a2cf9efc
Write tabs to bottle JSON, optionally not bottle
- Write a subset of the tab required for bottles as an annotation.
- Add option on new bottle creation to skip writing tab into bottle
  and instead add it (and other useful metadata) to bottle JSON.
- Read formula information and tab from bottle JSON.
- Write prettier JSON to disk.
- Don't write `HEAD` to tab; this duplicates `HOMEBREW_VERSION`.
- Allow `brew bottle` to use `--json` to generate JSON files from a
  local bottle file.
2021-03-31 09:43:37 +01:00
Mike McQuaid
2b1f460289
Fix installed_on_request for dependencies.
Dependencies were using `Tab.for_formula(df)` to get a `Tab` which meant
that they were always ending up with the (default) value of `true` for
`installed_on_request`. Fix this by:
- setting `installed_on_request` to `false` by default in empty `Tab`s;
  we always override it on installation so we'd rather have it default
  to `false`
- only read and use a `Tab` for the existing dependency formula if
  there's an existing `Keg`
2021-02-23 10:19:45 +00:00
Mike McQuaid
eaae52edb8
tab: return default values on existing, blank install receipt contents. 2021-01-14 16:26:58 +00:00
Mike McQuaid
74fb058c7e
More deprecations
More deprecations, disabling and removal for Homebrew 2.7.0.
2020-12-18 14:17:37 +00:00
Mike McQuaid
d496f5c121
Deprecations for Homebrew 2.6.0
Do the usual deprecate/disable dance for the Homebrew 2.6.0 release.

Not to be merged until the next release will definitely be 2.6.0.
2020-11-24 16:44:02 +00:00
Markus Reiter
da9289eff0 Add more type signatures. 2020-11-13 12:26:36 +01:00
Mike McQuaid
5afff3f3aa
Handle macOS Homebrew on ARM
- Output `brew doctor` and `brew install` messages noting this configuration is (currently) unsupported and encourage use of Rosetta instead
- Output Rosetta 2 usage in `brew config` on ARM (whether in Rosetta 2 or not)
- Check the architecture of (newly installed) dependencies and ensure they are using the correct architecture.
- Don't allow installing macOS Intel Homebrew in macOS ARM Homebrew default prefix (and vice versa
- Actually write out the architecture of dependencies to the tab rather than generating and throwing them away
- Set and document the expected default prefix for macOS Intel Homebrew, macOS ARM Homebrew (`/opt/homebrew`) and Homebrew on Linux

While we're here:
- Don't say Big Sur is a prerelease version but still make it clear we
  don't support it (yet).
- Don't reference non-existent IRC channel
2020-11-12 17:06:47 +00:00
EricFromCanada
3768b7a6e9 apidoc: update comment wording, punctuation, formatting 2020-11-06 00:21:02 -05:00
Mike McQuaid
ffe827ad0e
Fix upgrading dependents on missing keg
Ensure that we don't try to check for broken linkage in a keg that
doesn't exist. Furthermore, fix the reason we checked for the keg that
doesn't exist by `Formula.clear_cache`.

While here, I noticed that there was other methods of caching at use in
`Formula` so consolidate them to be consistent.

Fixes #8997
2020-10-29 08:31:04 +00:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Jonathan Chang
14cba7f648 tab: fix nil modification time 2020-10-05 13:52:50 +11:00
Mike McQuaid
2e5272d04c Deprecate/disable code for Homebrew 2.5.0.
Do the usual "disable deprecations" and "uncomment pending deprecations"
dance and delete/deprecate/disable relevant/related code.
2020-09-03 10:34:22 +01:00
Seeker
5acdcd26d0 formula: rename installed_prefix to latest_installed_prefix 2020-09-01 09:32:32 -07:00
Bo Anderson
b338398a8c tab: add built_on & arch information 2020-08-18 15:58:00 +01:00
Mike McQuaid
1e265247ca
rubocop: apply autofixes. 2020-03-13 21:16:18 +00:00
Mike McQuaid
766fc4b301
Fix RuboCop 0.77.0 failures. 2019-11-28 15:10:50 +00:00