File: install-hooks.sh

package info (click to toggle)
sdkmanager 0.6.11-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,044 kB
  • sloc: python: 1,387; sh: 92; makefile: 9
file content (30 lines) | stat: -rwxr-xr-x 841 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
#
# Install all the client hooks

BASE_DIR="$(cd $(dirname $0); pwd -P)"
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"
HOOK_DIR="$(git rev-parse --show-toplevel)/.git/hooks"

for hook in $HOOK_NAMES; do

	shipped_hook="$BASE_DIR/$hook"
	installed_hook="$HOOK_DIR/$hook"

	# If we don't distribute it, continue
	if [ ! -f "$shipped_hook" ]; then
		continue
	fi

	if [ -h "$installed_hook" ]; then
		echo "$installed_hook is a symlink - replacing."
	elif [ -e "$installed_hook" ]; then
		echo "$installed_hook hook already exists."
		continue
	fi

	# Create the symlink
	echo "ln -s -f \"$shipped_hook\" \"$installed_hook\""
	ln -s -f "$shipped_hook" "$installed_hook"

done