Permalink
Browse files

When a hook returns with non-zero report which hook last ran before e…

…xiting

Signed-off-by: Benjamin C Meyer <ben@meyerhome.net>
  • Loading branch information...
icefox committed Jun 19, 2010
1 parent 536997d commit 593590bd81c9285839b18dcc416db0690fce721f
Showing with 7 additions and 0 deletions.
  1. +7 −0 git-hooks
View
@@ -53,6 +53,7 @@ function run_hooks
shift 1
for hook in `list_hooks_in_dir "${dir}"`
do
+ export last_run_hook="${hook} $@"
if [ ! -z ${GIT_HOOKS_VERBOSE} ] ; then
echo -n "@@ Running hook: "
echo -n `basename \`dirname "${hook}"\``
@@ -132,12 +133,18 @@ function list_hooks
done
}
+function report_error {
+ echo "Hook failed: $last_run_hook"
+ exit 1
+}
+
case $1 in
run )
if [ ! -z "${GIT_DIR}" ] ; then
unset GIT_DIR
fi
shift
+ trap report_error ERR
run_hook "$@"
;;
--install|--uninstall )

0 comments on commit 593590b

Please sign in to comment.