workdir=$(git rev-parse --show-toplevel)
cd "$workdir" || exit 1
set -e
if [ $# -eq 0 ]; then
CHECK_FILTER="git diff --cached --name-only --diff-filter=ACMR"
CHECK_FILES="$($CHECK_FILTER \
src/lib/*/*.[ch] \
src/core/*/*.[ch] \
src/feature/*/*.[ch] \
src/app/*/*.[ch] \
src/test/*.[ch] \
src/test/*/*.[ch] \
src/tools/*.[ch] \
)"
else
CHECK_FILES="$*"
fi
if [ -n "$(ls ./changes/)" ]; then
python scripts/maint/lintChanges.py ./changes/*
fi
if [ -e scripts/maint/checkShellScripts.sh ]; then
scripts/maint/checkShellScripts.sh
fi
PT_DIR=scripts/maint/practracker
if [ -e "${PT_DIR}/test_practracker.sh" ]; then
"${PT_DIR}/test_practracker.sh"
fi
if [ -e scripts/maint/checkSpaceTest.sh ]; then
scripts/maint/checkSpaceTest.sh
fi
if [ ! "$CHECK_FILES" ]; then
echo "No modified tor-owned source files, skipping further checks"
exit 0
fi
printf "Modified tor-owned source files:\\n%s\\n" "$CHECK_FILES"
perl scripts/maint/checkSpace.pl -C \
$CHECK_FILES
if test -e scripts/maint/practracker/includes.py; then
python scripts/maint/practracker/includes.py
fi
if [ -e "${PT_DIR}/practracker.py" ]; then
if [ -e "${PT_DIR}/.enable_practracker_in_hooks" ]; then
python3 "${PT_DIR}/practracker.py" "$workdir"
fi
fi
if [ -e scripts/coccinelle/check_cocci_parse.sh ]; then
VERBOSE=1 scripts/coccinelle/check_cocci_parse.sh \
$CHECK_FILES
fi