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
1=== modified file 'nova/tests/test_misc.py'
2--- nova/tests/test_misc.py 2011-03-22 15:29:37 +0000
3+++ nova/tests/test_misc.py 2011-04-19 21:01:13 +0000
4@@ -29,11 +29,12 @@
5 class ProjectTestCase(test.TestCase):
6 def test_authors_up_to_date(self):
7 topdir = os.path.normpath(os.path.dirname(__file__) + '/../../')
8+ missing = set()
9+ contributors = set()
10+ mailmap = parse_mailmap(os.path.join(topdir, '.mailmap'))
11+ authors_file = open(os.path.join(topdir, 'Authors'), 'r').read()
12+
13 if os.path.exists(os.path.join(topdir, '.bzr')):
14- contributors = set()
15-
16- mailmap = parse_mailmap(os.path.join(topdir, '.mailmap'))
17-
18 import bzrlib.workingtree
19 tree = bzrlib.workingtree.WorkingTree.open(topdir)
20 tree.lock_read()
21@@ -47,23 +48,37 @@
22 for r in revs:
23 for author in r.get_apparent_authors():
24 email = author.split(' ')[-1]
25- contributors.add(str_dict_replace(email, mailmap))
26-
27- authors_file = open(os.path.join(topdir, 'Authors'),
28- 'r').read()
29-
30- missing = set()
31- for contributor in contributors:
32- if contributor == 'nova-core':
33- continue
34- if not contributor in authors_file:
35- missing.add(contributor)
36-
37- self.assertTrue(len(missing) == 0,
38- '%r not listed in Authors' % missing)
39+ contributors.add(str_dict_replace(email,
40+ mailmap))
41 finally:
42 tree.unlock()
43
44+ elif os.path.exists(os.path.join(topdir, '.git')):
45+ import git
46+ repo = git.Repo(topdir)
47+ for commit in repo.head.commit.iter_parents():
48+ email = commit.author.email
49+ if email is None:
50+ email = commit.author.name
51+ if 'nova-core' in email:
52+ continue
53+ if email.split(' ')[-1] == '<>':
54+ email = email.split(' ')[-2]
55+ email = '<' + email + '>'
56+ contributors.add(str_dict_replace(email, mailmap))
57+
58+ else:
59+ self.assertTrue(False, 'Cannot read commit history')
60+
61+ for contributor in contributors:
62+ if contributor == 'nova-core':
63+ continue
64+ if not contributor in authors_file:
65+ missing.add(contributor)
66+
67+ self.assertTrue(len(missing) == 0,
68+ '%r not listed in Authors' % missing)
69+
70
71 class LockTestCase(test.TestCase):
72 def test_synchronized_wrapped_function_metadata(self):