Commit Graph
52 Commits
Author SHA1 Message Date
Mike McQuaid 204ea7e964 Make tests use public APIs and enable their cops
- Make every statically-poked method public and call it directly,
  keeping `public_send` only for dynamically-named public methods.
- Read and write state through public `attr_*` accessors instead of
  instance variable reflection.
- Enable `Homebrew/NoSendInTests` and
  `Homebrew/NoInstanceVariableAccessInTests` now the test suite is
  clean, so neither pattern creeps back in.
- Keep rare justified disables, e.g. `Module#remove_const` is
  private core Ruby and raw memoisation state has no accessor.
2026-07-27 08:11:46 +01:00
Patrick Linnane b512bd5df2 Fix uninstalling casks removed from the API
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2026-07-19 18:49:28 -07:00
Anthony HollandandClaude Fable 5 9f23c03c54 Fold aged Caskroom fixture test into update-report spec
Address review feedback on #23144: delete the fixture README, merge the
per-era trees into a single fixture Caskroom copied directly onto the
sandboxed test Caskroom path (no path stub, no mkpath), hardcode the
per-era expectations in one typed example in update-report_spec.rb and
make migrate_caskroom_caskfiles_to_json public instead of calling it via
send.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-18 03:58:15 +12:00
Mike McQuaid 71bfac209e Recover legacy Cask metadata
- preserve artifacts when receipts or metadata are missing
- share recovery between migration, upgrade and reinstall
- verify rewritten JSON before deleting legacy metadata
2026-07-16 17:56:15 +01:00
Mike McQuaid 213c8b90d7 Fix donation link 2026-07-14 09:08:47 +01:00
Mike McQuaid e4e097135b Enable cask metadata migration
- Remove the developer gate after proving the update-time path.
- Keep the regression pinned to a non-developer update run.
2026-07-10 09:31:25 +01:00
Mike McQuaid c6ebe2b06a Migrate cask metadata for developers
- Exercise the update-report path under `HOMEBREW_DEVELOPER` first.
- Convert supported Caskroom `.rb` and `.internal.json` metadata.
- Keep uninstall flight block caskfiles as Ruby until ported.
2026-07-05 13:38:28 +01:00
Patrick Linnane 7b228d3399 Revalidate tap restrictions for git redirects
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2026-06-29 15:27:00 -07:00
Mike McQuaid e3cfc7fb2d Skip auto-update outdated list before upgrade/outdated
- a zero-argument `brew upgrade` or `brew outdated` lists the
  outdated packages itself right after auto-updating
- suppress the duplicate `You have N outdated ...` count that
  the auto-update report would otherwise print first
- unset `HOMEBREW_AUTO_UPDATE_SKIP_OUTDATED` on the early return
  too so it cannot leak into the command's environment
2026-06-18 09:52:03 +01:00
Mike McQuaid 1717af5d68 Retarget redirected tap trust
- Follow GitHub redirects while preventing old tap names from staying trusted
- Update redirected tap remotes so future operations use the new canonical URL
- Remove old `trustedtaps` and per-item trust entries after a tap redirect
- Show tap trust status in `tap-info` when tap trust is required
- Query redirected tap metadata only after tap API redirects
- Keep forced redirect checks limited to taps
- Preserve update-report revisions when a tap redirect renames a tap
- Keep no-op tap updates from querying redirected metadata
- Treat redirected tap SHA API checks as updates
- Print redirected and untrusted tap messages with explicit tap wording
2026-06-12 17:00:12 +01:00
Mike McQuaid 5bf35125a0 Stop auto-tapping untrusted taps
- remove `brew test-bot` auto-tapping that silently tapped and
  retried on `TapFormulaUnavailableError` for discovered dependency
  taps; missing taps now surface so they can be tapped explicitly
- gate `update` tap migrations behind `Trust.trusted_tap?` so only
  official or already-trusted taps are auto-tapped, otherwise warn
  with manual instructions instead of erroring out the wider
  `brew update`
- recommend trusting just the migrated `user/repo/formula` rather
  than the whole tap, tapping first so `brew trust` can infer the
  package type from the on-disk tap files
- recommend `brew migrate` only for renames; a tap-only migration
  keeps the name so `brew migrate` is a no-op there, so recommend
  `brew reinstall` to re-pour from the new tap instead
- spell out manual completion because a skipped tap migration will
  not re-run on a later `brew update`
- now that `brew trust` exists, tapping untrusted taps should be an
  explicit user action rather than an implicit side effect
2026-06-08 21:18:49 +01:00
Mike McQuaid c6f1e9f04f Avoid frozen update report arrays
- Prevent `ReporterHub` from mutating arrays supplied by reports.
- Cover frozen report arrays to avoid `brew update` `FrozenError`s.
2026-06-07 11:45:03 +01:00
Bo Anderson c82887d374 test: clean up remaining klass references 2026-06-07 05:06:14 +01:00
Issy LongandBo Anderson 46d728bad9 tests: Use RSpec's described_class now Sorbet understands it
- Since https://github.com/sorbet/sorbet/commit/d9d4b57b3fde3907d739ed85d340e64f75f2a7b8
  Sorbet types `described_class` more correctly than assuming `T.untyped`.
- Switched back via having Copilot CLI (GPT 5.3 Codex) write me a
  script to change all of the `klass` references into full class names,
  and then running RuboCop's autocorrector having removed the `explicit`
  style. The explicit style was deemed too verbose in
  0c1321f1b1, hence why we went with
  `let(:klass)`.
- This is much less verbose than the full class name, while preserving
  Sorbet typing of the tests fully.
2026-06-07 00:37:41 +01:00
Issy Long 711f7eed3e sorbet: RSpec uses dynamic be_ and have_ matchers
- Some RSpec `be_` and `have_` matchers are dynamically generated[1],
  meaning that `be_empty` etc. are unknown to Sorbet. So, add a Tapioca
  compiler to generate RBIs for these matchers that are used in our
  tests but not elsewhere defined.
- This generates the same kind of RBI file as `Homebrew::Service`
  methods: all `T.untyped`.

[1]: https://github.com/rspec/rspec/blob/8098cb121a440cbc1f9dc4581ac65edbd9f001c8/rspec-expectations/lib/rspec/matchers.rb#L25-L59
2026-05-30 19:26:35 +01:00
Issy LongandMike McQuaid 0c1321f1b1 tests: Prefer let(:klass) { Foo } over described_class
- The "explicit" setting on the `RSpec/DescribedClass` cop is still
  enabled, because `described_class` is bad for Sorbet typing, but
  instead of applying its autocorrections to specify the full class name
  everywhere that `described_class` was used, use
  `let(:klass) { Foo }` so that the repetition per-test isn't massive in
  tests that use it a lot (say, >5 times).

- Changes made with Copilot CLI, agent mode, Claude Opus 4.7.
2026-05-22 14:32:42 +01:00
Issy Long f3fb592638 sorbet: Make tests typed: false
- Now that we've enabled `--experimental-rspec-mode` [1], let's start
  using Sorbet in tests at its basic `typed: false` level for now.
- This will ease the migration to `typed: true` of any or all tests we
  want to do in the future.

[1]: https://github.com/Homebrew/brew/pull/21742
2026-03-29 16:37:52 +01:00
Rylan Polster ff719ba39a Fix formula reporter inconsistencies 2025-11-07 11:53:02 -05:00
48f7d5680c Enable formula-to-cask migration within same tap
Co-authored-by: MikeMcQuaid <125011+MikeMcQuaid@users.noreply.github.com>
2025-10-03 16:24:37 +01:00
Douglas Eichelberger 7879b2052c Enable raise_on_warning in specs 2025-09-25 13:29:51 -07:00
Ruoyu Zhong 758ef51a22 Reapply "Enable recursive typechecking in specs"
This reverts commit a39d4274d3.
2025-09-16 17:15:17 +08:00
Mike McQuaidandGitHub a39d4274d3 Revert "Enable recursive typechecking in specs" 2025-09-16 09:22:15 +01:00
Mike McQuaidandGitHub 1a38b8167b Merge pull request #20644 from Homebrew/dug/deep-typecheck-specs
Enable recursive typechecking in specs
2025-09-16 07:21:01 +00:00
Douglas Eichelberger 3646b17de7 Enable recursive typechecking in specs 2025-09-14 20:43:53 -07:00
Nabo Yu 587433a33f feat: reinstall pkgconf automatically on macOS version mismatch 2025-09-13 18:43:36 -04:00
Ruoyu Zhong b45f0ecd2e test/cmd/update-report: fix test 2025-08-19 14:59:40 +08:00
Mike McQuaid 28753ef002 cmd/update-report: display descriptions for new formulae and casks.
This parses Homebrew's API JSON data to display descriptions for new
formulae and casks if available.

While we're here also add tests for ReporterHub.
2025-06-24 16:59:24 +01: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 6e9288470e brew style --fix 2024-05-23 17:15:43 +01:00
Douglas Eichelberger d5add6565c Port Homebrew::Cmd::UpdateReport 2024-04-01 11:58:20 -07:00
Markus Reiter e3a102efd4 Make Tap::new private. 2024-03-06 15:10:14 +01:00
Markus Reiter 132a87aff5 Rename Tap#repo_var to Tap#repo_var_suffix. 2024-02-23 16:02:29 +01:00
Douglas EichelbergerandMike McQuaid 26eda5a303 git grep -l '^describe' | xargs gsed -i 's|^describe|RSpec.describe|g' 2024-02-19 13:57:27 +00:00
Douglas Eichelberger 9075cbae62 brew style --fix 2023-04-21 09:58:50 -07:00
Douglas Eichelberger ac1e6ded9a git grep -l '# typed: false' | xargs gsed -i 's|# typed: false||g' 2023-04-21 09:57:47 -07:00
Issy Long 3a83b5492c rubocop: Clean up Style/BlockDelimiters excludes and autofix offenses
- The defaults of using "do ... end" for multi-line blocks everywhere is
  good, better than switching everything to braces everywhere.
2023-03-08 23:54:22 +00:00
Douglas Eichelberger bd62afde91 Resolve cmd/update-report_spec violation 2023-01-22 17:09:55 -08:00
Mike McQuaid 04c8e02418 cmd/update-report: use better wording where appropriate.
From reading https://github.com/orgs/Homebrew/discussions/3328: I
initially thought we should just change "Updated" to "Modified" when
appropriate. After conversation with Bo98, though, I thought more and
saw that we're already checking for outdated formulae here so, rather
than ever traverse through the formula history, look at the outdated
formula and list them unless we've set
`HOMEBREW_UPDATE_REPORT_ALL_FORMULAE` in which case we show the
modifications.

While we're here, also do a bit of reformatting and renaming to better
clarify intent.
2022-06-03 19:23:38 +01:00
Mike McQuaidandGitHub d48a9337e4 Revert "update-report: default HOMEBREW_UPDATE_REPORT_ONLY_INSTALLED to on." 2022-02-28 09:54:12 +00:00
Mike McQuaid 10d5266361 update-report: default HOMEBREW_UPDATE_REPORT_ONLY_INSTALLED to on.
This avoids reading formula files that the user hasn't explicitly
installed which both speeds up `brew update` and improves the security.
2022-02-22 10:01:24 +00:00
Rylan Polster 4a82d807e1 style: remove RSpec/MultipleDescribes violations in commands 2021-02-01 20:30:51 -05:00
Markus Reiter 24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Mike McQuaid 36dbad3922 Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid 2f1c6e9ca5 Cleanup cmd/* tests
- Test `_args` methods
- Remove multiple integration tests (except where essential
  e.g. `install`, `help`)
2019-03-28 08:35:36 +00:00
Markus Reiter 516a39f5a4 Move migrations into UpdateMigrator module. 2018-08-31 16:51:23 +02:00
Markus Reiter fbcaa8c85a Resolve URL to get real file extension. 2018-08-31 16:51:23 +02:00
Markus Reiter 888a7073bc Change migration to loop through formulae. 2018-08-06 17:25:29 +02:00
Markus Reiter 7449f9cd15 Fix update-report migration. 2018-08-06 12:52:18 +02:00
Markus Reiter dcf5d8d79b Add test for migrate_cache_entries_to_double_dashes. 2018-08-05 20:38:50 +02:00
Markus Reiter 54834ccbe3 Move repo_var method to Tap class. 2018-05-25 16:21:37 +02:00