fix(gazelle): generate target names from proto file name, not directory #128
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 PR stacks on top of !127 but I've split them as the rationale is different / you might not agree with both (let me know!). The issue of this PR was uncovered in !127 fix of #117. This PR Plus !127 resolve at least the base case issues of #117.
Fix target name generation in the buf gazelle plugin's
CrossResolvefunction to use the proto file name instead of the directory name. This aligns with the official Bazel proto_library naming convention documented at: https://bazel.build/reference/be/protocol-bufferPer Bazel's convention: "A file named foo.proto will be in a rule named foo_proto, which is located in the same package."
The original code used
proto.RuleName(path.Dir(importSpec.Imp))which incorrectly derived target names from the directory path.Example import:
logical/interface.protoBefore (wrong):
@buf_deps//logical:logical_proto(from directory)After (correct):
@buf_deps//logical:interface_proto(from file)Co-Authored-By: Claude Opus 4.5 [email protected]