2014-05-27 11:52:22 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Install all the client hooks
|
|
|
|
|
2014-05-28 07:21:37 +00:00
|
|
|
BASE_DIR="$(cd $(dirname $0); pwd -P)"
|
2014-05-27 11:52:22 +00:00
|
|
|
HOOK_NAMES="applypatch-msg pre-applypatch post-applypatch pre-commit prepare-commit-msg commit-msg post-commit pre-rebase post-checkout post-merge pre-receive update post-receive post-update pre-auto-gc"
|
2014-05-28 07:21:37 +00:00
|
|
|
HOOK_DIR="$(git rev-parse --show-toplevel)/.git/hooks"
|
2014-05-27 11:52:22 +00:00
|
|
|
|
|
|
|
for hook in $HOOK_NAMES; do
|
|
|
|
|
2014-05-28 07:21:37 +00:00
|
|
|
shipped_hook="$BASE_DIR/$hook"
|
|
|
|
installed_hook="$HOOK_DIR/$hook"
|
2014-05-27 11:52:22 +00:00
|
|
|
|
|
|
|
# If we don't distribute it, continue
|
2014-05-28 07:21:37 +00:00
|
|
|
if [ ! -f "$shipped_hook" ]; then
|
2014-05-27 11:52:22 +00:00
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
2014-05-28 07:21:37 +00:00
|
|
|
if [ -h "$installed_hook" ]; then
|
|
|
|
echo "$installed_hook is a symlink - replacing."
|
|
|
|
elif [ -e "$installed_hook" ]; then
|
2014-05-27 11:52:22 +00:00
|
|
|
echo "$installed_hook hook already exists."
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Create the symlink
|
2014-05-28 07:21:37 +00:00
|
|
|
echo "ln -s -f \"$shipped_hook\" \"$installed_hook\""
|
|
|
|
ln -s -f "$shipped_hook" "$installed_hook"
|
2014-05-27 11:52:22 +00:00
|
|
|
|
|
|
|
done
|