Commit 6776d7b9 authored by Adam Procter's avatar Adam Procter Committed by GitHub

Tweak code format script to ignore symlinked .cpp / .hpp files (#165)

Emacs likes to add hidden symlinks with names like '.#myfile.cpp' that don't actually point to real files as a locking mechanism, which cause the format check/apply scripts to fail. This tweaks the format scripts to ignore files that are symlinks (adds a -type f predicate to the find commands), which gets around this issue.
parent 5ed9d5b7
......@@ -41,7 +41,10 @@ for ROOT_SUBDIR in src test; do
fi
echo "About to format C/C++ code in directory tree '$(pwd)/${ROOT_SUBDIR}' ..."
find "${ROOT_SUBDIR}" -name '*.cpp' -or -name '*.hpp' | xargs "${CLANG_FORMAT_PROG}" -i -style=file
# Note that we restrict to "-type f" to exclude symlinks. Emacs sometimes
# creates dangling symlinks with .cpp/.hpp suffixes as a sort of locking
# mechanism, and this confuses clang-format.
find "${ROOT_SUBDIR}" -type f -and \( -name '*.cpp' -or -name '*.hpp' \) | xargs "${CLANG_FORMAT_PROG}" -i -style=file
echo "Done."
done
......
......@@ -45,7 +45,10 @@ for ROOT_SUBDIR in src test; do
echo "About to format C/C++ code in directory tree '$(pwd)/${ROOT_SUBDIR}' ..."
declare SRC_FILE
for SRC_FILE in $(find "${ROOT_SUBDIR}" -name '*.cpp' -or -name '*.hpp'); do
# Note that we restrict to "-type f" to exclude symlinks. Emacs sometimes
# creates dangling symlinks with .cpp/.hpp suffixes as a sort of locking
# mechanism, and this confuses clang-format.
for SRC_FILE in $(find "${ROOT_SUBDIR}" -type f -and \( -name '*.cpp' -or -name '*.hpp' \) ); do
if "${CLANG_FORMAT_PROG}" -style=file -output-replacements-xml "${SRC_FILE}" | grep -c "<replacement " >/dev/null; then
FAILED_FILES+=( "${SRC_FILE}" )
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment