From be5f4cd19ca0b0c2835f47d47764196561a0524a Mon Sep 17 00:00:00 2001 From: dramforever Date: Thu, 27 Nov 2025 15:03:10 +0800 Subject: [PATCH] nix-channels: Tolerate new release taglines The release tagline format changed and now has timezone and Git commit information. Try to be more tolerant to those. Old .released-time files may have already been collected with incorrect data. Handle those as well. See https://github.com/NixOS/nixos-channel-scripts/pull/99 --- nix-channels.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nix-channels.py b/nix-channels.py index fe3aee5..4ce3522 100755 --- a/nix-channels.py +++ b/nix-channels.py @@ -194,7 +194,11 @@ def clone_channels(): tagline = node('p').text() - tagline_res = re.match(r'^Released on (.+) from', tagline) + # Examples: + # + # Released on yyyy-mm-dd hh:mm UTC from Git commit ... + # Released on yyyy-mm-dd hh:mm from ... + tagline_res = re.match(r'^Released on (.+?) (?:UTC )?from', tagline) if tagline_res is None: logging.warning(f' - Invalid tagline: {tagline}') @@ -385,6 +389,9 @@ def garbage_collect(): channel = release.name.split('@')[0] date_str = (release / '.released-time').read_text() + date_match = re.match(r'\d+-\d+-\d+ \d+:\d+', date_str) + assert date_match is not None, f'Release {release!r} has invalid time {date_str!r}' + date_str = date_match[0] released_date = datetime.strptime(date_str, '%Y-%m-%d %H:%M:%S') if released_date >= time_threshold: