richard pushed to branch maint-13.0 at The Tor Project / Applications / tor-browser-build
Commits: 2fbd7956 by Pier Angelo Vendrame at 2023-12-19T12:02:56+00:00 Bug 41042: Add options to include updates in the changelog scripts.
Pass the new version of components as arguments to avoid having to change the changelog output after it has been generated by the script.
- - - - -
1 changed file:
- tools/fetch-changelogs.py
Changes:
===================================== tools/fetch-changelogs.py ===================================== @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import argparse from datetime import datetime import enum from pathlib import Path @@ -23,6 +24,11 @@ project_order = { }
+class EntryType(enum.IntFlag): + UPDATE = 0 + ISSUE = 1 + + class Platform(enum.IntFlag): WINDOWS = 8 MACOS = 4 @@ -32,40 +38,12 @@ class Platform(enum.IntFlag): ALL_PLATFORMS = 8 | 4 | 2 | 1
-class Issue: - def __init__(self, j): - self.title = j["title"] - self.project, self.number = ( - j["references"]["full"].rsplit("/", 2)[-1].split("#") - ) - self.number = int(self.number) - self.platform = 0 - self.num_platforms = 0 - if "Desktop" in j["labels"]: - self.platform = Platform.DESKTOP - self.num_platforms += 3 - else: - if "Windows" in j["labels"]: - self.platform |= Platform.WINDOWS - self.num_platforms += 1 - if "MacOS" in j["labels"]: - self.platform |= Platform.MACOS - self.num_platforms += 1 - if "Linux" in j["labels"]: - self.platform |= Platform.LINUX - self.num_platforms += 1 - if "Android" in j["labels"]: - if is_mb and self.num_platforms == 0: - raise Exception( - f"Android-only issue on Mullvad Browser: {j['references']['full']}!" - ) - elif not is_mb: - self.platform |= Platform.ANDROID - self.num_platforms += 1 - if not self.platform or (is_mb and self.platform == Platform.DESKTOP): - self.platform = Platform.ALL_PLATFORMS - self.num_platforms = 4 - self.is_build = "Build System" in j["labels"] +class ChangelogEntry: + def __init__(self, type_, platform, num_platforms, is_build): + self.type = type_ + self.platform = platform + self.num_platforms = num_platforms + self.is_build = is_build
def get_platforms(self): if self.platform == Platform.ALL_PLATFORMS: @@ -81,15 +59,78 @@ class Issue: platforms.append("Android") return " + ".join(platforms)
- def __str__(self): - return f"Bug {self.number}: {self.title} [{self.project}]" - def __lt__(self, other): + if self.type != other.type: + return self.type < other.type + if self.type == EntryType.UPDATE: + # Rely on sorting being stable on Python + return False if self.project == other.project: return self.number < other.number return project_order[self.project] < project_order[other.project]
+class UpdateEntry(ChangelogEntry): + def __init__(self, name, version): + if name == "Firefox" and not is_mb: + platform = Platform.DESKTOP + num_platforms = 3 + elif name == "GeckoView": + platform = Platform.ANDROID + num_platforms = 3 + else: + platform = Platform.ALL_PLATFORMS + num_platforms = 4 + super().__init__( + EntryType.UPDATE, platform, num_platforms, name == "Go" + ) + self.name = name + self.version = version + + def __str__(self): + return f"Updated {self.name} to {self.version}" + + +class Issue(ChangelogEntry): + def __init__(self, j): + self.title = j["title"] + self.project, self.number = ( + j["references"]["full"].rsplit("/", 2)[-1].split("#") + ) + self.number = int(self.number) + platform = 0 + num_platforms = 0 + if "Desktop" in j["labels"]: + platform = Platform.DESKTOP + num_platforms += 3 + else: + if "Windows" in j["labels"]: + platform |= Platform.WINDOWS + num_platforms += 1 + if "MacOS" in j["labels"]: + platform |= Platform.MACOS + num_platforms += 1 + if "Linux" in j["labels"]: + platform |= Platform.LINUX + num_platforms += 1 + if "Android" in j["labels"]: + if is_mb and num_platforms == 0: + raise Exception( + f"Android-only issue on Mullvad Browser: {j['references']['full']}!" + ) + elif not is_mb: + platform |= Platform.ANDROID + num_platforms += 1 + if not platform or (is_mb and platform == Platform.DESKTOP): + platform = Platform.ALL_PLATFORMS + num_platforms = 4 + is_build = "Build System" in j["labels"] + super().__init__(EntryType.ISSUE, platform, num_platforms, is_build) + + def __str__(self): + return f"Bug {self.number}: {self.title} [{self.project}]" + + def sorted_issues(issues): issues = [sorted(v) for v in issues.values()] return sorted( @@ -99,8 +140,20 @@ def sorted_issues(issues): )
-if len(sys.argv) < 2: - print(f"Usage: {sys.argv[0]} version-to-release or #issue-id") +parser = argparse.ArgumentParser() +parser.add_argument("issue_version") +parser.add_argument("--date", help="The date of the release") +parser.add_argument("--firefox", help="New Firefox version (if we rebased)") +parser.add_argument("--tor", help="New Tor version (if updated)") +parser.add_argument("--no-script", help="New NoScript version (if updated)") +parser.add_argument("--openssl", help="New OpenSSL version (if updated)") +parser.add_argument("--ublock", help="New uBlock version (if updated)") +parser.add_argument("--zlib", help="New zlib version (if updated)") +parser.add_argument("--go", help="New Go version (if updated)") +args = parser.parse_args() + +if not args.issue_version: + parser.print_help() sys.exit(1)
token_file = Path(__file__).parent / ".changelogs_token" @@ -121,7 +174,7 @@ with token_file.open() as f: token = f.read().strip() headers = {"PRIVATE-TOKEN": token}
-version = sys.argv[1] +version = args.issue_version r = requests.get( f"{API_URL}/projects/{PROJECT_ID}/issues?labels=Release Prep", headers=headers, @@ -132,7 +185,7 @@ if r.status_code == 401: issue = None issues = [] for i in r.json(): - if i["title"].find(sys.argv[1]) != -1: + if i["title"].find(version) != -1: issues.append(i) if len(issues) == 1: issue = issues[0] @@ -172,20 +225,44 @@ iid = issue["iid"]
linked = {} linked_build = {} + + +def add_entry(entry): + target = linked_build if entry.is_build else linked + if entry.platform not in target: + target[entry.platform] = [] + target[entry.platform].append(entry) + + +if args.firefox: + add_entry(UpdateEntry("Firefox", args.firefox)) + if not is_mb: + add_entry(UpdateEntry("GeckoView", args.firefox)) +if args.tor and not is_mb: + add_entry(UpdateEntry("Tor", args.tor)) +if args.no_script: + add_entry(UpdateEntry("NoScript", args.no_script)) +if not is_mb: + if args.openssl: + add_entry(UpdateEntry("OpenSSL", args.openssl)) + if args.zlib: + add_entry(UpdateEntry("zlib", args.zlib)) + if args.go: + add_entry(UpdateEntry("Go", args.go)) +elif args.ublock: + add_entry(UpdateEntry("uBlock Origin", args.ublock)) + r = requests.get( f"{API_URL}/projects/{PROJECT_ID}/issues/{iid}/links", headers=headers ) for i in r.json(): - i = Issue(i) - target = linked_build if i.is_build else linked - if i.platform not in target: - target[i.platform] = [] - target[i.platform].append(i) + add_entry(Issue(i)) + linked = sorted_issues(linked) linked_build = sorted_issues(linked_build)
name = "Mullvad" if is_mb else "Tor" -date = datetime.now().strftime("%B %d %Y") +date = args.date if args.date else datetime.now().strftime("%B %d %Y") print(f"{name} Browser {version} - {date}") for issues in linked: print(f" * {issues[0].get_platforms()}")
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/2f...
tbb-commits@lists.torproject.org