Chromium Code Reviews| Index: dashboard/dashboard/pinpoint/models/job.py |
| diff --git a/dashboard/dashboard/pinpoint/models/job.py b/dashboard/dashboard/pinpoint/models/job.py |
| index 2d625aeb3824a8399301a89a2ddc143ea7e57d41..a65b2e382d1732e2e31788d677ce6d83735d439d 100644 |
| --- a/dashboard/dashboard/pinpoint/models/job.py |
| +++ b/dashboard/dashboard/pinpoint/models/job.py |
| @@ -114,11 +114,11 @@ class Job(ndb.Model): |
| self._PostBugComment('started') |
| def Complete(self): |
| - self._PostBugComment('completed') |
| + self._PostBugComment('completed', include_differences=True) |
| def Fail(self): |
| self.exception = traceback.format_exc() |
| - self._PostBugComment('stopped with an error') |
| + self._PostBugComment('stopped with an error', include_differences=True) |
| def Schedule(self): |
| task = taskqueue.add(queue_name='job-queue', url='/api/run/' + self.job_id, |
| @@ -160,27 +160,25 @@ class Job(ndb.Model): |
| d.update(self.state.AsDict()) |
| return d |
| - def _PostBugComment(self, status): |
| + def _PostBugComment(self, status, include_differences=False): |
| if not self.bug_id: |
| return |
| title = '%s Pinpoint job %s.' % (_ROUND_PUSHPIN, status) |
| header = '\n'.join((title, self.url)) |
| - # Include list of Changes. |
| change_details = [] |
| - for _, change in self.state.Differences(): |
| - # TODO: Store the commit info in the Commit. |
| - commit = change.last_commit |
| - commit_info = gitiles_service.CommitInfo(commit.repository_url, |
| - commit.git_hash) |
| - subject = '<b>%s</b>' % commit_info['message'].split('\n', 1)[0] |
| - author = commit_info['author']['email'] |
| - time = commit_info['committer']['time'] |
| - |
| - byline = 'By %s %s %s' % (author, _MIDDLE_DOT, time) |
| - git_link = commit.repository + '@' + commit.git_hash |
| - change_details.append('\n'.join((subject, byline, git_link))) |
| + if include_differences: |
| + # Include list of Changes. |
| + differences = tuple(self.state.Differences()) |
| + change_details.append( |
|
perezju
2017/09/21 09:57:18
nit: only append this when there are differences
dtu
2017/09/21 19:32:29
Done.
|
| + '<b>Found significant differences from %d commits:</b>' % |
|
perezju
2017/09/21 09:57:18
suggestion nits:
with multiple commits: 'Found si
dtu
2017/09/21 19:32:29
Done.
|
| + len(differences)) |
| + if differences: |
| + for _, change in differences: |
| + change_details.append(_FormatChangeForBug(change)) |
| + else: |
| + change_details.append("<b>Couldn't reproduce a difference.</b>") |
| comment = '\n\n'.join([header] + change_details) |
| @@ -352,6 +350,20 @@ class _JobState(object): |
| return _UNKNOWN |
| +def _FormatChangeForBug(change): |
| + # TODO: Store the commit info in the Commit. |
| + commit = change.last_commit |
| + commit_info = gitiles_service.CommitInfo(commit.repository_url, |
| + commit.git_hash) |
| + subject = '<b>%s</b>' % commit_info['message'].split('\n', 1)[0] |
| + author = commit_info['author']['email'] |
| + time = commit_info['committer']['time'] |
| + |
| + byline = 'By %s %s %s' % (author, _MIDDLE_DOT, time) |
| + git_link = commit.repository + '@' + commit.git_hash |
| + return '\n'.join((subject, byline, git_link)) |
| + |
| + |
| def _CombineResultsPerQuest(attempts): |
| aggregate_results = collections.defaultdict(list) |
| for attempt in attempts: |