blob: 0cd6a712a6ee0b5774e65747476cab30e4657297 [file] [log] [blame]
#!/bin/bash
# This script reformats source files using the clang-format utility.
#
# Files are changed in-place, so make sure you don't have anything open in an
# editor, and you may want to commit before formatting in case of awryness.
#
# This must be run on a clean repository to succeed
#
# Input parmameter must be full path to git repo to scan
DIR=$1
cd ${DIR}
echo "Formatting code under $DIR/"
if [ -f "setup.cfg" ]; then
pycodestyle --show-source .
rc=$?
if [ ${rc} -ne 0 ]; then
exit ${rc}
fi
fi
if [ -f ".clang-format" ]; then
find . -regextype sed -regex ".*\.[hc]\(pp\)\?" -not -name "*mako*" -print0 |\
xargs -0 "clang-format-5.0" -i
git --no-pager diff --exit-code
fi