render: replace generated_at timestamp with commit SHA in banner

Timestamps made the idempotency check always false — every run would
rewrite every page. Commit SHA is stable: same source commit produces
identical wikitext, so unchanged pages are correctly skipped.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-09 18:01:46 +09:00
parent 58507edfd5
commit df7195511f
+4 -5
View File
@@ -5,7 +5,7 @@ import argparse
import os
import subprocess
import sys
from datetime import datetime, timezone
from datetime import datetime
from pathlib import Path
import frontmatter
@@ -60,9 +60,8 @@ def markdown_to_wikitext(body: str) -> str:
return result.stdout
def build_wikitext(fm: dict, body_wikitext: str, source_url: str) -> str:
now = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
banner = f"{{{{Auto-generated|source={source_url}|generated_at={now}}}}}"
def build_wikitext(fm: dict, body_wikitext: str, source_url: str, source_ref: str) -> str:
banner = f"{{{{Auto-generated|source={source_url}|commit={source_ref}}}}}"
category = f"[[Category:{fm['album']}]]"
return f"{banner}\n\n{body_wikitext}\n{category}\n"
@@ -89,7 +88,7 @@ def publish_one(rel: Path, post, site: mwclient.Site, source_ref: str, gitea_rep
body_wikitext = markdown_to_wikitext(strip_first_h1(post.content))
source_url = f"{gitea_repo_url}/src/commit/{source_ref}/{rel}"
page_content = build_wikitext(fm, body_wikitext, source_url)
page_content = build_wikitext(fm, body_wikitext, source_url, source_ref)
page = site.pages[fm["title"]]
if page.text() == page_content: