Provides a script to clang-format the repository in parallel

This commit is contained in:
Daniel J. Hofmann 2016-02-01 15:36:08 +01:00 committed by Patrick Niklaus
parent 69bc8a8b22
commit 19ac465fa4

22
scripts/format.sh Executable file
View 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