diff --git a/.githooks/check-format b/.githooks/check-format index c6bd6693..2c57dc5c 100755 --- a/.githooks/check-format +++ b/.githooks/check-format @@ -5,6 +5,20 @@ # This script checks the format of the code and cmake files. # In many cases it will automatically fix the issues and abort the commit. +no_formatted_directories_staged() { + staged_directories=$(git diff-index --cached --name-only HEAD | awk -F/ '{print $1}') + for sd in $staged_directories; do + if [[ "$sd" =~ ^(benchmark|cmake|src|tests)$ ]]; then + return 1 + fi + done + return 0 +} + +if no_formatted_directories_staged ; then + exit 0 +fi + echo "+ Checking code format..." # paths to check and re-format