Skip to content

Conversation

@MikeMcQuaid
Copy link
Member

@MikeMcQuaid MikeMcQuaid commented Oct 24, 2025

Add a new audit method to check if the revision and compatibility_version are consistent with each other.

This ensures that when a formula's compatibility_version is increased, the revision of dependent formulas was also increased.

Inversely, when a formula's revision is increased in the same PR as one of its dependencies, the compatibility_version of dependent formulae must be increased by 1.

While we're here, DRY things up and improve some naming to be more readable/obvious.

@MikeMcQuaid MikeMcQuaid force-pushed the audit_revision_and_compatibility_version_relationships branch from d7bae0f to 21b5d67 Compare October 28, 2025 17:40
@MikeMcQuaid MikeMcQuaid marked this pull request as ready for review October 28, 2025 17:40
Copilot AI review requested due to automatic review settings October 28, 2025 17: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 adds support for auditing compatibility_version changes in formulae and extends the existing revision audit to validate dependency relationships.

  • Introduces a new audit_compatibility_version method that ensures compatibility versions don't decrease and only increment by 1, and that dependent formulae bump their revisions accordingly
  • Extends audit_revision to validate that when a formula's revision increases, changed dependencies must have their compatibility_version incremented by 1
  • Refactors version info caching and adds a changed_formulae_paths helper method to identify changed formulae in a tap

Reviewed Changes

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

File Description
Library/Homebrew/formula_auditor.rb Adds audit_compatibility_version method, extends audit_revision with dependency validation, adds changed_formulae_paths helper, and refactors version info caching to support multiple formulae
Library/Homebrew/test/formula_auditor_spec.rb Adds comprehensive test coverage for both compatibility_version audits and revision-dependency relationship validation, including new test helper methods for formula creation and stubbing

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

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.

I think this approach looks good! I do think there's a few places where the wrong output from committed_version_info is being used, though.

It's possible that I'm misunderstanding, though, so feel free to correct me if I'm wrong here

@MikeMcQuaid MikeMcQuaid force-pushed the audit_revision_and_compatibility_version_relationships branch from 4c7716e to 5c0782d Compare October 29, 2025 09:20
@MikeMcQuaid MikeMcQuaid requested a review from Copilot October 29, 2025 09:30
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 2 out of 2 changed files in this pull request and generated 3 comments.


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

@MikeMcQuaid MikeMcQuaid force-pushed the audit_revision_and_compatibility_version_relationships branch from 5c0782d to 99ccfd7 Compare October 31, 2025 14:36
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 2 out of 2 changed files in this pull request and generated 2 comments.


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

Add a new audit method to check if the `revision` and
`compatibility_version` are consistent with each other.

This ensures that when a formula's `compatibility_version` is
increased, the `revision` of dependent formulas was also increased.

Inversely, when a formula's `revision` is increased in the same PR as
one of its dependencies, the `compatibility_version` of dependent
formulae must be increased by 1.

While we're here, DRY things up and improve some naming to me more
readable/obvious.

Co-authored-by: Rylan Polster <[email protected]>
@MikeMcQuaid MikeMcQuaid force-pushed the audit_revision_and_compatibility_version_relationships branch from 99ccfd7 to 3871cc0 Compare October 31, 2025 14:46
@MikeMcQuaid MikeMcQuaid requested a review from Copilot October 31, 2025 14:46
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 2 out of 2 changed files in this pull request and generated 1 comment.


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

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 great, I love the naming! Thanks for sticking through my nits 😅

One final set of comments, I still think there's a small edge case that's not handled, but I think it's unlikely (and potentially impossible) to get to this situation, so feel free to ignore

previous_version_info, origin_head_version_info = committed_version_info
return if origin_head_version_info.empty?

previous_compatibility_version = previous_version_info[:compatibility_version] || 0
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
previous_compatibility_version = previous_version_info[:compatibility_version] || 0
previous_compatibility_version = origin_head_version_info[:compatibility_version] || 0

Because committed_version_info doesn't stop iterating when compatibility_version changes, I think we need to use origin_head_version_info here to protect against cases like this:

version revision compatibility_version
current 1.0.0 1 0
origin/HEAD 1.0.0 1 1
previous 1.0.0 0 0

Right now, the compatibility_version should not decrease problem won't trigger because current_compatibility_version == previous_compatibility_version == 0, and also compatibility_increment == 0.

current_version_scheme = formula.version_scheme

previous_committed, = committed_version_info
previous_version_info, = committed_version_info
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
previous_version_info, = committed_version_info
_, origin_head_version_info = committed_version_info

Same thing here, this allows the following:

version revision version_scheme
current 1.0.0 1 0
origin/HEAD 1.0.0 1 1
previous 1.0.0 0 0

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