From bdeee89132457fb2ae8ccdb8e744d511fe69447c Mon Sep 17 00:00:00 2001 From: Steven Borrelli Date: Thu, 8 Oct 2026 16:27:57 +0200 Subject: [PATCH] Strip the generator version stamp from generated protos protobuf-check fails on routine dependency PRs. ts-proto writes its own version and protoc's into a "// versions:" header block in every generated file, so bumping ts-proto rewrites those three comment lines, the CI drift check sees changes under src, and the PR goes red until someone regenerates and commits. Measured on the open renovate PR #45 (ts-proto 2.12.4 -> 2.13.0), that is the entire diff: three files, one comment line each, no generated code change at all. Drop the version block in scripts/protoc-gen.sh after generation, so the output depends only on the .proto input and the generator flags -- which is what the check is meant to police. The versions themselves stay recorded in package.json and in the workflow's protoc pin, and the "Code generated ... DO NOT EDIT" and "source:" header lines are untouched. Verified: with this change, regenerating under ts-proto 2.13.0 produces no diff, while adding a field to run_function.proto is still caught. Also add set -euo pipefail, so a protoc failure stops the run rather than leaving half-generated output for the post-processing step to rewrite. Co-Authored-By: Claude Opus 5 Signed-off-by: Steven Borrelli --- scripts/protoc-gen.sh | 23 +++++++++++++++++++++-- src/proto/google/protobuf/duration.ts | 3 --- src/proto/google/protobuf/struct.ts | 3 --- src/proto/run_function.ts | 3 --- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/scripts/protoc-gen.sh b/scripts/protoc-gen.sh index 3bb554c..f34945e 100755 --- a/scripts/protoc-gen.sh +++ b/scripts/protoc-gen.sh @@ -1,8 +1,9 @@ #!/bin/bash -set -x +set -euo pipefail +set -x -rm -rf ./src/proto/*.js ./src/proto/*.ts +rm -rf ./src/proto/*.js ./src/proto/*.ts protoc \ --plugin=./node_modules/.bin/protoc-gen-ts_proto \ @@ -11,3 +12,21 @@ protoc \ --proto_path=./src/proto \ ./src/proto/run_function.proto +# Strip the generator version stamp from the header of every generated file. +# +# ts-proto records its own version and protoc's in a "// versions:" block. That +# makes the output change on every dependency bump even when the generated code +# is identical, so the CI drift check fails on routine renovate PRs and someone +# has to regenerate and commit three lines of comment to make it green. +# +# Dropping the block makes the output depend only on the .proto input and the +# generator flags, which is what the check is meant to police. The versions +# themselves stay recorded in package.json and the workflow's protoc pin. +find ./src/proto -name '*.ts' -print0 | while IFS= read -r -d '' f; do + sed -i.bak \ + -e '/^\/\/ versions:$/d' \ + -e '/^\/\/ protoc-gen-ts_proto /d' \ + -e '/^\/\/ protoc /d' \ + "$f" + rm -f "$f.bak" +done diff --git a/src/proto/google/protobuf/duration.ts b/src/proto/google/protobuf/duration.ts index b7fd24e..44f3779 100644 --- a/src/proto/google/protobuf/duration.ts +++ b/src/proto/google/protobuf/duration.ts @@ -1,7 +1,4 @@ // Code generated by protoc-gen-ts_proto. DO NOT EDIT. -// versions: -// protoc-gen-ts_proto v2.12.4 -// protoc v7.36.2 // source: google/protobuf/duration.proto /* eslint-disable */ diff --git a/src/proto/google/protobuf/struct.ts b/src/proto/google/protobuf/struct.ts index 64a5733..1d19635 100644 --- a/src/proto/google/protobuf/struct.ts +++ b/src/proto/google/protobuf/struct.ts @@ -1,7 +1,4 @@ // Code generated by protoc-gen-ts_proto. DO NOT EDIT. -// versions: -// protoc-gen-ts_proto v2.12.4 -// protoc v7.36.2 // source: google/protobuf/struct.proto /* eslint-disable */ diff --git a/src/proto/run_function.ts b/src/proto/run_function.ts index 7d517b5..7a52474 100644 --- a/src/proto/run_function.ts +++ b/src/proto/run_function.ts @@ -1,7 +1,4 @@ // Code generated by protoc-gen-ts_proto. DO NOT EDIT. -// versions: -// protoc-gen-ts_proto v2.12.4 -// protoc v7.36.2 // source: run_function.proto /* eslint-disable */