25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
641B

  1. #!/bin/bash
  2. HOOK_NAMES="pre-commit"
  3. HOOK_DIR=$(git rev-parse --show-toplevel)/.git/hooks
  4. INSTALL_DIR=$(git rev-parse --show-toplevel)/hooks
  5. for hook in $HOOK_NAMES; do
  6. # If the hook already exists, is executable, and is not a symlink
  7. if [ ! -h $HOOK_DIR/$hook -a -x $HOOK_DIR/$hook ]; then
  8. mv $HOOK_DIR/$hook $HOOK_DIR/$hook.local
  9. fi
  10. # create the symlink, overwriting the file if it exists
  11. # probably the only way this would happen is if you're using an old version of git
  12. # -- back when the sample hooks were not executable, instead of being named ____.sample
  13. ln -s -f $INSTALL_DIR/$hook $HOOK_DIR
  14. done