+ def mr_status_msg(self, a_mr, author=None):
+ self.log.info("mr_status_msg: a_mr: {}".format(a_mr))
+
+ now = datetime.now(timezone.utc)
+ creation_time = parser.parse(a_mr['created_at'], tzinfos=tzutc)
+ self.log.info("times: {}, {}, {}".format(creation_time, self.soak_delta, now))
+ if creation_time + self.soak_delta > now:
+ info_msg = "skipping: MR <{},{}> was opened less than {} hours ago".format(project, iid, soak_hours)
+ self.log.info(info_msg)
+ return None
+
+ str_open_since = deltastr(now - creation_time)
+
+ warning = ""
+ if a_mr['work_in_progress']:
+ warning = "still WIP"
+ elif a_mr['merge_status'] != 'can_be_merged':
+ warning = "there are merge conflicts"
+
+ if author:
+ authored = (a_mr['author']['id'] == author)
+ else:
+ authored = False
+
+ # TODO: Include the count of opened MR notes (does the API show resolved state ??)
+
+ # getapprovals is only available in GitLab 8.9 EE or greater (not the open source CE version)
+ # approvals = self.gitlab.getapprovals(a_mr['id'])
+ # also_approved = ""
+ # for approved in approvals['approved_by']:
+ # also_approved += "," + approved['user']['name']
+
+ upvotes = a_mr['upvotes']
+ msg = "{} (opened {})".format(a_mr['web_url'], str_open_since)
+ if upvotes >= 2:
+ msg += ": Has 2+ upvotes / Could be merge in now"
+ if warning != "":
+ msg += " except {}".format(a_mr['web_url'], str_open_since, warning)
+ else:
+ msg += "."
+
+ elif upvotes == 1:
+ if authored:
+ msg += ": Your MR is waiting for another upvote"
+ else:
+ msg += ": Waiting for another upvote"
+ if warning != "":
+ msg += "but {}.".format(warning)
+ else:
+ msg += "."
+
+ else:
+ if authored:
+ msg += ": Your MR has no upvotes"
+ else:
+ msg += ": No upvotes, please review"
+ if warning != "":
+ msg += "but {}".format(warning)
+ else:
+ msg += "."
+
+ return((creation_time, msg))
+
+