feat: link each emulator page to its pinned commit

This commit is contained in:
Abdessamad Derraz committed 2026-10-17 15:10:09 +02:00
1 parent 13b7177c88
commit de30a43441
3 files changed
+55

No files matched your search

+4
View File
@@ -2470,6 +2470,9 @@ def generate_emulator_page(
else:
lines.append(f"| Upstream | {upstream} |")
lines.append(f"| Version | {version} |")
revision = revision_markdown(profile)
if revision:
lines.append(f"| Revision | {revision} |")
lines.append(f"| Profiled | {profiled} |")
if cores:
lines.append(f"| Cores | {', '.join(str(c) for c in cores)} |")
@@ -3989,6 +3992,7 @@ from sitewrite import ( # noqa: E402,F401
_sweep_generated,
)
from sitesources import ( # noqa: E402,F401
revision_markdown,
_repo_pins,
_forge_sources,
_source_permalink,
+26
View File
@@ -92,6 +92,32 @@ def _source_permalink(repo: upstream.Repo, pin: str, path: str,
url += f"-L{end}"
return url
def _commit_url(repo: upstream.Repo, pin: str) -> str:
"""Forge-specific browser URL for one commit."""
base = f"https://{repo.host}/{repo.owner}/{repo.name}"
if repo.family == "gitlab":
return f"{base}/-/commit/{pin}"
return f"{base}/commit/{pin}"
def revision_markdown(profile: dict) -> str:
"""Each repository the profile reads, linked at the commit it was read at.
The page linked the repositories unpinned: the revision every citation
refers to sat in the YAML alone, for 178 profiles.
"""
links = [
f"[{repo.slug}@{pin[:12]}]({_commit_url(repo, pin)})"
for repo, pin in _forge_sources(profile)
]
branch = profile.get("source_branch")
if branch and not isinstance(branch, dict):
links.append(f"branch `{branch}`")
elif isinstance(branch, dict):
links += [f"{mode} branch `{name}`" for mode, name in branch.items()]
return ", ".join(links)
def _source_ref_markdown(profile: dict, value) -> str:
"""Render source_ref values as pinned links when their forge is known.