32 lines
700 B
Bash
Executable File
32 lines
700 B
Bash
Executable File
#!/bin/sh
|
|
|
|
|
|
GIT_TOPDIR=$(git rev-parse --show-toplevel 2>/dev/null)
|
|
# shellcheck disable=SC2181
|
|
if [ $? -ne 0 ]; then
|
|
echo "ERROR: Couldn't determine git top directory"
|
|
exit 1
|
|
fi
|
|
|
|
debug_msg() {
|
|
if [ "${GIT_OBS_HOOKS_DEBUG}" != "1" ]; then
|
|
return
|
|
fi
|
|
echo "$@" >&1
|
|
}
|
|
|
|
|
|
HOOKS_TOPDIR="/usr/share/git-obs-hooks"
|
|
|
|
|
|
for hook_path in "${HOOKS_TOPDIR}"/*; do
|
|
if [ ! -x "${hook_path}" ] || [ -d "${hook_path}" ]; then
|
|
continue
|
|
fi
|
|
|
|
hook_name=$(basename "${hook_path}")
|
|
git_hook_path="${GIT_TOPDIR}/.git/hooks/${hook_name}"
|
|
debug_msg "Installing hook ${hook_path} -> ${git_hook_path}"
|
|
ln -s --no-target-directory "${hook_path}" "${git_hook_path}"
|
|
done
|