Skip to content

Commit

Permalink
Support rc version CMKVersion of testlib
Browse files Browse the repository at this point in the history
CMK-19234

Change-Id: If6140821a22b9627ebfeb296efa4199fb597cb75
  • Loading branch information
JonasScharpf committed Oct 23, 2024
1 parent b2ea620 commit 3649c1c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/testlib/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import logging
import operator
import os
import re
import subprocess
import time
from collections.abc import Callable
Expand Down Expand Up @@ -156,12 +157,19 @@ def _sanitize_version_spec(version: str) -> tuple[Version, time.struct_time | No
Uses `packaging.version.Version` to wrap Checkmk version.
"""
_timestamp = None

# ignore release candidate
_version = re.sub(r"-rc(\d+)", "", version)

# treat `patch-version` as `micro-version`.
_version = version.replace("0p", "")
_version = _version.replace("0p", "")

# detect daily builds
if "-" in version:
_timestamp = time.strptime(version.split("-")[-1], CMKVersion.TIMESTAMP_FORMAT)
_version = version.split("-")[0]
if match := re.search(
r"([1-9]?\d\.[1-9]?\d\.[1-9]?\d)-([1-9]\d{3}\.[0-1]\d\.[0-3]\d)", _version
):
_version = match.groups()[0]
_timestamp = time.strptime(match.groups()[1], CMKVersion.TIMESTAMP_FORMAT)
return Version(_version), _timestamp

@staticmethod
Expand Down

0 comments on commit 3649c1c

Please sign in to comment.