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)) self.logger.debug('previous comment too similar on {}'.format(debug_key))
return return
self.logger.debug('adding comment to {}: {}'.format(debug_key, message)) if comment is None:
self.logger.debug('broadening search to include any state on {}'.format(debug_key))
if not self.dryrun: comment, _ = self.comment_api.comment_find(comments, self.bot_name)
if comment is None: if comment is not None:
# Broaden search to include any comment state. self.logger.debug('removing previous comment on {}'.format(debug_key))
comment, _ = self.comment_api.comment_find(comments, self.bot_name) if not self.dryrun:
if comment is not None:
self.comment_api.delete(comment['id']) 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_api.add_comment(comment=str(message), **kwargs)
self.comment_handler_remove() self.comment_handler_remove()