Skip to content

Commit

Permalink
Update go version checker (#1474)
Browse files Browse the repository at this point in the history
* Handle new files (old version is empty)
* Handle the case where .0 patch is added/removed

Signed-off-by: Todd Short <tshort@redhat.com>
  • Loading branch information
tmshort authored Nov 15, 2024
1 parent 39e7dd5 commit 63ef902
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions hack/tools/check-go-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ check_version () {
echo "${file}: ${whole}: Bad golang version (expected ${GO_VER} or less)"
return 1
fi

if [ ${#ver[*]} -eq 2 ] ; then
return 0
fi
Expand Down Expand Up @@ -63,8 +63,15 @@ 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 file
if [ "${new}" != "${old}" -a -n "${old}" ]; then
# 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
fi
Expand Down

0 comments on commit 63ef902

Please sign in to comment.