X-Git-Url: https://pwan.org/git/?p=margebot.git;a=blobdiff_plain;f=plugins%2Fmarge.py;fp=plugins%2Fmarge.py;h=7be6ea6630eb093d1c44ddc8d90e7f8ed8f3012a;hp=0dbbffe558726647fce1f5ed3198b6ee90e35177;hb=209be8741c76d9f3cdc70dff38bb8982369f4890;hpb=133b2a8561644869ab29db462718f7121f54d800 diff --git a/plugins/marge.py b/plugins/marge.py index 0dbbffe..7be6ea6 100755 --- a/plugins/marge.py +++ b/plugins/marge.py @@ -186,7 +186,7 @@ class Marge(BotPlugin, CrontabMixin): # Only weed out MRs less than the soak time for the crontab output (where author==None) now = datetime.now(timezone.utc) - creation_time = parser.parse(mr_attrs['created_at'], tzinfos=tzutc) + creation_time = parser.parse(mr_attrs['created_at'], tzinfos=[tzutc()]).astimezone(timezone.utc) if not author: self.log.info("times: {}, {}, {}".format(creation_time, self.soak_delta, now)) if creation_time + self.soak_delta > now: @@ -431,33 +431,31 @@ class Marge(BotPlugin, CrontabMixin): msg = "Couldn't find {} hooks".format(repo) self.log.error("watchrepo: {}".format(msg)) return msg - else: - for a_hook in hooks: - self.log.info('a_hook: {}'.format(a_hook)) - hook_attributes = a_hook.attributes - if hook_attributes['merge_requests_events'] and hook_attributes['url'].startswith(self.webhook_url): - marge_hook = a_hook - break + + for a_hook in hooks: + self.log.info('a_hook: {}'.format(a_hook)) + hook_attributes = a_hook.attributes + if hook_attributes['merge_requests_events'] and hook_attributes['url'].startswith(self.webhook_url): + marge_hook = a_hook + break # If so replace it (or error out ?) url = "{}{}".format(self.webhook_url, rooms) # webhooks_url will end in '/' hook_updated = True if marge_hook: - old_rooms = marge_hook.attributes['url'].split(self.webhook_url, 1)[1] if old_rooms == rooms: msg = "Already reporting {} MRs to the {} room(s)".format(repo, rooms) self.log.info('watchrepo: {}'.format(msg)) return msg - else: - try: - s_action = "update" - marge_hook.attributes['url'] = url - marge_hook.save() - s_watch_msg = "Updating room list for {} MRs from {} to {}".format(repo, old_rooms, rooms) - except Exception as exp: - hook_updated = False - self.log.error("watchrepo; update hook {} raised exception {}".format(repo, exp)) + try: + s_action = "update" + marge_hook.attributes['url'] = url + marge_hook.save() + s_watch_msg = "Updating room list for {} MRs from {} to {}".format(repo, old_rooms, rooms) + except Exception as exp: + hook_updated = False + self.log.error("watchrepo; update hook {} raised exception {}".format(repo, exp)) else: try: s_action = "add"