Skip to content

Conversation

@bevanjkay
Copy link
Member

  • 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?

When we are updating python resources, if the version and checksum has not changed we retain the existing block instead of generating a new one. This ensures that any version-specific patches are retained.

Closes #21100

Copilot AI review requested due to automatic review settings November 18, 2025 09: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

This PR enhances the update_python_resources! method to preserve existing resource blocks (including any patches) when the resource's version and checksum haven't changed. This addresses issue #21100 by preventing the loss of version-specific patches during resource updates.

Key changes:

  • Added AST parsing to extract existing resource blocks from formula files
  • Implemented logic to compare existing resources with new ones and retain unchanged blocks
  • Created a new helper method resource_blocks_from_formula to parse and extract resource blocks

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

Copy link
Member

@p-linnane p-linnane left a comment

Choose a reason for hiding this comment

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

Works great! Thanks so much!

@p-linnane p-linnane added this pull request to the merge queue Nov 18, 2025
Merged via the queue into main with commit 07a983c Nov 18, 2025
43 checks passed
@p-linnane p-linnane deleted the use-existing-resource-blocks branch November 18, 2025 18:07
ZhongRuoyu added a commit that referenced this pull request Nov 21, 2025
Since 1ab3b0c (#21105), `utils/pypi`
depends on the `rubocop-ast` gem (via `utils/ast`). We need to ensure
that the gem is installed before requiring `utils/pypi` in the affected
developer commands.

Fixes https://github.com/orgs/Homebrew/discussions/6557.
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.

brew update-python-resources should not strip patches from unchanged resources

3 participants