From d3a97f6e3959997b8466e7ee2051fb815605d549 Mon Sep 17 00:00:00 2001 From: Derek Su Date: Mon, 26 Feb 2024 14:05:45 +0000 Subject: [PATCH] ci: fix the check of proto codes Longhorn 7985 Signed-off-by: Derek Su --- scripts/validate | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/validate b/scripts/validate index 95da6dec5..b5d69c65b 100755 --- a/scripts/validate +++ b/scripts/validate @@ -7,11 +7,20 @@ cd "$(dirname $0)"/.. echo Running proto validation -output=$(git diff --stat|grep -e '.pb.go' -e '_pb2.py' -e '_pb2_grpc.py') -if [ $? -eq 0 ] -then - echo $output - echo GRPC generated code is not up to date +check_proto_generated_code() { + local output=$(git diff --stat | grep -q -e '.pb.go' -e '_pb2.py' -e '_pb2_grpc.py') + if [ -z "$output" ]; then + return 0 + else + return 1 + fi +} + +check_proto_generated_code +if [ $? -eq 0 ]; then + echo "GRPC generated code is up to date" +else + echo "GRPC generated code is not up to date" exit 1 fi