Add support for the hooks setup by pagure itself on dist-git
Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
parent
a1fd28c04c
commit
59fe50e3f1
2 changed files with 29 additions and 2 deletions
|
@ -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':
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue