Skip to content

Commit

Permalink
try this
Browse files Browse the repository at this point in the history
  • Loading branch information
vilhelmprytz authored May 6, 2024
1 parent 9b4a324 commit 7e9635b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions check-format.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#!/bin/bash

# Find all C++ files and run clang-format on them
find . -regex '.*\.\(cpp\|hpp\|c\|h\)' -exec clang-format -style=file -output-replacements-xml {} + | grep "<replacement " >/dev/null
start_dir="."
echo "Starting format check in directory: $start_dir"

file_count=$(find $start_dir -type f \( -iname "*.cpp" -or -iname "*.hpp" -or -iname "*.c" -or -iname "*.h" \) -not -path "./external/*" | wc -l)
echo "Total files to check: $file_count"

find $start_dir -type f \( -iname "*.cpp" -or -iname "*.hpp" -or -iname "*.c" -or -iname "*.h" \) -not -path "./external/*" -exec echo "Processing file: {}" \; -exec clang-format -style=file -output-replacements-xml {} + | grep "<replacement " >/dev/null
if [ $? -ne 1 ]; then
echo "Code formatting differs from clang-format's style"
exit 1
else
echo "All files formatted correctly."
fi

0 comments on commit 7e9635b

Please sign in to comment.