Add multihook script
This commit is contained in:
parent
8d0fad7ed3
commit
3a4360105b
28
use-hook-dir.sh
Normal file
28
use-hook-dir.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
|
||||
# From: https://gist.github.com/mjackson/7e602a7aa357cfe37dadcc016710931b
|
||||
|
||||
# Make a symlink per hook to this script you use e.g. .git/hooks/pre-receive.
|
||||
# It looks for scripts in the .git/hooks/pre-receive.d directory and executes them in order,
|
||||
# passing along stdin. If any script exits with a non-zero status, this script exits.
|
||||
|
||||
script_dir=$(dirname $0)
|
||||
hook_name=$(basename $0)
|
||||
|
||||
hook_dir="$script_dir/$hook_name.d"
|
||||
|
||||
if [[ -d $hook_dir ]]; then
|
||||
stdin=$(cat /dev/stdin)
|
||||
|
||||
for hook in $hook_dir/*; do
|
||||
echo "$stdin" | $hook "$@"
|
||||
|
||||
exit_code=$?
|
||||
|
||||
if [ $exit_code != 0 ]; then
|
||||
exit $exit_code
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user