#!/bin/sh # Framework for running git hooks in git-obs and osc # # To install the hooks on the system, place executables under: # - /usr/local/share/git-obs-hooks/.d/ # - /usr/share/git-obs-hooks/.d/ # - ~/.local/share/git-obs-hooks/.d/ # To enable git-obs-hooks in the current git repo, run: install-git-obs-hooks # # See githooks(5) man page for more help on the hooks. set -eu XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share} GIT_OBS_HOOKS_DEBUG=${GIT_OBS_HOOKS_DEBUG:-${GIT_TRACE:-0}} hook_name=${0##*/} die() { exit_code=$? printf >&2 '%s\n' "$1" exit "$exit_code" } debug_msg() { if [ "$GIT_OBS_HOOKS_DEBUG" = 1 ]; then printf >&2 '%s\n' "$1" fi } debug_msg "Running $hook_name hooks:" for hook in \ "$XDG_DATA_HOME/git-obs-hooks/$hook_name.d"/* \ "/usr/local/share/git-obs-hooks/$hook_name.d"/* \ "/usr/share/git-obs-hooks/$hook_name.d"/* do if [ -f "$hook" ] && [ -x "$hook" ] ; then debug_msg " - Running $hook" "$hook" "$@" || die "ERROR: '$hook' failed with exit status $?" fi done