Commit 6446282f authored by Christian Kellner's avatar Christian Kellner

git-hooks.sh: ensure the .git/hooks exists

Before doing anything check if .git/hook exists, otherwise abort
with an exit status.
parent 293724e5
......@@ -12,8 +12,18 @@ cd "$SRCDIR"
declare -a HOOKS=()
readarray -t HOOKS < <(find "$HOOKDIR" -maxdepth 1 -type f -exec basename {} \;)
# helpers
ensure_destdir () {
if [ ! -d "$DESTDIR" ]; then
echo "$DESTDIR does not exist"
exit 2
fi
}
# individual commands
check () {
ensure_destdir
for hook in ${HOOKS[@]}; do
echo -n "$hook "
DEST="$DESTDIR/$hook"
......@@ -26,6 +36,8 @@ check () {
}
install () {
ensure_destdir
RESULT=0
for hook in ${HOOKS[@]}; do
DEST="$DESTDIR/$hook"
......@@ -42,6 +54,8 @@ install () {
}
uninstall () {
ensure_destdir
for hook in ${HOOKS[@]}; do
DEST="$DESTDIR/$hook"
if [ ! -x "$DEST" ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment