summaryrefslogtreecommitdiffstats
path: root/g2h/gen.py
diff options
context:
space:
mode:
authorChristoph Schlosser <christoph@linux.com>2025-08-24 14:08:47 +0200
committerChristoph Schlosser <christoph@linux.com>2025-08-24 14:08:47 +0200
commit49fb19170a74accf51aa13ef0600a0d15f707737 (patch)
treea0a66e919e031638129ab9b128eb74c12e376fe7 /g2h/gen.py
parent782a350e1f56292176ac8471195c889e47b2b841 (diff)
downloadgit2hugo-49fb19170a74accf51aa13ef0600a0d15f707737.tar.gz
g2h: Add log page
Diffstat (limited to 'g2h/gen.py')
-rw-r--r--g2h/gen.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/g2h/gen.py b/g2h/gen.py
index 02162e8..91fab82 100644
--- a/g2h/gen.py
+++ b/g2h/gen.py
@@ -1,6 +1,14 @@
from jinja2 import Environment, FileSystemLoader
import os
+def ref_names_for_commit(refs, commit_sha):
+ ref_names = []
+ for ref in refs:
+ if ref.commit.hexsha == commit_sha:
+ ref_names.append(ref.name)
+
+ return ref_names
+
class Generator:
def __init__(self, output_dir):
self.output_dir = output_dir
@@ -15,6 +23,23 @@ class Generator:
with open(out_file, 'w', encoding='utf-8') as f:
f.write(content)
+ def render_log(self, name, commits, branches, tags):
+ commits_context = []
+ for commit in commits:
+ refs = ref_names_for_commit(branches, commit.hexsha) + ref_names_for_commit(tags, commit.hexsha)
+ commit_context = {
+ 'committed_datetime': commit.committed_datetime,
+ 'refs': refs,
+ 'summary': commit.summary
+ }
+ commits_context.append(commit_context)
+
+ context = {
+ 'commits': commits_context,
+ 'title': name
+ }
+ self._render('log.md', context, 'l.md')
+
def render_overview(self, name, branches, tags):
context = {
'branches': branches,