diff --git a/tools/sanity_checks.py b/tools/sanity_checks.py index f3376e851..42e6da85b 100755 --- a/tools/sanity_checks.py +++ b/tools/sanity_checks.py @@ -27,7 +27,7 @@ import sys from pathlib import Path -from utils import Version, ci_group, is_ci, is_alpinelike, is_debianlike, is_linux, is_macos, is_windows, is_msys +from utils import Version, ci_group, is_ci, is_alpinelike, is_debianlike, is_linux, is_macos, is_windows, is_msys, split_version_revision PERMITTED_FILES = ['generator.sh', 'meson.build', 'meson_options.txt', 'meson.options', 'LICENSE.build'] PER_PROJECT_PERMITTED_FILES = { @@ -255,9 +255,9 @@ def test_releases(self): # a corresponding tag already. for i, v in enumerate(versions): t = f'{name}_{v}' - ver, rev = v.rsplit('-', 1) - with self.subTest(step='valid release name'): - self.assertTrue(re.fullmatch('[a-z0-9._]+', ver)) + ver, rev = split_version_revision(v) + with self.subTest(step='valid release version'): + self.assertTrue(re.fullmatch('[^_]+', ver)) self.assertTrue(re.fullmatch('[0-9]+', rev)) if i == 0: with self.subTest(step='check_source_url'): diff --git a/tools/utils.py b/tools/utils.py index 597d4e499..ef6316acb 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -128,3 +128,6 @@ def is_msys() -> bool: def is_macos(): return any(platform.mac_ver()[0]) + +def split_version_revision(version: str) -> T.Tuple[str, str]: + return version.rsplit('-', 1) diff --git a/tools/versions.py b/tools/versions.py index 69bbc5794..78c00f643 100755 --- a/tools/versions.py +++ b/tools/versions.py @@ -26,6 +26,7 @@ import sys import time from typing import TypedDict +from utils import split_version_revision import requests @@ -113,7 +114,7 @@ def get_releases() -> dict[str, WrapInfo]: def get_wrap_versions() -> dict[str, str]: '''Return a dict: wrap_name -> wrapdb_version.''' return { - name: info['versions'][0].split('-')[0] + name: split_version_revision(info['versions'][0])[0] for name, info in get_releases().items() if name not in DEPRECATED_WRAPS } @@ -219,7 +220,7 @@ def do_autoupdate(args: Namespace) -> None: # only allow for ports, since official wraps can't have # downstream changes print(f'Updating {name} revision...') - cur_rev = int(releases[name]['versions'][0].split('-')[1]) + cur_rev = int(split_version_revision(releases[name]['versions'][0])[1]) releases[name]['versions'].insert( 0, f'{cur_vers[name]}-{cur_rev + 1}' )