From e7ab45baf7dbbce9685c04e206f13ffd9ed04da0 Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Thu, 21 Jan 2021 12:50:53 +0100 Subject: [PATCH] check_format: Include all potential bash scripts from the repo Checking only the .sh suffix was omitting ./configure and potentially other bash scripts which don't necessarily have to include said suffix in their name. Signed-off-by: Michal Berger Change-Id: I6196559e8875de46f80d9c8426577a1a79b5996d Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6026 Tested-by: SPDK CI Jenkins Reviewed-by: Paul Luse Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Karol Latecki Reviewed-by: Tomasz Zawadzki --- scripts/check_format.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/check_format.sh b/scripts/check_format.sh index b522115340..1447d807da 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -374,6 +374,15 @@ function check_python_style() { return $rc } +function get_bash_files() { + local sh shebang + + mapfile -t sh < <(git ls-files '*.sh') + mapfile -t shebang < <(git grep -l '^#!.*bash') + + printf '%s\n' "${sh[@]}" "${shebang[@]}" | sort -u +} + function check_bash_style() { local rc=0 @@ -392,8 +401,7 @@ function check_bash_style() { silly_plural[1]="s" commits=() sh_files=() sh_files_repo=() sh_files_staged=() - - mapfile -t sh_files_repo < <(git ls-files '*.sh') + mapfile -t sh_files_repo < <(get_bash_files) # Fetch .sh files only from the commits that are targeted for merge while read -r _ commit; do commits+=("$commit") @@ -504,7 +512,7 @@ SC2119,SC2120,SC2148,SC2153,SC2154,SC2164,SC2174,SC2001,SC2206,SC2207,SC2223" SHCK_APPLY=false SHCH_ARGS=" -x -e $SHCK_EXCLUDE -f $SHCK_FORMAT" - git ls-files '*.sh' | xargs -P$(nproc) -n1 shellcheck $SHCH_ARGS &> shellcheck.log + get_bash_files | xargs -P$(nproc) -n1 shellcheck $SHCH_ARGS &> shellcheck.log if [[ -s shellcheck.log ]]; then echo " Bash formatting errors detected!"