add support for git checking and a default of failing if the history can't be read
This commit is contained in:
@@ -29,11 +29,12 @@ from nova.utils import parse_mailmap, str_dict_replace
|
|||||||
class ProjectTestCase(test.TestCase):
|
class ProjectTestCase(test.TestCase):
|
||||||
def test_authors_up_to_date(self):
|
def test_authors_up_to_date(self):
|
||||||
topdir = os.path.normpath(os.path.dirname(__file__) + '/../../')
|
topdir = os.path.normpath(os.path.dirname(__file__) + '/../../')
|
||||||
if os.path.exists(os.path.join(topdir, '.bzr')):
|
missing = set()
|
||||||
contributors = set()
|
contributors = set()
|
||||||
|
|
||||||
mailmap = parse_mailmap(os.path.join(topdir, '.mailmap'))
|
mailmap = parse_mailmap(os.path.join(topdir, '.mailmap'))
|
||||||
|
authors_file = open(os.path.join(topdir, 'Authors'), 'r').read()
|
||||||
|
|
||||||
|
if os.path.exists(os.path.join(topdir, '.bzr')):
|
||||||
import bzrlib.workingtree
|
import bzrlib.workingtree
|
||||||
tree = bzrlib.workingtree.WorkingTree.open(topdir)
|
tree = bzrlib.workingtree.WorkingTree.open(topdir)
|
||||||
tree.lock_read()
|
tree.lock_read()
|
||||||
@@ -47,12 +48,28 @@ class ProjectTestCase(test.TestCase):
|
|||||||
for r in revs:
|
for r in revs:
|
||||||
for author in r.get_apparent_authors():
|
for author in r.get_apparent_authors():
|
||||||
email = author.split(' ')[-1]
|
email = author.split(' ')[-1]
|
||||||
|
contributors.add(str_dict_replace(email,
|
||||||
|
mailmap))
|
||||||
|
finally:
|
||||||
|
tree.unlock()
|
||||||
|
|
||||||
|
elif os.path.exists(os.path.join(topdir, '.git')):
|
||||||
|
import git
|
||||||
|
repo = git.Repo(topdir)
|
||||||
|
for commit in repo.head.commit.iter_parents():
|
||||||
|
email = commit.author.email
|
||||||
|
if email is None:
|
||||||
|
email = commit.author.name
|
||||||
|
if 'nova-core' in email:
|
||||||
|
continue
|
||||||
|
if email.split(' ')[-1] == '<>':
|
||||||
|
email = email.split(' ')[-2]
|
||||||
|
email = '<' + email + '>'
|
||||||
contributors.add(str_dict_replace(email, mailmap))
|
contributors.add(str_dict_replace(email, mailmap))
|
||||||
|
|
||||||
authors_file = open(os.path.join(topdir, 'Authors'),
|
else:
|
||||||
'r').read()
|
self.assertTrue(False, 'Cannot read commit history')
|
||||||
|
|
||||||
missing = set()
|
|
||||||
for contributor in contributors:
|
for contributor in contributors:
|
||||||
if contributor == 'nova-core':
|
if contributor == 'nova-core':
|
||||||
continue
|
continue
|
||||||
@@ -61,8 +78,6 @@ class ProjectTestCase(test.TestCase):
|
|||||||
|
|
||||||
self.assertTrue(len(missing) == 0,
|
self.assertTrue(len(missing) == 0,
|
||||||
'%r not listed in Authors' % missing)
|
'%r not listed in Authors' % missing)
|
||||||
finally:
|
|
||||||
tree.unlock()
|
|
||||||
|
|
||||||
|
|
||||||
class LockTestCase(test.TestCase):
|
class LockTestCase(test.TestCase):
|
||||||
|
|||||||
Reference in New Issue
Block a user