diff --git a/agents/tests/unit/test_tools.py b/agents/tests/unit/test_tools.py index 0f94408f..bc69c961 100644 --- a/agents/tests/unit/test_tools.py +++ b/agents/tests/unit/test_tools.py @@ -267,6 +267,22 @@ async def run_and_check(spec, expected_release, error=False): await run_and_check(minimal_spec, "1%{?dist}" if rebase else "3%{?dist}") await run_and_check(autorelease_spec, "%autorelease") + with specfile.Specfile(minimal_spec) as spec: + spec.raw_release = "5%{?alphatag:.%{alphatag}}%{?dist}.8" + + if not dist_git_branch.startswith("rhel-"): + await run_and_check( + minimal_spec, + ( + "1%{?alphatag:.%{alphatag}}%{?dist}" + if rebase + else "6%{?alphatag:.%{alphatag}}%{?dist}" + ), + ) + else: + await run_and_check(minimal_spec, "0%{?dist}.1" if rebase else "5%{?alphatag:.%{alphatag}}%{?dist}.9") + await run_and_check(minimal_spec, "0%{?dist}.1" if rebase else "5%{?alphatag:.%{alphatag}}%{?dist}.10") + @pytest.mark.asyncio async def test_get_cwd(tmp_path): diff --git a/agents/tools/specfile.py b/agents/tools/specfile.py index 09ecb75b..6097a538 100644 --- a/agents/tools/specfile.py +++ b/agents/tools/specfile.py @@ -164,10 +164,6 @@ async def _get_latest_higher_stream_build(package: str, candidate_tag: str) -> E [build] = builds return EVR(epoch=build["epoch"] or 0, version=build["version"], release=build["release"]) - @staticmethod - def _parse_release(release: str) -> list[Node]: - return list(ValueParser.flatten(ValueParser.parse(release))) - @staticmethod def _find_macro(name: str, nodes: list[Node]) -> int | None: for index, node in reversed(list(enumerate(nodes))): @@ -182,7 +178,7 @@ def _find_macro(name: str, nodes: list[Node]) -> int | None: async def _bump_or_reset_release(cls, spec_path: Path, rebase: bool) -> None: with Specfile(spec_path) as spec: current_release = spec.raw_release - nodes = cls._parse_release(current_release) + nodes = ValueParser.parse(current_release) autorelease_index = cls._find_macro("autorelease", nodes) dist_index = cls._find_macro("dist", nodes) @@ -220,7 +216,7 @@ async def _set_zstream_release( higher_stream_base_release, _ = latest_higher_stream_build.release.rsplit(".el", maxsplit=1) with Specfile(spec_path) as spec: current_release = spec.raw_release - nodes = cls._parse_release(current_release) + nodes = ValueParser.parse(current_release) autorelease_index = cls._find_macro("autorelease", nodes) dist_index = cls._find_macro("dist", nodes)