Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Add handing of exit codes to post hooks #409

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions gitflow-common
Original file line number Diff line number Diff line change
Expand Up @@ -794,14 +794,21 @@ run_pre_hook() {
# post-flow-<subcmd>-<subaction>
#
# 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
kadaan marked this conversation as resolved.
Show resolved Hide resolved
if [ -x "$scriptfile" ]; then
"$scriptfile" "$@"
exitcode=$?

if [ $exitcode -gt 0 ]; then
die "Hook command $scriptfile ended with exit code $exitcode."
fi
fi
}

Expand Down