summaryrefslogtreecommitdiff
path: root/repo
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-03-28 09:48:07 -0400
committerEric S. Raymond <esr@thyrsus.com>2010-03-28 09:48:07 -0400
commit55e2961181003046bbb31bf6d369e79c7a7951a2 (patch)
tree7ec4296241d863b053f696ac7ca1b707181390ba /repo
parentc692257952b730cf45c81cf361f2b7a2686abede (diff)
downloadgpsd-55e2961181003046bbb31bf6d369e79c7a7951a2.tar.gz
Refactor.
Diffstat (limited to 'repo')
-rwxr-xr-xrepo/hooks/ciabot.py33
1 files changed, 17 insertions, 16 deletions
diff --git a/repo/hooks/ciabot.py b/repo/hooks/ciabot.py
index f8ee951e..09c0a53f 100755
--- a/repo/hooks/ciabot.py
+++ b/repo/hooks/ciabot.py
@@ -91,9 +91,6 @@ xml = '''\
# No user-serviceable parts below this line:
#
-def do(command):
- return commands.getstatusoutput(command)[1]
-
# Addresses for the e-mail. The from address is a dummy, since CIA
# will never reply to this mail.
fromaddr = "CIABOT-NOREPLY@" + host
@@ -103,16 +100,11 @@ toaddr = "cia@cia.vc"
# Should only change when the script itself has a new home
generator="http://www.catb.org/~esr/ciabot.sh"
-# Git version number.
-gitver = do("git --version").split()[0]
-
-# Add the git private command directory to the command path.
-os.environ["PATH"] += ":" + do("git --exec-path")
-
-urlprefix = urlprefix % globals()
+def do(command):
+ return commands.getstatusoutput(command)[1]
def report(refname, merged):
- "Report a commit notification to CIA"
+ "Generare a commit notification to be reported to CIA"
# Try to tinyfy a reference to a web view for this commit.
try:
@@ -159,12 +151,17 @@ Subject: DeliverXML
%(out)s''' % locals()
- if mailit:
- server.sendmail(fromaddr, [toaddr], message)
- else:
- print message
+ return message
if __name__ == "__main__":
+ # We''ll need the git version number.
+ gitver = do("git --version").split()[0]
+
+ # Add the git private command directory to the command path.
+ os.environ["PATH"] += ":" + do("git --exec-path")
+
+ urlprefix = urlprefix % globals()
+
# Call this script with -n to dump the notification mail to stdout
mailit = True
if sys.argv[1] == '-n':
@@ -185,7 +182,11 @@ if __name__ == "__main__":
server = smtplib.SMTP('localhost')
for merged in merges:
- report(refname, merged)
+ message = report(refname, merged)
+ if mailit:
+ server.sendmail(fromaddr, [toaddr], message)
+ else:
+ print message
if mailit:
server.quit()