Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/signals/path-matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ function isGeneratedFileFrom(parts: NormalizedPath): boolean {
// 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`
// `.pbobjc.{h,m}` plus gRPC `.pbrpc.{h,m}` service stubs (some layouts spell these
// `.pb.objc.{h,m}` instead). Swift gRPC emits sibling `.grpc.swift`
// service stubs; grpc-kotlin emits sibling `*GrpcKt.kt` coroutine service stubs; grpc-java emits
// sibling `*Grpc.java` service stubs; grpc-dotnet emits sibling `*Grpc.cs` service stubs; the Dart
// gRPC plugin emits sibling `.pbgrpc.dart` service stubs.
Expand All @@ -91,6 +92,8 @@ function isGeneratedFileFrom(parts: NormalizedPath): boolean {
/grpc\.cs$/.test(norm) ||
/\.pbgrpc\.dart$/.test(norm) ||
/\.pbobjc\.(h|m)$/.test(norm) ||
/\.pb\.objc\.(h|m)$/.test(norm) ||
/\.pb\.m$/.test(norm) ||
/\.pbrpc\.(h|m)$/.test(norm) ||
// Python protobuf: message stubs are `*_pb2.py[i]`; the gRPC plugin emits sibling
// `*_pb2_grpc.py[i]` service stubs, which are the same machine-generated output.
Expand Down
12 changes: 12 additions & 0 deletions test/unit/path-matchers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ describe("isGeneratedFile", () => {
expect(classifyChangedFile("gen/service_pb.d.ts")).toBe("generated");
});

it("matches alternate Objective-C protobuf spellings alongside pbobjc output", () => {
expect(isGeneratedFile("proto/foo.pb.objc.h")).toBe(true);
expect(isGeneratedFile("proto/messages.pb.objc.m")).toBe(true);
expect(isGeneratedFile("proto/messages.pb.m")).toBe(true);
expect(isGeneratedFile("src/App.m")).toBe(false);
expect(isGeneratedFile("src/App.h")).toBe(false);
expect(classifyChangedFile("proto/foo.pb.objc.h")).toBe("generated");
expect(classifyChangedFile("proto/messages.pb.m")).toBe("generated");
});

it("matches Swift protobuf, Dart freezed/retrofit, C# designer/XAML, and Objective-C protoc output", () => {
for (const path of [
"proto/messages.pb.swift",
Expand Down Expand Up @@ -546,6 +556,8 @@ describe("classifyChangedFile", () => {
["gen/GreeterGrpcKt.kt", "generated"],
["gen/GreeterGrpc.java", "generated"],
["proto/messages.pb.java", "generated"],
["proto/foo.pb.objc.h", "generated"],
["proto/messages.pb.m", "generated"],
["gen/GreeterGrpc.cs", "generated"],
["lib/foo.pbgrpc.dart", "generated"],
["gen/service_grpc_pb.js", "generated"],
Expand Down