Files
govoplan/tools/repo/generate-repository-index.py
Albrecht Degering 05ae81d641
Some checks failed
Dependency Audit / dependency-audit (push) Failing after 16s
Security Audit / security-audit (push) Failing after 11s
intermediate commit
2026-07-14 13:32:09 +02:00

49 lines
1.6 KiB
Python

#!/usr/bin/env python3
from __future__ import annotations
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
CATEGORIES = ("system", "module", "connector", "website")
def main() -> int:
manifest = json.loads((ROOT / "repositories.json").read_text(encoding="utf-8"))
lines = [
"# GovOPlaN Repository Index",
"",
"Generated from `repositories.json`. Use that JSON file as the machine-readable source of truth; this page is the human-readable link index.",
"",
]
for category in CATEGORIES:
entries = [entry for entry in manifest["repositories"] if entry["category"] == category]
if not entries:
continue
lines.extend([
f"## {category.title()}",
"",
"| Repository | Subtype | Local path | Gitea |",
"| --- | --- | --- | --- |",
])
for entry in entries:
name = entry["name"]
subtype = entry.get("subtype", "")
path = entry["path"]
url = gitea_url(entry["remote"])
lines.append(f"| `{name}` | `{subtype}` | `../{path}` | [{name}]({url}) |")
lines.append("")
(ROOT / "docs" / "REPOSITORY_INDEX.md").write_text("\n".join(lines).rstrip() + "\n", encoding="utf-8")
return 0
def gitea_url(remote: str) -> str:
if remote.startswith("git@git.add-ideas.de:"):
return remote.replace("git@git.add-ideas.de:", "https://git.add-ideas.de/", 1).removesuffix(".git")
return remote
if __name__ == "__main__":
raise SystemExit(main())