Port Authors test to git.
Change-Id: I27bb6b3951422ad32e5e0225765b1056c5b3ffc5
This commit is contained in:
parent
c81ebbcc5a
commit
ee6f91ed97
1
.mailmap
1
.mailmap
|
@ -9,3 +9,4 @@
|
||||||
<rick@openstack.org> <rclark@chat-blanc>
|
<rick@openstack.org> <rclark@chat-blanc>
|
||||||
<soren.hansen@rackspace.com> <soren@linux2go.dk>
|
<soren.hansen@rackspace.com> <soren@linux2go.dk>
|
||||||
<soren.hansen@rackspace.com> <soren@openstack.org>
|
<soren.hansen@rackspace.com> <soren@openstack.org>
|
||||||
|
<james.blair@rackspace.com> <corvus@gnu.org>
|
||||||
|
|
1
Authors
1
Authors
|
@ -12,6 +12,7 @@ Ewan Mellor <ewan.mellor@citrix.com>
|
||||||
Isaku Yamahata <yamahata@valinux.co.jp>
|
Isaku Yamahata <yamahata@valinux.co.jp>
|
||||||
Jason Koelker <jason@koelker.net>
|
Jason Koelker <jason@koelker.net>
|
||||||
Jay Pipes <jaypipes@gmail.com>
|
Jay Pipes <jaypipes@gmail.com>
|
||||||
|
James E. Blair <james.blair@rackspace.com>
|
||||||
Jinwoo 'Joseph' Suh <jsuh@isi.edu>
|
Jinwoo 'Joseph' Suh <jsuh@isi.edu>
|
||||||
Johannes Erdfelt <johannes.erdfelt@rackspace.com>
|
Johannes Erdfelt <johannes.erdfelt@rackspace.com>
|
||||||
Josh Kearney <josh@jk0.org>
|
Josh Kearney <josh@jk0.org>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import commands
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,39 +40,27 @@ def str_dict_replace(s, mapping):
|
||||||
|
|
||||||
class AuthorsTestCase(unittest.TestCase):
|
class AuthorsTestCase(unittest.TestCase):
|
||||||
def test_authors_up_to_date(self):
|
def test_authors_up_to_date(self):
|
||||||
topdir = os.path.normpath(os.path.dirname(__file__) + '/../../')
|
|
||||||
if os.path.exists(os.path.join(topdir, '.bzr')):
|
|
||||||
contributors = set()
|
|
||||||
|
|
||||||
|
topdir = os.path.normpath(os.path.dirname(__file__) + '/../../..')
|
||||||
|
contributors = set()
|
||||||
|
missing = set()
|
||||||
|
authors_file = open(os.path.join(topdir, 'Authors'), 'r').read()
|
||||||
|
|
||||||
|
if os.path.exists(os.path.join(topdir, '.git')):
|
||||||
mailmap = parse_mailmap(os.path.join(topdir, '.mailmap'))
|
mailmap = parse_mailmap(os.path.join(topdir, '.mailmap'))
|
||||||
|
for email in commands.getoutput('git log --format=%ae').split():
|
||||||
|
if not email:
|
||||||
|
continue
|
||||||
|
if "jenkins" in email and "openstack.org" in email:
|
||||||
|
continue
|
||||||
|
email = '<' + email + '>'
|
||||||
|
contributors.add(str_dict_replace(email, mailmap))
|
||||||
|
|
||||||
import bzrlib.workingtree
|
for contributor in contributors:
|
||||||
tree = bzrlib.workingtree.WorkingTree.open(topdir)
|
if contributor == 'glance-core':
|
||||||
tree.lock_read()
|
continue
|
||||||
try:
|
if not contributor in authors_file:
|
||||||
parents = tree.get_parent_ids()
|
missing.add(contributor)
|
||||||
g = tree.branch.repository.get_graph()
|
|
||||||
for p in parents:
|
|
||||||
rev_ids = [r for r, _ in g.iter_ancestry(parents)
|
|
||||||
if r != "null:"]
|
|
||||||
revs = tree.branch.repository.get_revisions(rev_ids)
|
|
||||||
for r in revs:
|
|
||||||
for author in r.get_apparent_authors():
|
|
||||||
email = author.split(' ')[-1]
|
|
||||||
mailmapped = str_dict_replace(email, mailmap)
|
|
||||||
contributors.add(mailmapped)
|
|
||||||
|
|
||||||
authors_file = open(os.path.join(topdir, 'Authors'),
|
self.assertTrue(len(missing) == 0,
|
||||||
'r').read()
|
'%r not listed in Authors' % missing)
|
||||||
|
|
||||||
missing = set()
|
|
||||||
for contributor in contributors:
|
|
||||||
if contributor == 'glance-core':
|
|
||||||
continue
|
|
||||||
if not contributor in authors_file:
|
|
||||||
missing.add(contributor)
|
|
||||||
|
|
||||||
self.assertTrue(len(missing) == 0,
|
|
||||||
'%r not listed in Authors' % missing)
|
|
||||||
finally:
|
|
||||||
tree.unlock()
|
|
||||||
|
|
Loading…
Reference in New Issue