From 9bc2d82b55549f0786f729fdc080335d8aa4a8a8 Mon Sep 17 00:00:00 2001 From: Michael Weiss Date: Tue, 3 Aug 2021 13:20:15 +0200 Subject: [PATCH] chromium: get-commit-message.py: Support specifying a version This makes the usage from update.py more robust. It also adds a workaround for [0] which currently lacks a title. [0]: https://chromereleases.googleblog.com/2021/08/the-stable-channel-has-been-updated-to.html --- .../browsers/chromium/get-commit-message.py | 25 +++++++++++++++---- .../networking/browsers/chromium/update.py | 10 ++------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/pkgs/applications/networking/browsers/chromium/get-commit-message.py b/pkgs/applications/networking/browsers/chromium/get-commit-message.py index 7a91b74c83d5..b0fbe20db8ef 100755 --- a/pkgs/applications/networking/browsers/chromium/get-commit-message.py +++ b/pkgs/applications/networking/browsers/chromium/get-commit-message.py @@ -2,8 +2,10 @@ #!nix-shell -i python3 -p python3Packages.feedparser python3Packages.requests # This script prints the Git commit message for stable channel updates. +# Usage: ./get-commit-message.py [version] import re +import sys import textwrap from collections import OrderedDict @@ -13,19 +15,29 @@ import requests feed = feedparser.parse('https://chromereleases.googleblog.com/feeds/posts/default') html_tags = re.compile(r'<[^>]+>') +target_version = sys.argv[1] if len(sys.argv) == 2 else None for entry in feed.entries: - if entry.title != 'Stable Channel Update for Desktop': - continue url = requests.get(entry.link).url.split('?')[0] + if entry.title != 'Stable Channel Update for Desktop': + if target_version and entry.title == '': + # Workaround for a special case (Chrome Releases bug?): + if not 'the-stable-channel-has-been-updated-to' in url: + continue + else: + continue content = entry.content[0].value content = html_tags.sub('', content) # Remove any HTML tags if re.search(r'Linux', content) is None: continue #print(url) # For debugging purposes version = re.search(r'\d+(\.\d+){3}', content).group(0) - print('chromium: TODO -> ' + version) - print('\n' + url) + if target_version: + if version != target_version: + continue + else: + print('chromium: TODO -> ' + version + '\n') + print(url) if fixes := re.search(r'This update includes .+ security fixes\.', content).group(0): zero_days = re.search(r'Google is aware( of reports)? that .+ in the wild\.', content) if zero_days: @@ -35,4 +47,7 @@ for entry in feed.entries: cve_list = list(OrderedDict.fromkeys(cve_list)) # Remove duplicates but preserve the order cve_string = ' '.join(cve_list) print("\nCVEs:\n" + '\n'.join(textwrap.wrap(cve_string, width=72))) - break # We only care about the most recent stable channel update + sys.exit(0) # We only care about the most recent stable channel update + +print("Error: No match.") +sys.exit(1) diff --git a/pkgs/applications/networking/browsers/chromium/update.py b/pkgs/applications/networking/browsers/chromium/update.py index 4f9f53bd02ac..72d6df055b38 100755 --- a/pkgs/applications/networking/browsers/chromium/update.py +++ b/pkgs/applications/networking/browsers/chromium/update.py @@ -222,14 +222,8 @@ if len(sys.argv) == 2 and sys.argv[1] == '--commit': attr_name = channel_name_to_attr_name(channel_name) commit_message = f'{attr_name}: {version_old} -> {version_new}' if channel_name == 'stable': - body = subprocess.check_output([COMMIT_MESSAGE_SCRIPT]).decode('utf-8') - prefix = f'chromium: TODO -> {version_new}' - if not body.startswith(prefix): - print("Error: Couldn't fetch the the release notes for the following update:") - print(commit_message) - sys.exit(1) - body = body.removeprefix(prefix) - commit_message += body + body = subprocess.check_output([COMMIT_MESSAGE_SCRIPT, version_new]).decode('utf-8') + commit_message += '\n\n' + body subprocess.run(['git', 'add', JSON_PATH], check=True) subprocess.run(['git', 'commit', '--file=-'], input=commit_message.encode(), check=True) else: