Ports dirigent's gitea scripts into a self-contained reliquary plugin. Scripts run via uv with PEP 723 inline deps — no project venv needed. Gitea connection inferred from `git remote get-url origin` with env-var overrides; only GITEA_TOKEN is mandatory. Workpad path and tickets directory are parameterized so the plugin works in any project. Label set externalized to labels.default.json with project-level override via .gitea-labels.json. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
# /// script
|
|
# requires-python = ">=3.11"
|
|
# dependencies = ["httpx", "pydantic>=2", "python-dotenv"]
|
|
# ///
|
|
"""List Gitea issues.
|
|
|
|
Usage:
|
|
uv run list_tickets.py [--state open|closed|all] [--labels "l1,l2"] [--milestone NAME]
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import io
|
|
import sys
|
|
from typing import List, Optional
|
|
|
|
from client import GiteaClient, GiteaError
|
|
from config import load_config
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(description="List Gitea issues.")
|
|
parser.add_argument("--state", type=str, default="open", help="Issue state: open, closed, all (default: open)")
|
|
parser.add_argument("--labels", type=str, default=None, help="Comma-separated label names")
|
|
parser.add_argument("--milestone", type=str, default=None, help="Milestone name")
|
|
args = parser.parse_args()
|
|
|
|
out = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
|
|
label_list: Optional[List[str]] = None
|
|
if args.labels:
|
|
label_list = [l.strip() for l in args.labels.split(",") if l.strip()]
|
|
|
|
config = load_config()
|
|
try:
|
|
with GiteaClient(config) as client:
|
|
issues = client.list_issues(state=args.state, labels=label_list, milestone=args.milestone)
|
|
if not issues:
|
|
out.write(f"No {args.state} issues found.\n")
|
|
else:
|
|
for i in issues:
|
|
labels = f" [{', '.join(i.label_names())}]" if i.labels else ""
|
|
out.write(f"#{i.number}: {i.title}{labels}\n")
|
|
out.flush()
|
|
except GiteaError as e:
|
|
print(f"Error: {e}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|