From 529f3058bb14a16652822dc8075a95ab2f24e787 Mon Sep 17 00:00:00 2001 From: Todd Short Date: Fri, 15 Nov 2024 10:25:08 -0500 Subject: [PATCH] Update go version checker * Handle new files (old version is empty) * Handle the case where .0 patch is added/removed Signed-off-by: Todd Short --- hack/scripts/check-go-version.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hack/scripts/check-go-version.sh b/hack/scripts/check-go-version.sh index 4482983b..307f203d 100755 --- a/hack/scripts/check-go-version.sh +++ b/hack/scripts/check-go-version.sh @@ -63,6 +63,14 @@ for f in $(find . -name "*.mod"); do old=${old#go } new=$(git grep -ohP '^go .*$' "${f}") new=${new#go } + # If ${old} is empty, it means this is a new .mod file + if [ -z "${old}" ]; then + continue + fi + # Check if patch version remains 0: X.x.0 <-> X.x + if [ "${new}.0" == "${old}" -o "${new}" == "${old}.0" ]; then + continue + fi if [ "${new}" != "${old}" ]; then echo "${f}: ${v}: Updated golang version from ${old}" RETCODE=1