From aa123668c4f6db3c14bdc47b62956ee42b1aeb17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20H=C3=A9rilier?= Date: Sun, 22 Sep 2024 15:34:41 +0200 Subject: [PATCH 1/3] tools: factorize information extraction from release version strings --- tools/sanity_checks.py | 4 ++-- tools/utils.py | 3 +++ tools/versions.py | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/sanity_checks.py b/tools/sanity_checks.py index f3376e851..b1d284a49 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,7 +255,7 @@ def test_releases(self): # a corresponding tag already. for i, v in enumerate(versions): t = f'{name}_{v}' - ver, rev = v.rsplit('-', 1) + ver, rev = split_version_revision(v) with self.subTest(step='valid release name'): self.assertTrue(re.fullmatch('[a-z0-9._]+', ver)) self.assertTrue(re.fullmatch('[0-9]+', rev)) 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}' ) From 3c6c531dbaada745e6d8658997fa11375f7eedbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20H=C3=A9rilier?= Date: Sun, 22 Sep 2024 15:36:31 +0200 Subject: [PATCH 2/3] tools: rename test name which has nothing to do with the release name --- tools/sanity_checks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/sanity_checks.py b/tools/sanity_checks.py index b1d284a49..4685bc857 100755 --- a/tools/sanity_checks.py +++ b/tools/sanity_checks.py @@ -256,7 +256,7 @@ def test_releases(self): for i, v in enumerate(versions): t = f'{name}_{v}' ver, rev = split_version_revision(v) - with self.subTest(step='valid release name'): + with self.subTest(step='valid release version'): self.assertTrue(re.fullmatch('[a-z0-9._]+', ver)) self.assertTrue(re.fullmatch('[0-9]+', rev)) if i == 0: From 56fbd77415362af995aafc6a7616432c81ece9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20H=C3=A9rilier?= Date: Sun, 22 Sep 2024 17:42:00 +0200 Subject: [PATCH 3/3] sanity_checks: fix validity check of upstream versions upstream versions with underscores break the way wrap files are handled: this character is the delimiter used to extract the wrap's name and version from different sources: * `meson wrap` when retrieving patch files; * sanity_checks.py when retrieving git tags. --- tools/sanity_checks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/sanity_checks.py b/tools/sanity_checks.py index 4685bc857..42e6da85b 100755 --- a/tools/sanity_checks.py +++ b/tools/sanity_checks.py @@ -257,7 +257,7 @@ def test_releases(self): t = f'{name}_{v}' ver, rev = split_version_revision(v) with self.subTest(step='valid release version'): - self.assertTrue(re.fullmatch('[a-z0-9._]+', ver)) + self.assertTrue(re.fullmatch('[^_]+', ver)) self.assertTrue(re.fullmatch('[0-9]+', rev)) if i == 0: with self.subTest(step='check_source_url'):