in bugbot/rules/bisection_without_regressed_by.py [0:0]
def comment_handler(self, bug, bug_id, bugs):
analysis_comment_number = None
# We start from the last comment just in case bugmon has updated the range.
for comment in bug["comments"][::-1]:
if comment["creation_time"] < self.oldest_comment_date:
break
# Using comments that quote other comments will lead to report an
# inaccurate comment number.
if "(In reply to " in comment["text"]:
continue
# We target comments that have pushlog from BugMon or mozregression.
if self.is_bugmon_analysis(comment["text"]):
pushlog_source = "bugmon"
elif self.is_mozregression_analysis(comment["text"]):
pushlog_source = "mozregression"
else:
continue
pushlog_match = PUSHLOG_PAT.findall(comment["text"])
if len(pushlog_match) != 1:
continue
# Try to parse the regression range to find the regressor or at least somebody good to needinfo.
url = (
pushlog_match[0].replace("pushloghtml", "json-pushes")
+ "&full=1&version=2"
)
r = requests.get(url)
r.raise_for_status()
creation_time = lmdutils.get_timestamp(bugs[bug_id]["creation_time"])
changesets = [
changeset
for push in r.json()["pushes"].values()
if creation_time > push["date"]
for changeset in push["changesets"]
if any(not is_ignorable_path(path) for path in changeset["files"])
]
if not changesets:
continue
analysis_comment_number = comment["count"]
regressor_bug_ids = set()
for changeset in changesets:
bug_match = BUG_PAT.search(changeset["desc"])
if bug_match is not None:
regressor_bug_ids.add(bug_match.group(1))
if len(regressor_bug_ids) == 1:
# Only one bug in the regression range, we are sure about the regressor!
bugs[bug_id]["regressor_bug_id"] = regressor_bug_ids.pop()
break
if "needinfo_targets" not in bugs[bug_id]:
authors = set(changeset["author"] for changeset in changesets)
if authors and len(authors) <= self.max_ni:
needinfo_targets = []
for author in authors:
author_parts = author.split("<")
author_email = author_parts[1][:-1]
bzmail = self.people.get_bzmail_from_name(author_email)
if not bzmail:
logger.warning(f"No bzmail for {author} in bug {bug_id}")
continue
needinfo_targets.append(bzmail)
if needinfo_targets:
bugs[bug_id]["needinfo_targets"] = needinfo_targets
break
# Exclude bugs that do not have a range found by BugMon or mozregression.
if analysis_comment_number is not None:
bug = bugs[bug_id]
bug["comment_number"] = analysis_comment_number
bug["pushlog_source"] = pushlog_source
else:
del bugs[bug_id]