Verified Commit f5c9ea23 authored by Rahix's avatar Rahix
Browse files

fix(code-style): Use a blacklist instead of a big if block


Co-authored-by: Mateusz Zalega's avatarMateusz Zalega <mateusz@appliedsourcery.com>
Signed-off-by: Rahix's avatarRahix <rahix@rahix.de>
parent 1bb79811
......@@ -37,21 +37,40 @@ fi
script_dir="$(dirname "$0")"
formatter_blacklist=(
lib/ff13/
lib/FreeRTOS/
lib/FreeRTOS-Plus/
lib/gfx/
lib/micropython/
lib/mx25lba/
lib/sdk/
lib/vendor/
openocd/
docker/
)
for source_file in "$@"; do
# Check if file is actually one which we want to check
rel_path="$(realpath --relative-to="$script_dir/.." "$source_file")"
if [[ ( "$rel_path" == lib/* && "$rel_path" != lib/card10/* ) ||
( "$rel_path" == openocd/* ) ]]; then
echo " - Ignoring $source_file"
format_item=true
for blacklist_item in "${formatter_blacklist[@]}"; do
if [[ "$rel_path" == "$blacklist_item"* ]]; then
format_item=false
break
fi
done
if [[ "$format_item" == false ]]; then
echo -e "\tIGN\t\t$source_file"
continue
fi
if [[ "$source_file" == *.c ]]; then
echo " - Formatting $source_file ..."
echo -e "\tCLANG-FORMAT\t$source_file"
clang-format -i "$source_file"
python3 "$script_dir/fix-multi-decl.py" "$source_file"
elif [[ "$source_file" == *.py ]]; then
echo " - Formatting $source_file ..."
echo -e "\tBLACK\t\t$source_file"
black -q "$source_file"
else
echo " - Ignoring $source_file" >&2
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment