Log gerrit comment

Always log the gerrit comment, and when running in nocomment just don't
send it to gerrit. This helps make testing changes to the gerrit comment
easier.

Change-Id: Ie26b86ed374d284154389b4bd5a86b9d2f365800
This commit is contained in:
Joe Gordon 2014-01-30 19:27:48 -08:00
parent cd37ee2369
commit 5c6dc37552
2 changed files with 12 additions and 10 deletions

View File

@ -193,11 +193,9 @@ class RecheckWatch(threading.Thread):
self._read(event)
else:
self._read(event)
if self.commenting:
stream.leave_comment(
event.project,
event.name(),
event.bugs)
stream.leave_comment(
event,
debug=not self.commenting)
except er.ResultTimedOut as e:
LOG.warn(e.msg)
self._read(msg=e.msg)

View File

@ -257,9 +257,10 @@ class Stream(object):
if self._does_es_have_data(fevent.change, fevent.rev, failed_jobs):
return fevent
def leave_comment(self, project, commit, bugs=None):
if bugs:
bug_urls = ['https://bugs.launchpad.net/bugs/%s' % x for x in bugs]
def leave_comment(self, event, debug=False):
if event.bugs:
bug_urls = ['https://bugs.launchpad.net/bugs/%s' % x
for x in event.bugs]
message = """I noticed tempest failed, I think you hit bug(s):
- %(bugs)s
@ -275,12 +276,15 @@ For a code review which has been approved but failed to merge,
you can reverify by leaving a comment like this:
reverify bug %(bug)s""" % {'bugs': "\n- ".join(bug_urls),
'bug': list(bugs)[0]}
'bug': list(event.bugs)[0]}
else:
message = ("I noticed tempest failed, refer to: "
"https://wiki.openstack.org/wiki/"
"GerritJenkinsGithub#Test_Failures")
self.gerrit.review(project, commit, message)
LOG.debug("Compiled comment for commit %s:\n%s" %
(event.name(), message))
if not debug:
self.gerrit.review(event.project, event.name(), message)
class Classifier():