Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion bugbot/rules/uplift_beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

import re

from libmozdata import utils as lmdutils
from libmozdata.bugzilla import Bugzilla

from bugbot import utils
from bugbot.bzcleaner import BzCleaner

LANDO_BASE_URL = "https://lando.moz.tools/"
PHAB_FILE_NAME_PAT = re.compile(r"phabricator-D([0-9]+)-url\.txt")


class UpliftBeta(BzCleaner):
def __init__(self):
Expand Down Expand Up @@ -36,6 +41,21 @@ def get_extra_for_needinfo_template(self):
def columns(self):
return ["id", "summary", "assignee"]

@staticmethod
def get_lando_url(attachments):
"""Get Lando URL if there is exactly one non-obsolete Phabricator attachment."""
rev_ids = [
int(m.group(1))
for attachment in attachments
if attachment["content_type"] == "text/x-phabricator-request"
and not attachment["is_obsolete"]
for m in [PHAB_FILE_NAME_PAT.match(attachment["file_name"])]
if m
]
if len(rev_ids) == 1:
return f"{LANDO_BASE_URL}D{rev_ids[0]}"
return None

def handle_bug(self, bug, data):
bugid = str(bug["id"])

Expand All @@ -55,6 +75,7 @@ def handle_bug(self, bug, data):
"nickname": nickname,
"summary": self.get_summary(bug),
"regressions": bug["regressions"],
"lando_url": self.get_lando_url(bug.get("attachments", [])),
}

return bug
Expand Down Expand Up @@ -102,6 +123,7 @@ def get_bz_params(self, date):
"attachments.creation_time",
"attachments.is_obsolete",
"attachments.content_type",
"attachments.file_name",
"cf_last_resolved",
"assigned_to",
"flags",
Expand Down Expand Up @@ -143,7 +165,10 @@ def get_bugs(self, date="today", bug_ids=[]):

for bugid, data in bugs.items():
if data["mail"] and data["nickname"]:
self.extra_ni[bugid] = {"regression": len(data["regressions"])}
self.extra_ni[bugid] = {
"regression": len(data["regressions"]),
"lando_url": data["lando_url"],
}
self.add_auto_ni(
bugid, {"mail": data["mail"], "nickname": data["nickname"]}
)
Expand Down
3 changes: 2 additions & 1 deletion templates/uplift_beta_needinfo.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
The patch landed in nightly and beta is affected.
:{{ nickname }}, is this bug important enough to require an uplift?
- If yes, please nominate the patch for beta approval.{% if extra[bugid]["regression"] %} Also, don't forget to request an uplift for the patches in the {{ plural('regression', extra[bugid]["regression"]) }} caused by this fix.{% endif %}
- See https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift for documentation on how to request an uplift.
- See https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift for documentation on how to request an uplift.{% if extra[bugid]["lando_url"] %}
- The patch is available at {{ extra[bugid]["lando_url"] }}.{% endif %}
- If no, please set `{{ extra["status_beta"] }}` to `wontfix`.

{{ documentation }}