From b17e7ef0b9878f0a9cfa62014bdcb462ba8575d2 Mon Sep 17 00:00:00 2001 From: Joel Baranick Date: Thu, 14 Mar 2019 22:46:29 -0700 Subject: [PATCH] Add handing of exit codes to post hooks --- gitflow-common | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gitflow-common b/gitflow-common index 0ad52648..54697361 100644 --- a/gitflow-common +++ b/gitflow-common @@ -794,14 +794,21 @@ run_pre_hook() { # post-flow-- # # If such a hook script exists and is executable, it is called with the given -# positional arguments. Its return code is ignored. +# positional arguments. If its return code non-zero, the git-flow action is +# aborted. # run_post_hook() { - local scriptfile + local scriptfile exitcode scriptfile="${HOOKS_DIR}/post-flow-${SUBCOMMAND}-${SUBACTION}" + exitcode=0 if [ -x "$scriptfile" ]; then "$scriptfile" "$@" + exitcode=$? + + if [ $exitcode -gt 0 ]; then + die "Hook command $scriptfile ended with exit code $exitcode." + fi fi }