diff options
Diffstat (limited to 'scripts/hooks/common.sh')
-rw-r--r-- | scripts/hooks/common.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/hooks/common.sh b/scripts/hooks/common.sh new file mode 100644 index 0000000000..4d333689f8 --- /dev/null +++ b/scripts/hooks/common.sh @@ -0,0 +1,23 @@ +if [ "$1" = '--install' ]; then + mkdir -p ".git/hooks" + if [ -e ".git/hooks/$HOOK" ] || [ -L ".git/hooks/$HOOK" ]; then + if [ "$(readlink .git/hooks/$HOOK)" != "scripts/hooks/$HOOK" ]; then + echo "Can't install $HOOK because it has custom content" + else + echo "$HOOK hook is already installed" + fi + exit 1 + fi + echo "Installing $HOOK hook" + ln -s ../../scripts/hooks/$HOOK .git/hooks/$HOOK + exit 0 +elif [ "$1" = '--uninstall' ]; then + if [ "$(readlink .git/hooks/$HOOK)" = "scripts/hooks/$HOOK" ]; then + echo "Removing $HOOK hook" + rm .git/hooks/$HOOK + exit 0 + else + echo "$HOOK hook is not installed" + exit 1 + fi +fi |