Merge pull request #1088 from jberry-suse/ReviewBot-only_replace
repo_checker: post passed comment only if previous failed comment (and debug improvements).
This commit is contained in:
commit
c71e075396
21
ReviewBot.py
21
ReviewBot.py
@ -435,7 +435,7 @@ class ReviewBot(object):
|
|||||||
self.comment_handler.lines = list(OrderedDict.fromkeys(self.comment_handler.lines))
|
self.comment_handler.lines = list(OrderedDict.fromkeys(self.comment_handler.lines))
|
||||||
|
|
||||||
def comment_write(self, state='done', result=None, project=None, package=None,
|
def comment_write(self, state='done', result=None, project=None, package=None,
|
||||||
request=None, message=None, identical=False):
|
request=None, message=None, identical=False, only_replace=False):
|
||||||
"""Write comment from log messages if not similar to previous comment."""
|
"""Write comment from log messages if not similar to previous comment."""
|
||||||
if project:
|
if project:
|
||||||
kwargs = {'project_name': project}
|
kwargs = {'project_name': project}
|
||||||
@ -460,17 +460,22 @@ class ReviewBot(object):
|
|||||||
(not identical and comment['comment'].count('\n') == message.count('\n')))
|
(not identical and comment['comment'].count('\n') == message.count('\n')))
|
||||||
):
|
):
|
||||||
# Assume same state/result and number of lines in message is duplicate.
|
# Assume same state/result and number of lines in message is duplicate.
|
||||||
self.logger.debug('previous comment on {} too similar'.format(debug_key))
|
self.logger.debug('previous comment too similar on {}'.format(debug_key))
|
||||||
|
return
|
||||||
|
|
||||||
|
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'])
|
||||||
|
elif only_replace:
|
||||||
|
self.logger.debug('no previous comment to replace on {}'.format(debug_key))
|
||||||
return
|
return
|
||||||
|
|
||||||
self.logger.debug('adding comment to {}: {}'.format(debug_key, message))
|
self.logger.debug('adding comment to {}: {}'.format(debug_key, message))
|
||||||
|
|
||||||
if not self.dryrun:
|
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:
|
|
||||||
self.comment_api.delete(comment['id'])
|
|
||||||
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()
|
||||||
|
@ -187,6 +187,11 @@ class RepoChecker(ReviewBot.ReviewBot):
|
|||||||
# Some checks in group did not pass, post comment.
|
# Some checks in group did not pass, post comment.
|
||||||
self.comment_write(state='seen', result='failed', project=group,
|
self.comment_write(state='seen', result='failed', project=group,
|
||||||
message='\n'.join(comment).strip(), identical=True)
|
message='\n'.join(comment).strip(), identical=True)
|
||||||
|
else:
|
||||||
|
# Post passed comment only if previous failed comment.
|
||||||
|
text = 'Previously reported problems have been resolved.'
|
||||||
|
self.comment_write(state='done', result='passed', project=group,
|
||||||
|
message=text, identical=True, only_replace=True)
|
||||||
|
|
||||||
return self.group_pass
|
return self.group_pass
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user