Created
July 19, 2021 02:47
-
-
Save yusuiked/d569ae154ea383835bc3cc4370e1d1ce to your computer and use it in GitHub Desktop.
git の hook を複数実行したい時
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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