Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions agents/tests/unit/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 2 additions & 6 deletions agents/tools/specfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))):
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down