Skip to content

Commit ccceea5

Browse files
committed
refactor: limit protobuf package replacement to superclass only
Since all consumers now import the version-agnostic Metrics class, only the superclass file needs updating when the protobuf version changes. Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
1 parent 6430666 commit ccceea5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

prometheus-metrics-exposition-formats/generate-protobuf.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ mkdir -p $PROTO_DIR
2121
OLD_PACKAGE=$(sed -nE 's/.*extends (io\.prometheus\.metrics\.expositionformats\.generated\.[^ ]*?)\.Metrics.*/\1/p' src/main/java/io/prometheus/metrics/expositionformats/generated/Metrics.java)
2222
PACKAGE="io.prometheus.metrics.expositionformats.generated.com_google_protobuf_${PROTOBUF_VERSION_STRING}"
2323

24+
SUPERCLASS_FILE="src/main/java/io/prometheus/metrics/expositionformats/generated/Metrics.java"
2425
if [[ $OLD_PACKAGE != "$PACKAGE" ]]; then
25-
echo "Replacing package $OLD_PACKAGE with $PACKAGE in all java files"
26-
find .. -type f -name "*.java" -exec sed -i "s/$OLD_PACKAGE/$PACKAGE/g" {} +
26+
echo "Replacing package $OLD_PACKAGE with $PACKAGE in $SUPERCLASS_FILE"
27+
sed -i "s/$OLD_PACKAGE/$PACKAGE/g" "$SUPERCLASS_FILE"
2728
fi
2829

2930
curl -sL https://raw.githubusercontent.com/prometheus/client_model/master/io/prometheus/client/metrics.proto -o $PROTO_DIR/metrics.proto

0 commit comments

Comments
 (0)