From 0968ee2fcf7409cf50177d4f8f0234c6db2c94d5 Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Wed, 10 Mar 2021 14:29:03 +0100 Subject: [PATCH] scripts/check_format: Run shfmt against all bash files Currently, reference repos which are used to clone the SPDK repo in the CI pool's systems don't provide master head refs, hence there's no easy way to diff against it. Instead, simply run shfmt against all the bash files in the repo. Impact on the performance should be minimal. Also, cleanup some related code which is not used anymore. Signed-off-by: Michal Berger Change-Id: Ie0d4e35b8ad214ceed1b4ea29b01a7423b8ff73b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6824 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Ben Walker --- scripts/check_format.sh | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/scripts/check_format.sh b/scripts/check_format.sh index 1447d807d..aace77a09 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -396,31 +396,13 @@ function check_bash_style() { done if [ -n "$shfmt" ]; then - shfmt_cmdline=() silly_plural=() + shfmt_cmdline=() sh_files=() - silly_plural[1]="s" - - commits=() sh_files=() sh_files_repo=() sh_files_staged=() - 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") - done < <(git cherry -v origin/master) - - mapfile -t sh_files < <(git diff --name-only HEAD origin/master "${sh_files_repo[@]}") - # In case of a call from a pre-commit git hook - mapfile -t sh_files_staged < <( - IFS="|" - git diff --cached --name-only "${sh_files_repo[@]}" | grep -v "${sh_files[*]}" - ) + mapfile -t sh_files < <(get_bash_files) if ((${#sh_files[@]})); then printf 'Checking .sh formatting style...' - if ((${#sh_files_staged[@]})); then - sh_files+=("${sh_files_staged[@]}") - fi - shfmt_cmdline+=(-i 0) # indent_style = tab|indent_size = 0 shfmt_cmdline+=(-bn) # binary_next_line = true shfmt_cmdline+=(-ci) # switch_case_indent = true