Skip to content

Commit b43c1d5

Browse files
Simplify Lando URL via string replace; show all patch links
Agent-Logs-Url: https://github.com/mozilla/bugbot/sessions/4d972f29-57cb-43ea-beec-05b7e74f8a71 Co-authored-by: suhaibmujahid <4151357+suhaibmujahid@users.noreply.github.com>
1 parent adc4677 commit b43c1d5

3 files changed

Lines changed: 17 additions & 26 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ db/*
1515
cache/
1616
.coverage
1717
.tox/
18-
*.egg-info/

bugbot/rules/uplift_beta.py

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
# You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
import base64
6-
import re
76

87
from libmozdata import utils as lmdutils
98
from libmozdata.bugzilla import Bugzilla
109

1110
from bugbot import utils
1211
from bugbot.bzcleaner import BzCleaner
1312

14-
PHAB_URL_PAT = re.compile(r"https://phabricator\.services\.mozilla\.com/D([0-9]+)")
13+
PHAB_BASE_URL = "https://phabricator.services.mozilla.com/"
1514
LANDO_BASE_URL = "https://lando.moz.tools/"
1615

1716

@@ -43,25 +42,18 @@ def columns(self):
4342
return ["id", "summary", "assignee"]
4443

4544
@staticmethod
46-
def get_lando_url(attachments):
47-
"""Get the Lando URL for the most recently created non-obsolete
48-
Phabricator attachment, or None if no such attachment exists."""
49-
phab_attachments = [
50-
a
51-
for a in attachments
52-
if a["content_type"] == "text/x-phabricator-request"
53-
and not a["is_obsolete"]
54-
]
55-
if not phab_attachments:
56-
return None
57-
58-
latest = max(phab_attachments, key=lambda a: a["creation_time"])
59-
phab_url = base64.b64decode(latest["data"]).decode("utf-8")
60-
m = PHAB_URL_PAT.search(phab_url)
61-
if not m:
62-
return None
63-
64-
return f"{LANDO_BASE_URL}D{m.group(1)}"
45+
def get_lando_urls(attachments):
46+
"""Get Lando URLs for all non-obsolete Phabricator attachments."""
47+
urls = []
48+
for attachment in attachments:
49+
if (
50+
attachment["content_type"] == "text/x-phabricator-request"
51+
and not attachment["is_obsolete"]
52+
):
53+
phab_url = base64.b64decode(attachment["data"]).decode("utf-8").strip()
54+
if phab_url.startswith(PHAB_BASE_URL):
55+
urls.append(phab_url.replace(PHAB_BASE_URL, LANDO_BASE_URL, 1))
56+
return urls
6557

6658
def handle_bug(self, bug, data):
6759
bugid = str(bug["id"])
@@ -82,7 +74,7 @@ def handle_bug(self, bug, data):
8274
"nickname": nickname,
8375
"summary": self.get_summary(bug),
8476
"regressions": bug["regressions"],
85-
"lando_url": self.get_lando_url(bug.get("attachments", [])),
77+
"lando_urls": self.get_lando_urls(bug.get("attachments", [])),
8678
}
8779

8880
return bug
@@ -174,7 +166,7 @@ def get_bugs(self, date="today", bug_ids=[]):
174166
if data["mail"] and data["nickname"]:
175167
self.extra_ni[bugid] = {
176168
"regression": len(data["regressions"]),
177-
"lando_url": data["lando_url"],
169+
"lando_urls": data["lando_urls"],
178170
}
179171
self.add_auto_ni(
180172
bugid, {"mail": data["mail"], "nickname": data["nickname"]}

templates/uplift_beta_needinfo.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
The patch landed in nightly and beta is affected.
22
:{{ nickname }}, is this bug important enough to require an uplift?
33
- 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 %}
4-
- See https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift for documentation on how to request an uplift.{% if extra[bugid]["lando_url"] %}
5-
- The patch is available at {{ extra[bugid]["lando_url"] }}.{% endif %}
4+
- See https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift for documentation on how to request an uplift.{% for url in extra[bugid]["lando_urls"] %}
5+
- The patch is available at {{ url }}.{% endfor %}
66
- If no, please set `{{ extra["status_beta"] }}` to `wontfix`.
77

88
{{ documentation }}

0 commit comments

Comments
 (0)