suitepro/plugins/redmine_git_hosting/contrib/hooks/post-receive/mail_notifications.py

35 lines
862 B
Python

#! /usr/bin/env python
import sys
import os
import git_multimail
# It is possible to modify the output templates here; e.g.:
git_multimail.FOOTER_TEMPLATE = """\
-- \n\
This email was generated by the wonderful git-multimail tool from JBox Web.
"""
# Specify which "git config" section contains the configuration for
# git-multimail:
config = git_multimail.Config('multimailhook')
# check if hook is enabled
enabled = config.get_bool('enabled')
if enabled:
# Select the type of environment:
environment = git_multimail.GitoliteEnvironment(config=config)
# Choose the method of sending emails based on the git config:
mailer = git_multimail.choose_mailer(config, environment)
# Read changes from stdin and send notification emails:
git_multimail.run_as_post_receive_hook(environment, mailer)
else:
print(" multimailhook is disabled")