git-hooks-init.sh 457 B

123456789101112131415161718192021
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. if [ ! -d .git ]; then
  4. exit 0
  5. fi
  6. mkdir -p ".git/hooks"
  7. if [ ! -L '.git/hooks/pre-push' ]; then
  8. ln -sf '../../scripts/git-hook-pre-push.sh' '.git/hooks/pre-push'
  9. fi
  10. if [ ! -L '.git/hooks/pre-commit' ]; then
  11. ln -sf '../../scripts/git-hook-pre-commit.sh' '.git/hooks/pre-commit'
  12. fi
  13. if [ ! -L '.git/hooks/post-commit' ]; then
  14. ln -sf '../../scripts/git-hook-post-commit.sh' '.git/hooks/post-commit'
  15. fi