1
# jhbuild - a build script for GNOME 1.x and 2.x
2
# Copyright (C) 2008 Igalia S.L., John Carr, Frederic Peters
4
# changes.py: parsing of svn-commits-list messages
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
from buildbot import util
21
from buildbot.changes.mail import MaildirSource
22
from buildbot.changes import changes
24
from email.Utils import parseaddr
25
from email.Iterators import body_line_iterator
29
class GnomeMaildirSource(MaildirSource):
31
name = "Gnome svn-commits-list"
33
def parse(self, m, prefix=None):
38
from_header = m['from']
39
if '<' in from_header:
40
from_email = m['from'].split('<')[1][:-1]
42
from_email = m['from']
44
# From is account@src.gnome.org
45
name, domain = from_email.split("@")
47
# If this e-mail is valid, it will come from an svn/src.gnome.org email
48
if domain != 'src.gnome.org':
51
# we take the time of receipt as the time of checkin. Not correct, but it
52
# avoids the out-of-order-changes issue. See the comment in parseSyncmail
53
# about using the 'Date:' header
62
subject = m['subject']
64
if not subject.startswith('['):
65
# not a git message, abort
69
revision = m.get('X-Git-Newrev')
71
# not a new git revision, may be a new tag, a new branch, etc.
74
if m.get('X-Git-Refname', '').startswith('refs/tags/'):
79
project = subject[1:subject.index(']')]
81
return None # old git commit message format; ignored
84
# remove the branch part (ex: [anjal/inline-composer-quotes])
85
project = project.split('/')[0]
88
# remove the patch number part (ex: [anjal: 3/3])
89
project = project.split(':')[0]
91
if 'Created branch' in subject:
92
# new branches don't have to trigger rebuilds
95
if 'Merge branch' in subject:
96
comments = subject[subject.index('Merge branch'):]
97
elif 'Merge commit' in subject:
98
comments = subject[subject.index('Merge commit'):]
100
lines = list(body_line_iterator(m, m['Content-Transfer-Encoding']))
105
if line.startswith('Date:'):
110
if len(line) > 3 and line[0] == ' ' and line[1] != ' ' and '|' in line:
112
if line.startswith('---'):
117
files.append(line.split()[0])
119
comments += line[4:] + '\n'
121
comments = unicode(comments.strip(), m.get_content_charset() or 'ascii', 'ignore')
123
c = changes.Change(name, files, comments, isdir, revision=revision, links=links, when=when)
124
c.project = project # custom attribute