Skip to content

Commit 63ef902

Browse files
authoredNov 15, 2024
Update go version checker (#1474)
* Handle new files (old version is empty) * Handle the case where .0 patch is added/removed Signed-off-by: Todd Short <tshort@redhat.com>
1 parent 39e7dd5 commit 63ef902

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed
 

‎hack/tools/check-go-version.sh

+10-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ check_version () {
3232
echo "${file}: ${whole}: Bad golang version (expected ${GO_VER} or less)"
3333
return 1
3434
fi
35-
35+
3636
if [ ${#ver[*]} -eq 2 ] ; then
3737
return 0
3838
fi
@@ -63,8 +63,15 @@ for f in $(find . -name "*.mod"); do
6363
old=${old#go }
6464
new=$(git grep -ohP '^go .*$' "${f}")
6565
new=${new#go }
66-
# If ${old} is empty, it means this is a new file
67-
if [ "${new}" != "${old}" -a -n "${old}" ]; then
66+
# If ${old} is empty, it means this is a new .mod file
67+
if [ -z "${old}" ]; then
68+
continue
69+
fi
70+
# Check if patch version remains 0: X.x.0 <-> X.x
71+
if [ "${new}.0" == "${old}" -o "${new}" == "${old}.0" ]; then
72+
continue
73+
fi
74+
if [ "${new}" != "${old}" ]; then
6875
echo "${f}: ${v}: Updated golang version from ${old}"
6976
RETCODE=1
7077
fi

0 commit comments

Comments
 (0)