summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Schlosser <christoph@linux.com>2025-08-30 19:36:51 +0200
committerChristoph Schlosser <christoph@linux.com>2025-08-30 19:37:18 +0200
commitb06dbf67b9ac9e329922d7911ee7a9b09419c5f0 (patch)
treebd9ade44dae5a3c838f932d42df9938501251dba
parent9b0ee130c7408e839ceaa0de97a12c9da35e216f (diff)
downloadgit2hugo-b06dbf67b9ac9e329922d7911ee7a9b09419c5f0.tar.gz
g2h: Link to tree from commit page
-rw-r--r--README.md2
-rw-r--r--g2h/commit_page.py3
-rw-r--r--templates/commit.md1
-rw-r--r--test_repo/git.tgzbin22304 -> 22304 bytes
-rw-r--r--tests/commit_test.py3
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
--- a/test_repo/git.tgz
+++ b/test_repo/git.tgz
Binary files 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) == '')