pre-commit.git-hook 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env bash
  2. #
  3. # To install this script, copy it to .git/hooks/pre-commit in local copy of
  4. # tor git repo and make sure it has permission to execute.
  5. #
  6. # This is pre-commit git hook script that prevents commiting your changeset if
  7. # it fails our code formatting or changelog entry formatting checkers.
  8. workdir=$(git rev-parse --show-toplevel)
  9. cd "$workdir" || exit 1
  10. set -e
  11. if [ -n "$(ls ./changes/)" ]; then
  12. python scripts/maint/lintChanges.py ./changes/*
  13. fi
  14. if [ -d src/lib ]; then
  15. # This is the layout in 0.3.5
  16. perl scripts/maint/checkSpace.pl -C \
  17. src/lib/*/*.[ch] \
  18. src/core/*/*.[ch] \
  19. src/feature/*/*.[ch] \
  20. src/app/*/*.[ch] \
  21. src/test/*.[ch] \
  22. src/test/*/*.[ch] \
  23. src/tools/*.[ch]
  24. elif [ -d src/common ]; then
  25. # This was the layout before 0.3.5
  26. perl scripts/maint/checkSpace.pl -C \
  27. src/common/*/*.[ch] \
  28. src/or/*/*.[ch] \
  29. src/test/*.[ch] \
  30. src/test/*/*.[ch] \
  31. src/tools/*.[ch]
  32. fi
  33. if test -e scripts/maint/practracker/includes.py; then
  34. python scripts/maint/practracker/includes.py
  35. fi
  36. if [ -e scripts/maint/practracker/practracker.py ]; then
  37. python3 ./scripts/maint/practracker/practracker.py "$workdir"
  38. fi