Commit 178cecb1 authored by Peter van der Does's avatar Peter van der Does Committed by Vincent Driessen

Implements do_hook function

Signed-off-by: 's avatarPeter van der Does <peter@avirtualhome.com>
Signed-off-by: 's avatarVincent Driessen <vincent@3rdcloud.com>
parent e4e0e0c9
...@@ -53,7 +53,7 @@ has() { ...@@ -53,7 +53,7 @@ has() {
local item=$1; shift local item=$1; shift
echo " $@ " | grep -q " $(escape $item) " echo " $@ " | grep -q " $(escape $item) "
} }
# basic math # basic math
min() { [ "$1" -le "$2" ] && echo "$1" || echo "$2"; } min() { [ "$1" -le "$2" ] && echo "$1" || echo "$2"; }
max() { [ "$1" -ge "$2" ] && echo "$1" || echo "$2"; } max() { [ "$1" -ge "$2" ] && echo "$1" || echo "$2"; }
...@@ -323,3 +323,24 @@ require_branches_equal() { ...@@ -323,3 +323,24 @@ require_branches_equal() {
fi fi
fi fi
} }
do_hook() {
local prefix="$1"
local return_code=0
if [ -z $prefix ]; then
die "Hook implementation error - No prefix given"
fi
if [ $prefix != "pre" ] && [ $prefix != "post" ]; then
die "Hook implementation error - Bad Prefix"
fi
if [ -x ${GITFLOW_CONF_DIR_HOOKS}${prefix}_${SUBCOMMAND}_${SUBACTION} ]; then
${GITFLOW_CONF_DIR_HOOKS}${prefix}_${SUBCOMMAND}_${SUBACTION}
return_code=$?
fi
if [ $return_code -gt 0 ]; then
die "Hook command ${prefix}_${SUBCOMMAND}_${SUBACTION} failed. Exit code $return_code"
fi
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment