]> gitweb.fluxo.info Git - git-hooks.git/commitdiff
When a hook returns with non-zero report which hook last ran before exiting
authorBenjamin C Meyer <ben@meyerhome.net>
Sat, 19 Jun 2010 18:39:36 +0000 (14:39 -0400)
committerBenjamin C Meyer <ben@meyerhome.net>
Sat, 19 Jun 2010 18:39:36 +0000 (14:39 -0400)
Signed-off-by: Benjamin C Meyer <ben@meyerhome.net>
git-hooks

index 649d08ad4b6670059a1f3903f028ec98090a91c5..bab2b5d787c47e24ac7e237c63e05dd17ba514f4 100755 (executable)
--- a/git-hooks
+++ b/git-hooks
@@ -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 )