From a4a90526f20689f43f0785cd6842f3e31f6b06d2 Mon Sep 17 00:00:00 2001 From: jimcody1995 Date: Mon, 6 Jul 2026 09:11:18 +0200 Subject: [PATCH] fix(signals): classify Java protobuf message stubs as generated Recognize protoc Java .pb.java message stubs in isGeneratedFile alongside the existing grpc-java *Grpc.java service stub matcher. Co-authored-by: Cursor --- src/signals/path-matchers.ts | 4 ++-- test/unit/path-matchers.test.ts | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/signals/path-matchers.ts b/src/signals/path-matchers.ts index 0130c34a3c..dd664e903f 100644 --- a/src/signals/path-matchers.ts +++ b/src/signals/path-matchers.ts @@ -76,7 +76,7 @@ function isGeneratedFileFrom(parts: NormalizedPath): boolean { /\.(generated|gen)\.[^/]+$/.test(norm) || // protoc output: Go/TS/JS plugins emit `.pb.{go,ts,js}`, the reference C++ plugin emits // `.pb.cc` / `.pb.h`, the Swift plugin emits `.pb.swift`, the Dart plugin emits `.pb.dart`, - // the Kotlin plugin emits `.pb.kt`, the C# plugin emits `.pb.cs`, the Rust plugin emits `.pb.rs`, + // the Kotlin plugin emits `.pb.kt`, the Java plugin emits `.pb.java`, the C# plugin emits `.pb.cs`, the Rust plugin emits `.pb.rs`, // the Elixir plugin emits `.pb.ex`, the Erlang gpb plugin emits `.pb.erl` / `.pb.hrl`, the Crystal // plugin emits `.pb.cr`, the Haskell plugin emits `.pb.hs`, the Scala plugin emits `.pb.scala`, and the Objective-C plugin emits // `.pbobjc.{h,m}` plus gRPC `.pbrpc.{h,m}` service stubs. Swift gRPC emits sibling `.grpc.swift` @@ -84,7 +84,7 @@ function isGeneratedFileFrom(parts: NormalizedPath): boolean { // sibling `*Grpc.java` service stubs; grpc-dotnet emits sibling `*Grpc.cs` service stubs; the Dart // gRPC plugin emits sibling `.pbgrpc.dart` service stubs. // `.pb.dart`/`.pb.kt`/`.pb.cs` (the `.pb` infix keeps hand-written sources from matching). - /\.pb\.(go|ts|js|cc|h|swift|dart|kt|cs|rs|ex|erl|hrl|cr|hs|scala)$/.test(norm) || + /\.pb\.(go|ts|js|cc|h|swift|dart|kt|cs|rs|ex|erl|hrl|cr|hs|scala|java)$/.test(norm) || /\.grpc\.swift$/.test(norm) || /grpckt\.kt$/.test(norm) || /grpc\.java$/.test(norm) || diff --git a/test/unit/path-matchers.test.ts b/test/unit/path-matchers.test.ts index cefe1b4029..0784b26778 100644 --- a/test/unit/path-matchers.test.ts +++ b/test/unit/path-matchers.test.ts @@ -180,6 +180,12 @@ describe("isGeneratedFile", () => { expect(classifyChangedFile("lib/foo.pbgrpc.dart")).toBe("generated"); }); + it("matches Java protobuf message stubs alongside the other protoc plugins", () => { + expect(isGeneratedFile("proto/messages.pb.java")).toBe(true); + expect(isGeneratedFile("src/Main.java")).toBe(false); + expect(classifyChangedFile("proto/messages.pb.java")).toBe("generated"); + }); + it("matches Java gRPC service stubs alongside the other protoc plugins", () => { expect(isGeneratedFile("gen/GreeterGrpc.java")).toBe(true); expect(isGeneratedFile("src/Greeter.java")).toBe(false); @@ -533,6 +539,7 @@ describe("classifyChangedFile", () => { ["proto/messages.pb.scala", "generated"], ["gen/GreeterGrpcKt.kt", "generated"], ["gen/GreeterGrpc.java", "generated"], + ["proto/messages.pb.java", "generated"], ["gen/GreeterGrpc.cs", "generated"], ["lib/foo.pbgrpc.dart", "generated"], ["gen/service_grpc_pb.js", "generated"],