From 2a592ecd951f758a62b1c4907e5da212cf1ba264 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Thu, 18 Sep 2025 22:38:36 +0200 Subject: g2h: Set `date` frontmatter in overview page to HEAD commit --- g2h/cli.py | 2 +- g2h/git.py | 3 +++ g2h/overview_page.py | 4 +++- g2h/page_factory.py | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) (limited to 'g2h') diff --git a/g2h/cli.py b/g2h/cli.py index fbc456e..6ffabb0 100644 --- a/g2h/cli.py +++ b/g2h/cli.py @@ -27,7 +27,7 @@ def main(): tags = sorted(git.get_tags(), key=lambda t: t.commit.committed_date, reverse=True) factory = PageFactory(args.out_dir, project_name, args.content_subdir) - factory.new_overview(branches, tags).render() + factory.new_overview(branches, tags, git.get_head()).render() factory.new_log(commits, branches, tags).render() for commit in commits: factory.new_commit(commit).render() diff --git a/g2h/git.py b/g2h/git.py index 1e835e7..283135c 100644 --- a/g2h/git.py +++ b/g2h/git.py @@ -13,6 +13,9 @@ class Git: def get_commits(self): return list(self.repo.iter_commits()) + def get_head(self): + return self.repo.head.commit + def get_repo(self): return self.repo diff --git a/g2h/overview_page.py b/g2h/overview_page.py index 76de8cc..0363494 100644 --- a/g2h/overview_page.py +++ b/g2h/overview_page.py @@ -1,15 +1,17 @@ from .page import Page class OverviewPage(Page): - def __init__(self, out_dir, name, branches, tags, content_subdir): + def __init__(self, out_dir, name, branches, tags, content_subdir, latest_commit): super(OverviewPage, self).__init__('overview.md', out_dir, '_index.md', name, content_subdir) self.branches = branches self.tags = tags + self.latest_commit = latest_commit def context(self): return { 'branches': self.branches, 'content_subdir': self.content_subdir, + 'latest_commit_date': self.latest_commit.committed_datetime, 'tags': self.tags, 'title': self.name } diff --git a/g2h/page_factory.py b/g2h/page_factory.py index da9c5d5..82e2b0f 100644 --- a/g2h/page_factory.py +++ b/g2h/page_factory.py @@ -20,8 +20,8 @@ class PageFactory: dir = os.path.dirname(path) return FilePage(self.out_dir, self.name, commit, filename, dir, self.content_subdir) - def new_overview(self, branches, tags): - return OverviewPage(self.out_dir, self.name, branches, tags, self.content_subdir) + def new_overview(self, branches, tags, head): + return OverviewPage(self.out_dir, self.name, branches, tags, self.content_subdir, head) def new_log(self, commits, branches, tags): return LogPage(self.out_dir, self.name, commits, branches, tags, self.content_subdir) -- cgit v1.2.3