-
-
Save zzzeid/021793d21094d247a107bc87089049db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Generate change log to be pasted in the Mozilla wiki and Discourse: | |
- https://wiki.mozilla.org/MozPhab/Changelog | |
- https://discourse.mozilla.org/c/firefox-tooling-announcements | |
""" | |
import re | |
import requests | |
import subprocess | |
import sys | |
import time | |
MOZPHAB_PATH = "/home/zeid/src/review" | |
def fetch_bugzilla_info(bug): | |
"""Get bug info from the Bugzilla API | |
Args: | |
bug (int): A bug ID to query. | |
Returns: | |
dict: Dictionary containing bug info of the given bug. | |
""" | |
url = f"https://bugzilla.mozilla.org/rest/bug/{bug}" | |
response = requests.get(url) | |
# TODO -- is there a better way to query individual bugs, or a list of bugs? | |
return response.json()["bugs"][0] | |
def get_bug_ids(a, b, mozphab_path=MOZPHAB_PATH): | |
"""Fetch commits between version `a` and version `b` and return Bug IDs""" | |
output = subprocess.check_output( | |
["git", "log", "--oneline", f"{a}..{b}"], cwd=mozphab_path | |
).decode("utf-8") | |
bug_re = re.compile(r"^.*[Bug|bug] (\d+).*$", flags=re.MULTILINE) | |
bug_ids = [] | |
for line in output.split("\n"): | |
bug = bug_re.match(line) | |
if bug: | |
bug_ids.append(bug.groups()[0]) | |
bug_ids = list(set(bug_ids)) | |
bug_ids.sort() | |
return bug_ids | |
if __name__ == "__main__": | |
if len(sys.argv) != 3: | |
print("Usage: release <last version> <current version>") | |
sys.exit() | |
a = sys.argv[1] | |
b = sys.argv[2] | |
bug_ids = get_bug_ids(a, b) | |
bug_titles = {} | |
for bug in bug_ids: | |
time.sleep(0.1) | |
test = fetch_bugzilla_info(bug) | |
bug_titles[bug] = fetch_bugzilla_info(bug)["summary"] | |
print() | |
print(f"{'*' * 32} >8 copy and paste to wiki {'*' * 32}") | |
print(f"=== {b} ===") | |
for bug, bug_title in bug_titles.items(): | |
print(f"* {{{{bug|{bug}}}}} {bug_title}") | |
print() | |
print(f"{'*' * 32} >8 copy and paste to discourse {'*' * 32}") | |
print(f"Bugs resolved in Moz-Phab {b}:") | |
for bug, bug_title in bug_titles.items(): | |
print(f"- [bug {bug}](https://bugzilla.mozilla.org/{bug}) {bug_title}") | |
print() | |
print("Discuss these changes in #conduit on Slack or Matrix.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment