From b06dbf67b9ac9e329922d7911ee7a9b09419c5f0 Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Sat, 30 Aug 2025 19:36:51 +0200 Subject: g2h: Link to tree from commit page --- README.md | 2 +- g2h/commit_page.py | 3 ++- templates/commit.md | 1 + test_repo/git.tgz | Bin 22304 -> 22304 bytes tests/commit_test.py | 3 ++- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 380ab80..cb09b0d 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ For a full list of options, their defaults and how they're changing the behavior - [ ] Add links to parent(s). - [ ] Add links to child(ren). - [ ] Show diffstat on commit page. - - [ ] Add button to browse tree. + - [x] Add button to browse tree. - [ ] Add button to download tree tarball. - [x] Tree view. Show the state of the tree at the current commit. diff --git a/g2h/commit_page.py b/g2h/commit_page.py index 7123c82..6111013 100644 --- a/g2h/commit_page.py +++ b/g2h/commit_page.py @@ -24,5 +24,6 @@ class CommitPage(Page): return { 'commit': self.commit, 'title': self.name + ': ' + self.commit.hexsha, - 'redacted_email': redact_email(self.commit.author.email) + 'redacted_email': redact_email(self.commit.author.email), + 'content_subdir': self.content_subdir } diff --git a/templates/commit.md b/templates/commit.md index 4ea5594..8648760 100644 --- a/templates/commit.md +++ b/templates/commit.md @@ -3,6 +3,7 @@ **Commit**: {{ commit.hexsha }} **Author**: {{ commit.author }} <{{ redacted_email }}> **Date**: {{ commit.committed_datetime.strftime('%Y-%m-%d %H:%M:%S') }} +**Tree**: [Browse](/{{ content_subdir }}/{{ commit.hexsha }}/t) ``` {{ commit.message }} diff --git a/test_repo/git.tgz b/test_repo/git.tgz index f15b42a..df8887e 100644 Binary files a/test_repo/git.tgz and b/test_repo/git.tgz differ diff --git a/tests/commit_test.py b/tests/commit_test.py index 3a9871a..b32901e 100644 --- a/tests/commit_test.py +++ b/tests/commit_test.py @@ -13,11 +13,12 @@ def test_context(): commit = MagicMock() commit.hexsha = '123' commit.author.email = 'unit@te.st' - page = CommitPage('test/commit', 'commit test', commit, '') + page = CommitPage('test/commit', 'commit test', commit, 'commit/content') context = page.context() assert(context['title'] == 'commit test: 123') assert(context['commit'] == commit) assert(context['redacted_email'] == 'u...t@te...st') + assert(context['content_subdir'] == 'commit/content') def test_redacting_email(): assert(redact_email(None) == '') -- cgit v1.2.3