format-check.sh 555 B

123456789101112131415161718
  1. #!/bin/bash
  2. # Simple script to check for clang-format compliance
  3. wget -Nq https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format
  4. if chmod +x git-clang-format; then
  5. CLANG_FORMAT_OUTPUT=$(./git-clang-format HEAD^ HEAD --diff)
  6. if [[ ! ${CLANG_FORMAT_OUTPUT} == "no modified files to format" ]] && [[ ! -z ${CLANG_FORMAT_OUTPUT} ]]; then
  7. echo "Failed clang format check:"
  8. echo "${CLANG_FORMAT_OUTPUT}"
  9. exit 1
  10. else
  11. echo "Passed clang format check"
  12. fi
  13. else
  14. echo "git-clang-format not downloaded"
  15. exit 1
  16. fi