# gitea-client — Repository operations

load("star/http_helpers.star", "gitea_get")

def get_repos(conn):
    """List repositories accessible via the connection."""
    data = gitea_get(conn, "/repos/search?limit=50&sort=updated")
    if data == None:
        return None
    repos = data if type(data) == "list" else data.get("data", [])
    out = []
    for r in repos:
        out.append({
            "full_name":   r.get("full_name", ""),
            "name":        r.get("name", ""),
            "owner":       r.get("owner", {}).get("login", ""),
            "description": r.get("description", ""),
            "html_url":    r.get("html_url", ""),
            "open_issues": r.get("open_issues_count", 0),
        })
    return out
