Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

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