From ca64142d257d24586245c307cadeb8e9a025933a Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Fri, 29 Aug 2014 03:57:08 +0200 Subject: [PATCH] Trying to implement both "post-commit" and "post-receive" together --- src/deforaos-git-hook.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/deforaos-git-hook.sh b/src/deforaos-git-hook.sh index bb7fb4f..cd730a1 100755 --- a/src/deforaos-git-hook.sh +++ b/src/deforaos-git-hook.sh @@ -34,9 +34,23 @@ _error() #hook_post_commit _hook_post_commit() +{ + if [ $# -ne 0 ]; then + _usage "post-commit" + return $? + fi + while read oldrev newrev refname; do + #XXX ignore errors + _hook_post_receive "$refname" "$oldrev" "$newrev" + done + return 0 +} + + +_hook_post_receive() { if [ $# -ne 3 ]; then - _usage "post-commit refname oldrev newrev" + _usage "post-receive refname oldrev newrev" return $? fi refname="$1" @@ -100,6 +114,10 @@ case "$hook" in _hook_post_commit "$@" exit $? ;; + "post-receive") + _hook_post_receive "$@" + exit $? + ;; *) _error "$hook: Unknown hook" exit $?