Skip to content

Commit

Permalink
tools: Improve uncrustify filtering algorithm (#21)
Browse files Browse the repository at this point in the history
Instead of deiniting git submodules, use `git submodule status` to find
the list of exclude directories.

Signed-off-by: Devaraj Ranganna <[email protected]>
  • Loading branch information
urutva authored Nov 24, 2023
1 parent 1d45b35 commit 0e537a4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
21 changes: 18 additions & 3 deletions Tools/scripts/run_uncrustify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
# <[email protected]>
# SPDX-License-Identifier: MIT

git submodule deinit --all -f
find . -iname "*.[hc]" -exec uncrustify --replace --no-backup --if-changed -c Tools/uncrustify.cfg -l C {} +
git submodule update --init --recursive
# Ensure the new line is used to split the output of the `git submodule status`
# command into an array
IFS=$'\n'

submodules_status=($(git submodule status))

exclude_pattern="-E "
for submodule_status in "${submodules_status[@]}"
do
# Ensure the space is used to split the submodule status into an array
IFS=" "
submodule_status_parts=($submodule_status)
submodule_path = "${submodule_status_parts[1]}"
exclude_pattern+="${submodule_path} -E "
done
exclude_pattern+="./build"

fdfind -E $exclude_pattern -e c -e h --exec uncrustify --no-backup --replace --if-changed -c Tools/uncrustify.cfg -l C
2 changes: 2 additions & 0 deletions ci/pipeline-baseline-fri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ pre-commit:
stage: quality-check
script:
- pip install . -t $PWD
- apt-get update -y
- apt-get install fd-find -y
- cp $PWD/bin/banned-api-hook $PWD/banned-api-hook
- export PATH="$PWD:$PATH";
- pre-commit run --all-files --verbose --show-diff-on-failure
Expand Down
1 change: 1 addition & 0 deletions release_changes/202311221345.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tools: Improve `uncrustify` filtering algorithm

0 comments on commit 0e537a4

Please sign in to comment.