diff --git a/roles/git/checks/files/check-perms.py b/roles/git/checks/files/check-perms.py index 469f6c5bc7..43543bed80 100755 --- a/roles/git/checks/files/check-perms.py +++ b/roles/git/checks/files/check-perms.py @@ -217,13 +217,18 @@ def set_post_receive_hook_version3(gitdir, fix=False): """Configure a git repository to use the fedmsg+gnome-mail hooks.""" # Old folder where we used to place the hooks - dest_prefix = os.path.join(gitdir, 'hooks', 'post-receive-chained.d') + hook_dir = os.path.join(gitdir, 'hooks') + dest_prefix = os.path.join(hook_dir, 'post-receive-chained.d') # Remove the old hooks hooks = [ os.path.join(dest_prefix, 'post-receive-email'), os.path.join(dest_prefix, 'post-receive-fedmsg'), os.path.join(dest_prefix, 'post-receive-alternativearch'), + # These two hooks are setup by pagure but are already part of the + # main post-receive hook + os.path.join(hook_dir, 'post-receive.default'), + os.path.join(hook_dir, 'post-receive.pagure'), ] for hook in hooks: @@ -239,7 +244,7 @@ def set_post_receive_hook_version3(gitdir, fix=False): else: os.rmdir(dest_prefix) - # Symlink mail notification and fedmsg scripts to post-receive hook + # Symlink the post-receive-chained to post-receive hook scripts = { # This one kicks off all the others. '/usr/share/git-core/post-receive-chained': diff --git a/roles/git/hooks/files/post-receive-chained b/roles/git/hooks/files/post-receive-chained index e61cb72f40..b0175124fb 100755 --- a/roles/git/hooks/files/post-receive-chained +++ b/roles/git/hooks/files/post-receive-chained @@ -12,3 +12,25 @@ pee \ # We used to send emails directly from the git hook here, but now we send to # fedmsg which routes to FMN which routes to packagers and the mailing list. #$GIT_DIR/hooks/post-receive-chained.d/post-receive-email \ + +# Mechanism to support pagure's hook as well +hookname=`basename $0` + + +FILE=`mktemp` +trap 'rm -f $FILE' EXIT +cat - > $FILE + +for hook in $GIT_DIR/hooks/$hookname.* +do + if test -x "$hook"; then + cat $FILE | $hook "$@" + status=$? + + if test $status -ne 0; then + echo Hook $hook failed with error code $status + exit $status + fi + fi +done +