check_format.sh: only use specific v3.1.0 shfmt version

Our CI explicitly uses v3.1.0 shfmt.  Other versions,
including newer versions, may suggest a lot of script
changes that are different than what v3.1.0 reports.
So change check_format.sh to *only* run shfmt
checking if the version is exactly v3.1.0.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I788961faaae7992cf1369abf1e54f4075bd2521c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12309
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Pawel Piatek <pawelx.piatek@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Jim Harris 2022-04-18 22:12:51 +00:00 committed by Tomasz Zawadzki
parent ac7b9b7c66
commit 6e2ba81ee7

View File

@ -417,9 +417,13 @@ function check_bash_style() {
local rc=0
# find compatible shfmt binary
shfmt_bins=$(compgen -c | grep '^shfmt' || true)
shfmt_bins=$(compgen -c | grep '^shfmt' | uniq || true)
for bin in $shfmt_bins; do
if version_lt "$("$bin" --version)" "3.1.0"; then
shfmt_version=$("$bin" --version)
if [ $shfmt_version != "v3.1.0" ]; then
echo "$bin version $shfmt_version not used (only v3.1.0 is supported)"
echo "v3.1.0 can be installed using 'scripts/pkgdep.sh -d'"
else
shfmt=$bin
break
fi
@ -471,7 +475,7 @@ function check_bash_style() {
fi
fi
else
echo "shfmt not detected, Bash style formatting check is skipped"
echo "Supported version of shfmt not detected, Bash style formatting check is skipped"
fi
return $rc