Skip to content

Conversation

@cho-m
Copy link
Member

@cho-m cho-m commented Dec 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 lgtm (style, typechecking and tests) with your changes locally?

One situation this happens is brew reinstall --ask where choosing "no" would result in the keg being renamed to .reinstall which can cause issues as brew only expects these to exist during an ongoing reinstall operation.

One situation this happens is `brew reinstall --ask` where choosing "no"
would result in the keg being renamed to <version>.reinstall which can
cause issues as brew only expects these to exist during an ongoing
reinstall operation.
Copilot AI review requested due to automatic review settings December 10, 2025 04:22
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 addresses an issue where .reinstall backup directories were being left behind when brew reinstall --ask operations were cancelled. The fix refactors the restore_backup method to accept an InstallationContext parameter and adds explicit backup restoration when formulas are skipped or when exceptions occur.

Key Changes:

  • Refactored restore_backup to accept InstallationContext instead of individual parameters
  • Added backup restoration when formulas are excluded from valid installers (e.g., user declines with --ask)
  • Added exception handler to restore all backups if any error occurs during reinstallation

Reviewed changes

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

File Description
Library/Homebrew/reinstall.rb Refactored restore_backup method signature to use InstallationContext and moved it from private to public scope
Library/Homebrew/cmd/reinstall.rb Added backup restoration for skipped formulas and added exception handler to restore all backups on any error

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

@cho-m cho-m marked this pull request as draft December 10, 2025 04:39
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.

Makes sense, thanks again!

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