KEMBAR78
Fix brew fetch failure with symlinked taps and refactor path validation logic by Copilot · Pull Request #20655 · Homebrew/brew · GitHub
Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 9, 2025

  • Initial analysis of review comments
  • Update cask_loader.rb to match formulary.rb logic pattern more closely (use path.to_s instead of path.expand_path.to_s)
  • Move test from cask_loader_symlink_spec.rb to cask_loader_spec.rb
  • Replace File.join with Pathname#/ operations in test
  • Use Pathname methods instead of strings throughout test
  • Remove the separate cask_loader_symlink_spec.rb file
  • Run style checks and type checks - all passing
  • Apply DRY/simplify/YAGNI principles
  • Remove typed: strict from test file (tests should never be typed: strict)
  • Simplify test to use built-in mktmpdir helper instead of custom tmpdir setup
  • Update cask_loader.rb to fully match formulary.rb pattern with .rb extension checks, path count validation, and proper exception handling
  • Fix all style and typecheck errors
  • Extract shared path validation logic from cask_loader.rb and formulary.rb into utils/path.rb to eliminate code duplication

Refactoring Changes

The duplicate path validation logic that existed in both cask_loader.rb and formulary.rb has been extracted into a new shared method Utils::Path.validate_package_path in utils/path.rb. This refactoring:

  • Eliminates code duplication: The identical path validation logic is now centralized in one location
  • Maintains exact behavior: Both cask and formula validation work exactly as before
  • Improves maintainability: Future changes to path validation logic only need to be made in one place
  • Follows DRY principles: Reduces the codebase size and complexity

The shared method handles validation for both casks and formulae with appropriate error messages while preserving all the original security checks and tap detection logic.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] brew fetch fails on tap repo gh actions with setup-homebrew Fix brew fetch failure with symlinked taps Sep 9, 2025
@Copilot Copilot AI requested a review from MikeMcQuaid September 9, 2025 07:55
Copilot finished work on behalf of MikeMcQuaid September 9, 2025 07:55
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.

@copilot address review comments and also DRY/simplify/YAGNI things as much as possible.

@Copilot
Copy link
Contributor Author

Copilot AI commented Sep 9, 2025

@copilot address review comments and also DRY/simplify/YAGNI things as much as possible.

Addressed all review comments by matching formulary.rb pattern, consolidating tests into main file, using Pathname methods, and applying DRY/YAGNI principles. Removed duplicate code and simplified the implementation. (4f61380)

@Copilot Copilot AI requested a review from MikeMcQuaid September 9, 2025 12:03
Copilot finished work on behalf of MikeMcQuaid September 9, 2025 12:03
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.

@copilot Follow instructions, run brew style --fix and brew typecheck and fix all errors.

@Copilot
Copy link
Contributor Author

Copilot AI commented Sep 9, 2025

@copilot Follow instructions, run brew style --fix and brew typecheck and fix all errors.

Fixed all style and type issues. Removed typed: strict from test file, updated cask_loader.rb logic to match formulary.rb pattern with proper .rb extension and path count checks, and simplified test to use built-in mktmpdir helper.

@Copilot Copilot AI requested a review from MikeMcQuaid September 9, 2025 12:34
Copilot finished work on behalf of MikeMcQuaid September 9, 2025 12:34
@Copilot Copilot AI changed the title Fix brew fetch failure with symlinked taps Fix brew fetch failure with symlinked taps and refactor path validation logic Sep 9, 2025
@Copilot Copilot AI requested a review from MikeMcQuaid September 9, 2025 14:28
Copilot finished work on behalf of MikeMcQuaid September 9, 2025 14:28
@MikeMcQuaid MikeMcQuaid force-pushed the copilot/fix-brew-fetch-tap-repo-issue branch 2 times, most recently from 1f1ed48 to 14b84ed Compare September 10, 2025 15:34
@MikeMcQuaid MikeMcQuaid requested a review from Rylan12 September 10, 2025 15:35
@MikeMcQuaid MikeMcQuaid marked this pull request as ready for review September 10, 2025 15:35
Copy link
Member

@Rylan12 Rylan12 left a comment

Choose a reason for hiding this comment

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

Looks good!

Formulae, dependencies, tries are all used in multiple places so let's
simplify them
Co-authored-by: MikeMcQuaid <125011+MikeMcQuaid@users.noreply.github.com>
@MikeMcQuaid MikeMcQuaid force-pushed the copilot/fix-brew-fetch-tap-repo-issue branch from 14b84ed to 6297f98 Compare September 12, 2025 08:02
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Sep 12, 2025
Merged via the queue into main with commit 2d9e9ce Sep 12, 2025
36 checks passed
@MikeMcQuaid MikeMcQuaid deleted the copilot/fix-brew-fetch-tap-repo-issue branch September 12, 2025 08:40
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.

3 participants