From 19ac465fa48577e29dbebb3e7b28e7d4b79d7fed Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Mon, 1 Feb 2016 15:36:08 +0100 Subject: [PATCH] Provides a script to clang-format the repository in parallel --- scripts/format.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 scripts/format.sh diff --git a/scripts/format.sh b/scripts/format.sh new file mode 100755 index 000000000..561db8756 --- /dev/null +++ b/scripts/format.sh @@ -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