ReviewBot: comment_write(): pull dryrun protected bit out individually.

This commit is contained in:
Jimmy Berry 2017-08-23 15:17:26 -05:00
parent 757d31cf35
commit ca13855d2e

View File

@ -463,14 +463,16 @@ class ReviewBot(object):
self.logger.debug('previous comment too similar on {}'.format(debug_key))
return
self.logger.debug('adding comment to {}: {}'.format(debug_key, message))
if not self.dryrun:
if comment is None:
# Broaden search to include any comment state.
comment, _ = self.comment_api.comment_find(comments, self.bot_name)
if comment is not None:
if comment is None:
self.logger.debug('broadening search to include any state on {}'.format(debug_key))
comment, _ = self.comment_api.comment_find(comments, self.bot_name)
if comment is not None:
self.logger.debug('removing previous comment on {}'.format(debug_key))
if not self.dryrun:
self.comment_api.delete(comment['id'])
self.logger.debug('adding comment to {}: {}'.format(debug_key, message))
if not self.dryrun:
self.comment_api.add_comment(comment=str(message), **kwargs)
self.comment_handler_remove()