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 <michalx.berger@intel.com> Change-Id: Ie0d4e35b8ad214ceed1b4ea29b01a7423b8ff73b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6824 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
d515bf739d
commit
0968ee2fcf
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user