Files
workflows-py/src/dev_cli/git_utils.py
T
Adrian Lyjak 5ded4b40fa chore: CI/testing improvements for parallel test execution (#317)
* chore: CI/testing improvements for parallel test execution

- Add workflows-dev pytest command with parallel test runner
- Add pytest-xdist for parallel test execution (-nauto)
- Add timeouts to prevent test hangs (--timeout=10/60/120)
- Use module-scoped async fixtures for faster tests
- Remove mypy in favor of basedpyright/ty type checking
- Add test-docker CI job for integration tests with testcontainers
- Exclude integration tests from Python 3.9/3.14 in CI matrix
2026-02-02 13:27:10 -05:00

47 lines
1.3 KiB
Python

from __future__ import annotations
import subprocess
from pathlib import Path
from typing import Iterable
def list_tags(repo: str | Path, tag_glob: str) -> list[str]:
"""Return tags that match the provided glob sorted newest first."""
repo_path = Path(repo)
result = subprocess.run(
[
"git",
"-C",
str(repo_path),
"tag",
"-l",
tag_glob,
"--sort=-version:refname",
],
capture_output=True,
text=True,
check=True,
)
return [line.strip() for line in result.stdout.splitlines() if line.strip()]
def previous_tag(current_tag: str, tags: Iterable[str]) -> str | None:
"""Return the tag immediately after the current entry in the sorted list."""
tags_list = list(tags)
if current_tag in tags_list:
idx = tags_list.index(current_tag)
if idx + 1 < len(tags_list):
return tags_list[idx + 1]
return None
return tags_list[0] if tags_list else None
def find_previous_tag(repo: str | Path, tag_prefix: str, current_tag: str) -> str:
"""Locate the latest tag that matches a prefix but differs from the current tag."""
matches = list_tags(repo, f"{tag_prefix}*")
for candidate in matches:
if candidate != current_tag:
return candidate
return ""