Skip to content

Conversation

@loganrosen
Copy link
Contributor

@loganrosen loganrosen commented Nov 10, 2025

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Overview

This PR enhances TapAuditor to provide comprehensive validation for formula_renames.json and cask_renames.json files in taps, and updates the rename documentation.

Changes

New Validation Checks (tap_auditor.rb)

The new check_renames method validates rename entries and detects:

  1. Invalid format: .rb file extensions in rename keys or values (should use tokens only)
  2. Missing targets: Rename targets that don't exist in the tap
  3. Chained renames: Detects rename chains (A → B → C → D) and suggests collapsing them to the final target (A → D). Includes cycle detection to prevent infinite loops.
  4. Name conflicts: Old names that conflict with existing formulae/casks in the tap

Implementation Details

  • Added cask_renames to attr_reader (was missing)
  • Replaced simple check_formula_list call for formula_renames.json with check_renames method
  • Added check_renames call for cask_renames.json validation
  • Chained rename detection follows chains to their final target with cycle detection
  • Implemented comprehensive test coverage for all validation scenarios

Documentation Updates (docs/Rename-A-Formula.md)

  • Added missing cask rename process documentation
  • Added "Important Rules" section documenting all validation requirements
  • Updated title to "Renaming a Formula or Cask" to reflect complete coverage
  • Provided clear examples for both formula and cask renames

Motivation

This was motivated by Homebrew/homebrew-cask#235881, which fixes an incorrect cask_renames.json entry that erroneously included a .rb file extension in the old cask name. This caused Homebrew to fail to properly migrate users from multiviewer-for-f1 to multiviewer, breaking the rename functionality entirely.

Currently, there's no validation to catch these errors before they're merged, meaning broken renames can silently break user upgrades. This PR adds auditing to prevent such issues:

  • Invalid extensions: Catches .rb extensions that break rename matching
  • Chained renames: Detects and suggests collapsing multi-level chains (A → B → C → D becomes A → D)
  • Missing targets: Ensures renames point to formulae/casks that actually exist
  • Name conflicts: Warns when old names conflict with existing formulae/casks

These checks will catch issues during brew audit before they're merged and affect users.

Testing

All new functionality is covered by RSpec tests in tap_auditor_spec.rb:

  • Tests for cask rename validation (7 test cases, including multi-level chain detection)
  • Tests for formula rename validation (3 test cases)
  • All tests passing locally

Local validation:

✓ brew style (No offenses)
✓ brew typecheck (No errors)
✓ brew tests --only=tap_auditor (All 10 tests passing)

- Add check_renames method to validate rename entries
- Detect .rb extensions in rename keys/values
- Validate rename targets exist in tap
- Detect and report chained renames
- Warn about old names conflicting with existing formulae/casks
- Add cask_renames to attr_reader
- Add comprehensive test coverage for rename validation
Copilot AI review requested due to automatic review settings November 10, 2025 02:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive validation for cask_renames.json and formula_renames.json files in Homebrew taps, replacing basic existence checking with detailed auditing.

  • Implements a new check_renames method that validates rename entries for both casks and formulae
  • Detects common issues: .rb extensions, missing targets, chained renames, and naming conflicts
  • Adds comprehensive test coverage for cask rename validation and partial coverage for formula renames

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Library/Homebrew/tap_auditor.rb Adds cask_renames attribute, implements check_renames method with four validation checks, and integrates validation into the audit process
Library/Homebrew/test/tap_auditor_spec.rb Adds comprehensive test suite covering cask_renames validation scenarios and partial test coverage for formula_renames validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add missing cask rename process documentation
- Document validation rules for both formula and cask renames
- Explain .rb extension, chained renames, and other common issues
- Update title to reflect coverage of both formulae and casks
@loganrosen loganrosen requested a review from Copilot November 10, 2025 02:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

… end

- Follow rename chains to their final target (e.g., A → B → C → D now correctly suggests A → D)
- Add cycle detection to prevent infinite loops on circular renames
- Add test case for multi-level chained renames
- Simplify suggestion message since chains can be arbitrarily long

Addresses PR feedback from Homebrew#21011
@loganrosen loganrosen requested a review from Copilot November 10, 2025 02:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@loganrosen Was an LLM used to generated any of the PR description and/or code here? If so, can you confirm you've manually reviewed, shortened and simplified it all as much as possible to the best of your ability and you understand it all? Thanks!

Copilot AI review requested due to automatic review settings November 10, 2025 23:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@loganrosen
Copy link
Contributor Author

@loganrosen Was an LLM used to generated any of the PR description and/or code here? If so, can you confirm you've manually reviewed, shortened and simplified it all as much as possible to the best of your ability and you understand it all? Thanks!

@MikeMcQuaid Yes, I did use an LLM to assist with the PR description and code changes, but I've manually reviewed all of the information/changes and understand them fully. Your nudge did lead me to some slight improvements in the error messages, though. 🙂

@loganrosen loganrosen marked this pull request as ready for review November 11, 2025 00:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings November 14, 2025 01:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MikeMcQuaid
Copy link
Member

Looks good when final comments addressed.

Copilot AI review requested due to automatic review settings November 15, 2025 22:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings November 16, 2025 23:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @loganrosen, nice work here!

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Nov 18, 2025
Merged via the queue into Homebrew:main with commit 4d93d40 Nov 18, 2025
42 checks passed
@loganrosen loganrosen deleted the tap-auditor-rename-validation branch November 19, 2025 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants