Files
freebsd-src/contrib/libcbor/misc/hooks/pre-commit
T
Ed Maste b5b9517bfe libcbor: Update to 0.13.0
Sponsored by:	The FreeBSD Foundation
2026-03-23 11:41:51 -04:00

24 lines
646 B
Bash
Executable File

#!/bin/sh
set -e
# Run cmake-lint, clang-format, and add modified files
MODIFIED_UNSTAGED=$(git -C . diff --name-only)
MODIFIED_STAGED=$(git -C . diff --name-only --cached --diff-filter=d)
CMAKE_FILES=$(echo "${MODIFIED_STAGED} ${MODIFIED_UNSTAGED}" | grep -oE '(\S*)CMakeLists.txt' | cat)
if ! cmake-lint --line-width 140 ${CMAKE_FILES} > /dev/null; then
echo "cmake-lint failed:"
cmake-lint --line-width 140 ${CMAKE_FILES}
fi
./clang-format.sh
git add ${MODIFIED_STAGED}
if [[ ${MODIFIED_UNSTAGED} != $(git -C . diff --name-only) ]]; then
echo "WARNING: Non-staged files were reformatted. Please review and/or add" \
"them"
fi