[PATCH 5/5] gnome-post-receive-email: Make maildomain configurable
- From: Todd Zullinger <tmz pobox com>
- To: gnome-infrastructure gnome org
- Subject: [PATCH 5/5] gnome-post-receive-email: Make maildomain configurable
- Date: Wed, 22 Jul 2009 13:22:14 -0400
This first tries hooks.maildomain. If that is not found, the system
hostname, minus the host part is tried. If all else fails, the fallback
is localhost.localdomain.
---
gnome-post-receive-email | 24 ++++++++++++++++++++++--
1 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/gnome-post-receive-email b/gnome-post-receive-email
index 9a489cf..d614d01 100755
--- a/gnome-post-receive-email
+++ b/gnome-post-receive-email
@@ -34,6 +34,7 @@ import os
import pwd
import sys
from email import Header
+from socket import gethostname
script_path = os.path.realpath(os.path.abspath(sys.argv[0]))
script_dir = os.path.dirname(script_path)
@@ -63,6 +64,9 @@ user_fullname = None
# Who gets the emails
recipients = None
+# What domain the emails are from
+maildomain = None
+
# map of ref_name => Change object; this is used when computing whether
# we've previously generated a detailed diff for a commit in the push
all_changes = {}
@@ -116,9 +120,9 @@ class RefChange(object):
def generate_header(self, out, subject, include_revs=True, oldrev=None, newrev=None):
user = os.environ['USER']
if user_fullname:
- from_address = "%s <%s src gnome org>" % (user_fullname, user)
+ from_address = "%s <%s %s>" % (user_fullname, user, maildomain)
else:
- from_address = "%s src gnome org" % (user)
+ from_address = "%s %s" % (user, maildomain)
print >>out, s("""
To: %(recipients)s
@@ -833,6 +837,7 @@ def main():
global projectdesc
global user_fullname
global recipients
+ global maildomain
# No emails for a repository in the process of being imported
git_dir = git.rev_parse(git_dir=True, _quiet=True)
@@ -850,6 +855,21 @@ def main():
if not recipients:
die("hooks.mailinglist is not set")
+ # Get the domain name to use in the From header
+ try:
+ maildomain = git.config("hooks.maildomain", _quiet=True)
+ except CalledProcessError:
+ pass
+
+ if not maildomain:
+ try:
+ hostname = gethostname()
+ maildomain = '.'.join(hostname.split('.')[1:])
+ except:
+ pass
+ if not maildomain or '.' not in maildomain:
+ maildomain = 'localhost.localdomain'
+
# Figure out a human-readable username
try:
entry = pwd.getpwuid(os.getuid())
--
1.6.3.3
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]