1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
# Copyright 2012 OpenStack LLC
4
# Copyright 2012 Nebula Inc
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
# not use this file except in compliance with the License. You may obtain
8
# a copy of the License at
10
# http://www.apache.org/licenses/LICENSE-2.0
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
# License for the specific language governing permissions and limitations
23
def parse_mailmap(mailmap='.mailmap'):
25
if os.path.exists(mailmap):
26
fp = open(mailmap, 'r')
29
if not l.startswith('#') and ' ' in l:
30
canonical_email, alias = l.split(' ')
31
mapping[alias] = canonical_email
35
def str_dict_replace(s, mapping):
36
for s1, s2 in mapping.iteritems():
41
class AuthorsTestCase(unittest.TestCase):
42
def test_authors_up_to_date(self):
43
path_bits = (os.path.dirname(__file__), '..', '..', '..')
44
root = os.path.normpath(os.path.join(*path_bits))
47
authors_file = open(os.path.join(root, 'AUTHORS'), 'r').read()
49
if os.path.exists(os.path.join(root, '.git')):
50
mailmap = parse_mailmap(os.path.join(root, '.mailmap'))
51
for email in commands.getoutput('git log --format=%ae').split():
54
if "jenkins" in email and "openstack.org" in email:
56
email = '<' + email + '>'
57
contributors.add(str_dict_replace(email, mailmap))
59
for contributor in contributors:
60
if not contributor in authors_file:
61
missing.add(contributor)
63
self.assertTrue(len(missing) == 0,
64
'%r not listed in AUTHORS file.' % missing)