1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#
# GitMailDirSource
#
# loosely based on the patch from
# https://lists.buildbot.net/pipermail/devel/2010-November/007072.html
#
import re
import os
import sys
from email.iterators import body_line_iterator
from buildbot import util
from buildbot.changes.mail import MaildirSource
from twisted.python import log
# unicode safe wrapper for twisted.python.log
def logger(s):
log.msg(s.encode(sys.getdefaultencoding(), 'replace'))
class GitMaildirSource(MaildirSource):
name = "Git"
def parse(self, m, prefix=None):
"""Parse messages sent by the git 'post-recieve-email' script.
"""
logger('Processing git mail')
list = m["list-id"]
logger("list '%s'" % list)
if "xorg-commit.lists.x.org" in list:
repopathmap = { 'xorg' : [ 'xserver' ],
'xorg/app' : [ 'appres' , 'bdftopcf', 'bitmap', 'editres', 'iceauth', 'luit', 'mkfontdir', 'mkfontscale', 'rendercheck', 'rgb', 'rstart', 'scripts', 'sessreg', 'setxkbmap', 'smproxy', 'twm',
'x11perf', 'xauth', 'xbacklight', 'xcalc', 'xclipboard', 'xclock', 'xcmsdb', 'xconsole', 'xcursorgen', 'xditview', 'xdm', 'xdpyinfo', 'xdriinfo', 'xev', 'xeyes', 'xfd', 'xfontsel', 'xfs',
'xfsinfo', 'xgamma', 'xhost', 'xinit', 'xinput', 'xkbcomp', 'xkbevd', 'xkbutils', 'xkill', 'xload', 'xlogo', 'xlsatoms', 'xlsclients', 'xman', 'xmodmap', 'xpr', 'xprop', 'xrandr', 'xrdb',
'xrefresh', 'xset', 'xsetroot', 'xsm', 'xstdcmap', 'xvidtune', 'xvinfo', 'xwd', 'xwininfo', 'xwud' ],
'xorg/doc' : [ 'xorg-docs', 'xorg-sgml-doctools' ],
'xorg/driver' : [ 'xf86-video-dummy', 'xf86-video-nested' ],
'xorg/font' : [ 'util', 'encodings', 'adobe-100dpi', 'adobe-75dpi', 'adobe-utopia-100dpi', 'adobe-utopia-75dpi', 'adobe-utopia-type1', 'arabic-misc', 'bh-100dpi', 'bh-75dpi', 'bh-lucidatypewriter-100dpi',
'bh-lucidatypewriter-75dpi', 'bh-ttf', 'bh-type1', 'bitstream-100dpi', 'bitstream-75dpi', 'bitstream-type1', 'cronyx-cyrillic', 'cursor-misc', 'daewoo-misc', 'dec-misc', 'ibm-type1',
'isas-misc', 'jis-misc', 'micro-misc', 'misc-cyrillic', 'misc-ethiopic', 'misc-meltho', 'misc-misc', 'mutt-misc', 'schumacher-misc', 'screen-cyrillic', 'sony-misc', 'sun-misc',
'winitzki-cyrillic', 'xfree86-type1', 'alias' ],
'xorg/lib' : [ 'libAppleWM', 'libFS', 'libICE', 'libpciaccess', 'libSM', 'libX11', 'libXScrnSaver', 'libXau', 'libXaw', 'libXaw3d', 'libXcomposite', 'libXcursor', 'libXdamage', 'libXdmcp', 'libXext',
'libXfixes', 'libXfont', 'libXft', 'libXi', 'libXinerama', 'libXmu', 'libXpm', 'libXrandr', 'libXrender', 'libXRes', 'libXt', 'libXtst', 'libXv', 'libXvMC', 'libXxf86dga', 'libXxf86vm',
'libdmx', 'libfontenc', 'libxkbfile', 'libxshmfence', 'libxtrans', 'libWindowsWM' ],
'xorg/proto' : [ 'applewmproto', 'bigreqsproto', 'compositeproto', 'damageproto', 'dri2proto', 'dri3proto', 'dmxproto', 'fixesproto', 'fontsproto', 'glproto', 'inputproto', 'kbproto', 'presentproto',
'randrproto', 'recordproto', 'renderproto', 'resourceproto', 'scrnsaverproto', 'videoproto', 'windowswmproto', 'xcmiscproto', 'xextproto', 'xf86bigfontproto', 'xf86dgaproto', 'xf86driproto',
'xf86vidmodeproto', 'xineramaproto', 'x11proto' ],
'xorg/util' : [ 'macros', 'makedepend' ],
'' : [ 'pixman' ] }
repobaseurl = 'git://anongit.freedesktop.org/git/'
elif "mesa-commit.lists.freedesktop.org" in list:
repopathmap = { 'mesa' : [ 'mesa' , 'demos', 'glu', 'glut' ] }
repobaseurl = 'git://anongit.freedesktop.org/git/'
else:
logger("unknown list '%s'" % list)
# xkeyboard-config ?
# xcb ?
# fontconfig ?
# xts ?
subject = m["subject"]
# logger("subject '%s'" % subject)
match = re.search(r"^(.*): (Branch |Changes to )'(.*)'", subject)
if match:
repository = match.group(1)
branch = match.group(3)
logger("repository '%s'" % repository)
logger("branch '%s'" % branch)
else:
match = re.search(r"^(.*) \((.*)\):", subject)
if match:
repository = match.group(1).lower()
branch = match.group(2)
logger("repository '%s'" % repository)
logger("branch '%s'" % branch)
else:
return None
# map from the short repository name to the repository path
for k in repopathmap:
if repository in repopathmap[k]:
if k != '':
repository = k + '/' + repository
break
logger("repo name mapped to path '%s'" % repository)
# make the repository URL
repository = repobaseurl + repository
logger("repo URL '%s'" % repository)
# trigger a poll of the git repository using a webstatus change hook
# this gives a much more accurate result than trying to parse the email
# (note the curl must be run asynchronously, as the HTTP POST can't be processed by this thread until after we return from here)
os.system('curl -s -F poller=' + repository + ' http://localhost:8010/change_hook/poller &')
return None
|