pre-commit 748 B

1234567891011121314151617181920212223
  1. #!/bin/sh
  2. #
  3. # An example hook script to verify what is about to be committed.
  4. # Called by "git commit" with no arguments. The hook should
  5. # exit with non-zero status after issuing an appropriate message if
  6. # it wants to stop the commit.
  7. #
  8. # To enable this hook, rename this file to "pre-commit".
  9. for i in `git status -s | awk '{ print $NF }'`; do
  10. j=$(echo $(basename $i)|cut -d'.' -f2)
  11. if [ "$j" = "c" -o "$j" = "h" -o "$j" = "md" -o "$j" = "mk" ]; then
  12. if [ "$(find $i -perm /111 2>/dev/null)" != "" ]; then
  13. chmod a-x $i
  14. echo "[chmod] $i"
  15. if [ "$(git status --short $i|cut -c1)" = "M" ]; then
  16. git add $i
  17. fi
  18. fi
  19. else
  20. echo "[skip ] $i"
  21. fi
  22. done