Skip to content

Commit 5d37e37

Browse files
committed
make pr page support revision field from podutils
1 parent 98243b2 commit 5d37e37

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

gubernator/pull_request.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ def builds_to_table(jobs):
2828
"""
2929
# pylint: disable=too-many-locals
3030

31-
def commit(started):
31+
def commit(started, finished):
3232
if 'pull' in started:
3333
return started['pull'].split(':')[-1]
3434
if 'version' in started:
3535
return started['version'].split('+')[-1]
36+
if 'revision' in finished:
37+
return finished['revision']
3638
return 'unknown'
3739

3840
# Compute the headings first -- versions and their maximum build counts.
@@ -43,7 +45,7 @@ def commit(started):
4345
for build, started, finished in builds:
4446
if not started:
4547
continue
46-
version = commit(started)
48+
version = commit(started, finished)
4749
if not version:
4850
continue
4951
versions.setdefault(version, {}).setdefault(job, 0)
@@ -68,10 +70,10 @@ def commit(started):
6870
row = []
6971
n = 0
7072
for build, started, finished in builds:
71-
if not started or not commit(started):
73+
if not started or not commit(started, finished):
7274
minspan = 0
7375
else:
74-
minspan = version_colstart[commit(started)]
76+
minspan = version_colstart[commit(started, finished)]
7577
while n < minspan:
7678
row.append(None)
7779
n += 1

gubernator/pull_request_test.py

+14
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def make(number, version, result, start_time=1000):
2525
finished = result and {'result': result}
2626
return (number, started, finished)
2727

28+
def makePodutil(number, revision, result, start_time=1000):
29+
started = {'timestamp': start_time}
30+
finished = result and {'result': result, 'revision': revision}
31+
return (number, started, finished)
2832

2933
class TableTest(unittest.TestCase):
3034

@@ -48,3 +52,13 @@ def test_pull_ref_commit(self):
4852
jobs['J1'][0][1]['pull'] = 'master:1234,35:abcd'
4953
_, headings, _ = pull_request.builds_to_table(jobs)
5054
self.assertEqual(headings, [('abcd', 1, 9)])
55+
56+
def test_builds_to_table_podutils(self):
57+
jobs = {'J1': [makePodutil(4, 'v2', 'A', 9), makePodutil(3, 'v2', 'B', 10)],
58+
'J2': [makePodutil(5, 'v1', 'C', 7), makePodutil(4, 'v1', 'D', 6)]}
59+
max_builds, headings, rows = pull_request.builds_to_table(jobs)
60+
61+
self.assertEqual(max_builds, 4)
62+
self.assertEqual(headings, [('v2', 2, 9), ('v1', 2, 6)])
63+
self.assertEqual(rows, [('J1', [(4, 'A'), (3, 'B')]),
64+
('J2', [None, None, (5, 'C'), (4, 'D')])])

0 commit comments

Comments
 (0)