Skip to content

Commit ae151e9

Browse files
fix(signals): classify Rust prost/tonic underscore protobuf stubs as generated (#3782)
Recognize *_pb.rs and *_grpc_pb.rs alongside the existing .pb.rs matcher so replay/snapshot diff classification treats prost/tonic underscore output as machine-generated. Fixes #3010 Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 65ab16a commit ae151e9

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/signals/path-matchers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ function isGeneratedFileFrom(parts: NormalizedPath): boolean {
8181
// `.pb.cc` / `.pb.h`, the Swift plugin emits `.pb.swift`, the Dart plugin emits `.pb.dart`,
8282
// the Kotlin plugin emits `.pb.kt`, the Java plugin emits `.pb.java`, the C# plugin emits `.pb.cs`, the Rust plugin emits `.pb.rs`,
8383
// the Elixir plugin emits `.pb.ex`, the Erlang gpb plugin emits `.pb.erl` / `.pb.hrl`, the Crystal
84-
// plugin emits `.pb.cr`, the Haskell plugin emits `.pb.hs`, the Scala plugin emits `.pb.scala`, and the Objective-C plugin emits
84+
// plugin emits `.pb.cr`, the Haskell plugin emits `.pb.hs`, the Scala plugin emits `.pb.scala`, the Rust
85+
// plugin emits `.pb.rs` (and prost/tonic also emit underscore `*_pb.rs` / `*_grpc_pb.rs` siblings), and the Objective-C plugin emits
8586
// `.pbobjc.{h,m}` plus gRPC `.pbrpc.{h,m}` service stubs. Swift gRPC emits sibling `.grpc.swift`
8687
// service stubs; grpc-kotlin emits sibling `*GrpcKt.kt` coroutine service stubs; grpc-java emits
8788
// sibling `*Grpc.java` service stubs; grpc-dotnet emits sibling `*Grpc.cs` service stubs; the Dart
@@ -111,6 +112,9 @@ function isGeneratedFileFrom(parts: NormalizedPath): boolean {
111112
/_pb\.lua$/.test(norm) ||
112113
// Perl protobuf: message stubs are `*_pb.pm`.
113114
/_pb\.pm$/.test(norm) ||
115+
// Rust prost/tonic underscore stubs: `*_pb.rs` message output; tonic gRPC emits sibling `*_grpc_pb.rs`.
116+
/_pb\.rs$/.test(norm) ||
117+
/_grpc_pb\.rs$/.test(norm) ||
114118
// JavaScript/TypeScript grpc-node protobuf: message stubs are `*_pb.{js,ts,d.ts}`; gRPC emits
115119
// sibling `*_grpc_pb.{js,ts,d.ts}` service stubs (underscore form, not `.pb.js`).
116120
/_pb\.(js|ts)$/.test(norm) ||

test/unit/path-matchers.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ describe("isGeneratedFile", () => {
169169
expect(classifyChangedFile("proto/messages.pb.scala")).toBe("generated");
170170
});
171171

172+
it("matches Rust prost/tonic underscore protobuf stubs alongside the dot-pb spellings", () => {
173+
expect(isGeneratedFile("gen/service_pb.rs")).toBe(true);
174+
expect(isGeneratedFile("gen/service_grpc_pb.rs")).toBe(true);
175+
expect(isGeneratedFile("src/lib.rs")).toBe(false);
176+
expect(isGeneratedFile("src/main.rs")).toBe(false);
177+
expect(classifyChangedFile("gen/service_pb.rs")).toBe("generated");
178+
expect(classifyChangedFile("gen/service_grpc_pb.rs")).toBe("generated");
179+
});
180+
172181
it("matches Kotlin gRPC coroutine stubs alongside the other protoc plugins", () => {
173182
expect(isGeneratedFile("gen/GreeterGrpcKt.kt")).toBe(true);
174183
expect(isGeneratedFile("src/Greeter.kt")).toBe(false);
@@ -543,6 +552,8 @@ describe("classifyChangedFile", () => {
543552
["gen/service_pb.lua", "generated"],
544553
["gen/service_pb.pm", "generated"],
545554
["proto/messages.pb.scala", "generated"],
555+
["gen/service_pb.rs", "generated"],
556+
["gen/service_grpc_pb.rs", "generated"],
546557
["gen/GreeterGrpcKt.kt", "generated"],
547558
["gen/GreeterGrpc.java", "generated"],
548559
["proto/messages.pb.java", "generated"],

0 commit comments

Comments
 (0)