Merge lp:~jason-koelker/nova/lp765159 into lp:~hudson-openstack/nova/trunk

Proposed by Jason Kölker
Status: Merged
Approved by: Josh Kearney
Approved revision: 1004
Merged at revision: 1044
Proposed branch: lp:~jason-koelker/nova/lp765159
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 72 lines (+33/-18)
1 file modified
nova/tests/test_misc.py (+33/-18)
To merge this branch: bzr merge lp:~jason-koelker/nova/lp765159
Reviewer Review Type Date Requested Status
Trey Morris (community) Approve
Matt Dietz (community) Approve
Review via email: mp+58390@code.launchpad.net

Commit message

add support for git checking and a default of failing if the history can't be read

Description of the change

Fixes LP765159 (test_authors_up_to_date passes when if statement not met)

Also adds support for reading commit history for Authors verification from git (if you happen to use any of the git<->bzr stuff).

To post a comment you must log in.
Revision history for this message
Matt Dietz (cerberus) wrote :

This seems ok, and would be good for the git bridge people to have working correctly.

review: Approve
Revision history for this message
Trey Morris (tr3buchet) wrote :

gogogo

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nova/tests/test_misc.py'
--- nova/tests/test_misc.py 2011-03-22 15:29:37 +0000
+++ nova/tests/test_misc.py 2011-04-19 21:01:13 +0000
@@ -29,11 +29,12 @@
29class ProjectTestCase(test.TestCase):29class ProjectTestCase(test.TestCase):
30 def test_authors_up_to_date(self):30 def test_authors_up_to_date(self):
31 topdir = os.path.normpath(os.path.dirname(__file__) + '/../../')31 topdir = os.path.normpath(os.path.dirname(__file__) + '/../../')
32 missing = set()
33 contributors = set()
34 mailmap = parse_mailmap(os.path.join(topdir, '.mailmap'))
35 authors_file = open(os.path.join(topdir, 'Authors'), 'r').read()
36
32 if os.path.exists(os.path.join(topdir, '.bzr')):37 if os.path.exists(os.path.join(topdir, '.bzr')):
33 contributors = set()
34
35 mailmap = parse_mailmap(os.path.join(topdir, '.mailmap'))
36
37 import bzrlib.workingtree38 import bzrlib.workingtree
38 tree = bzrlib.workingtree.WorkingTree.open(topdir)39 tree = bzrlib.workingtree.WorkingTree.open(topdir)
39 tree.lock_read()40 tree.lock_read()
@@ -47,23 +48,37 @@
47 for r in revs:48 for r in revs:
48 for author in r.get_apparent_authors():49 for author in r.get_apparent_authors():
49 email = author.split(' ')[-1]50 email = author.split(' ')[-1]
50 contributors.add(str_dict_replace(email, mailmap))51 contributors.add(str_dict_replace(email,
5152 mailmap))
52 authors_file = open(os.path.join(topdir, 'Authors'),
53 'r').read()
54
55 missing = set()
56 for contributor in contributors:
57 if contributor == 'nova-core':
58 continue
59 if not contributor in authors_file:
60 missing.add(contributor)
61
62 self.assertTrue(len(missing) == 0,
63 '%r not listed in Authors' % missing)
64 finally:53 finally:
65 tree.unlock()54 tree.unlock()
6655
56 elif os.path.exists(os.path.join(topdir, '.git')):
57 import git
58 repo = git.Repo(topdir)
59 for commit in repo.head.commit.iter_parents():
60 email = commit.author.email
61 if email is None:
62 email = commit.author.name
63 if 'nova-core' in email:
64 continue
65 if email.split(' ')[-1] == '<>':
66 email = email.split(' ')[-2]
67 email = '<' + email + '>'
68 contributors.add(str_dict_replace(email, mailmap))
69
70 else:
71 self.assertTrue(False, 'Cannot read commit history')
72
73 for contributor in contributors:
74 if contributor == 'nova-core':
75 continue
76 if not contributor in authors_file:
77 missing.add(contributor)
78
79 self.assertTrue(len(missing) == 0,
80 '%r not listed in Authors' % missing)
81
6782
68class LockTestCase(test.TestCase):83class LockTestCase(test.TestCase):
69 def test_synchronized_wrapped_function_metadata(self):84 def test_synchronized_wrapped_function_metadata(self):