From 76f91fe25064e5a9bada9b96e00facd02ef345fa Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Fri, 29 Apr 2016 15:08:31 +0200 Subject: [PATCH] Update the openQA if the number of tests changed --- openqa-maintenance.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/openqa-maintenance.py b/openqa-maintenance.py index a2d4c1b2..92753f61 100755 --- a/openqa-maintenance.py +++ b/openqa-maintenance.py @@ -403,17 +403,23 @@ class OpenQABot(ReviewBot.ReviewBot): if not self.do_comments: return - (comment_id, comment_state, comment_result) = self.find_obs_request_comment(req, state) - if comment_id is not None: - self.logger.debug("found comment %s, state %s", comment_id, comment_state) - return - comment = "\n" % (state, ' result=%s' % result if result else '') comment += "\n" + msg + (comment_id, comment_state, comment_result, comment_text) = self.find_obs_request_comment(req, state) + + if comment_id is not None and state == comment_state: + lines_before = len(comment_text.split('\n')) + lines_after = len(comment.split('\n')) + if lines_before == lines_after: + self.logger.debug("not worth the update, previous comment %s is state %s", comment_id, comment_state) + return + self.logger.debug("adding comment to %s, state %s result %s", req.reqid, state, result) self.logger.debug("message: %s", msg) if not self.dryrun: + if comment_id is not None: + self.commentapi.delete(comment_id) self.commentapi.add_comment(request_id=req.reqid, comment=str(comment)) def openqa_overview_url_from_settings(self, settings): @@ -448,7 +454,7 @@ class OpenQABot(ReviewBot.ReviewBot): if self.force: # make sure to delete previous comments if we're forcing - (comment_id, comment_state, comment_result) = self.find_obs_request_comment(req) + (comment_id, comment_state, comment_result, comment_text) = self.find_obs_request_comment(req) if comment_id is not None: self.logger.debug("deleting old comment %s", comment_id) if not self.dryrun: @@ -503,8 +509,8 @@ class OpenQABot(ReviewBot.ReviewBot): for c in comments.values(): m = comment_marker_re.match(c['comment']) if m and (state is None or state == m.group('state')): - return c['id'], m.group('state'), m.group('result') - return None, None, None + return c['id'], m.group('state'), m.group('result'), c['comment'] + return None, None, None, None class CommandLineInterface(ReviewBot.CommandLineInterface):