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 os
import subprocess import subprocess
import sys import sys
from datetime import datetime, timezone from datetime import datetime
from pathlib import Path from pathlib import Path
import frontmatter import frontmatter
@@ -60,9 +60,8 @@ def markdown_to_wikitext(body: str) -> str:
return result.stdout return result.stdout
def build_wikitext(fm: dict, body_wikitext: str, source_url: str) -> str: def build_wikitext(fm: dict, body_wikitext: str, source_url: str, source_ref: str) -> str:
now = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") banner = f"{{{{Auto-generated|source={source_url}|commit={source_ref}}}}}"
banner = f"{{{{Auto-generated|source={source_url}|generated_at={now}}}}}"
category = f"[[Category:{fm['album']}]]" category = f"[[Category:{fm['album']}]]"
return f"{banner}\n\n{body_wikitext}\n{category}\n" 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)) body_wikitext = markdown_to_wikitext(strip_first_h1(post.content))
source_url = f"{gitea_repo_url}/src/commit/{source_ref}/{rel}" 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"]] page = site.pages[fm["title"]]
if page.text() == page_content: if page.text() == page_content: