Update buf breaking checks to support extensions#2960
Merged
Conversation
…on top-level extensions
bufdev
approved these changes
May 13, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is really two non-trivial changes. I've broken them up into multiple commits to (hopefully) make it easier to review.
The vast majority of changed lines are test data and test expectations (~1300 out of 1600 LOC). They are in their own commits (the third and fifth), in case you preferred focus a review on the other changes.
For the latter, since extensions are not defined in their containing message, they represent elements that a FILE check must verify aren't changed/deleted. A PACKAGE check allows them to move between files but not be changed/moved otherwise. These rules effectively consider the "identity" of the extension to be its fully-qualified name.
But all of the other checks assume the field's identity is its containing message plus number. That happens to be true of extensions, too: they can be uniquely identified by both fully-qualified name and by containing message + tag number.
The thing in here that might be a little odd is the FIELD_SAME_NAME check: it checks the fully-qualified name for extensions. So if you did rename an extension (or move it to a different package or nest it in a different message), you'll get a FIELD_SAME_NAME violation using just WIRE_JSON category. But you'll get that error plus an EXTENSION_NO_DELETE or PACKAGE_EXTENSION_NO_DELETE violation if using FILE or PACKAGE category. Is that weird?