summaryrefslogtreecommitdiffstats
path: root/g2h
diff options
context:
space:
mode:
authorChristoph Schlosser <christoph@linux.com>2025-08-24 18:58:26 +0200
committerChristoph Schlosser <christoph@linux.com>2025-08-24 18:58:26 +0200
commitbfb9afa2a57c3c302dde2c9669425d365c3f9b40 (patch)
treeb0f3f327becfd078b16ff777cde3b1ba93885954 /g2h
parent3d06cd01a52382982964a2c40036ca1dabb76501 (diff)
downloadgit2hugo-bfb9afa2a57c3c302dde2c9669425d365c3f9b40.tar.gz
g2h: Add redacted authors email to commit page
Diffstat (limited to 'g2h')
-rw-r--r--g2h/commit_page.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/g2h/commit_page.py b/g2h/commit_page.py
index 716a4f8..7123c82 100644
--- a/g2h/commit_page.py
+++ b/g2h/commit_page.py
@@ -2,6 +2,19 @@ import os
from .page import Page
+def redact_email(email):
+ if email is None or len(email) == 0:
+ return ''
+
+ if '@' not in email:
+ return email[0] + '...' + email[-1]
+
+ local, domain = email.split('@')
+ redacted_local = local[0] + '...' + local[-1] if len(local) > 0 else ''
+ redacted_domain = domain.replace('.', '...')
+
+ return redacted_local + '@' + redacted_domain
+
class CommitPage(Page):
def __init__(self, out_dir, name, commit, content_subdir):
super(CommitPage, self).__init__('commit.md', out_dir, os.path.join(commit.hexsha, 'index.md'), name, content_subdir)
@@ -10,5 +23,6 @@ class CommitPage(Page):
def context(self):
return {
'commit': self.commit,
- 'title': self.name + ': ' + self.commit.hexsha
+ 'title': self.name + ': ' + self.commit.hexsha,
+ 'redacted_email': redact_email(self.commit.author.email)
}