Provides a script to clang-format the repository in parallel
This commit is contained in:
parent
69bc8a8b22
commit
19ac465fa4
22
scripts/format.sh
Executable file
22
scripts/format.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Runs the Clang Formatter in parallel on the code base.
|
||||
# Return codes:
|
||||
# - 1 there are files to be formatted
|
||||
# - 0 everything looks fine
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
find src include unit_tests example -type f -name '*.hpp' -o -name '*.cpp' \
|
||||
| xargs -I{} -P $(nproc) clang-format -i -style=file {}
|
||||
|
||||
|
||||
dirty=$(git ls-files --modified)
|
||||
|
||||
if [[ $dirty ]]; then
|
||||
echo "The following files do not adhere to the .clang-format style file:"
|
||||
echo $dirty
|
||||
exit 1
|
||||
else
|
||||
exit 0
|
||||
fi
|
Loading…
Reference in New Issue
Block a user