diff options
author | Benjamin C Meyer <ben@meyerhome.net> | 2010-06-19 14:39:36 -0400 |
---|---|---|
committer | Benjamin C Meyer <ben@meyerhome.net> | 2010-06-19 14:39:36 -0400 |
commit | 593590bd81c9285839b18dcc416db0690fce721f (patch) | |
tree | f36d63ddd83d282b1884aece260262069c2a1a85 | |
parent | 536997d6d30467e2e9e401cca2cf6e7daa499665 (diff) | |
download | git-hooks-593590bd81c9285839b18dcc416db0690fce721f.tar.gz git-hooks-593590bd81c9285839b18dcc416db0690fce721f.tar.bz2 |
When a hook returns with non-zero report which hook last ran before exiting
Signed-off-by: Benjamin C Meyer <ben@meyerhome.net>
-rwxr-xr-x | git-hooks | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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 ) |