Skip to content

Instantly share code, notes, and snippets.

@yusuiked
Created July 19, 2021 02:47
Show Gist options
  • Save yusuiked/d569ae154ea383835bc3cc4370e1d1ce to your computer and use it in GitHub Desktop.
Save yusuiked/d569ae154ea383835bc3cc4370e1d1ce to your computer and use it in GitHub Desktop.
git の hook を複数実行したい時
#!/usr/bin/env bash
export GIT_DIR=`git rev-parse --git-dir`
hookname=`basename $0`
FILE=`mktemp`
trap 'rm -f $FILE' EXIT
cat - > $FILE
for hook in $GIT_DIR/hooks/$hookname.*
do
if test -x "$hook"; then
# echo $hook
cat $FILE | $hook "$@"
status=$?
if test $status -ne 0; then
echo Hook $hook failed with error code $status
exit $status
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment