diff --git a/gitgen.py b/gitgen.py
index abaaa22..9301b8d 100644
--- a/gitgen.py
+++ b/gitgen.py
@@ -268,29 +268,31 @@ class GitRepoScanner:
files = tree.strip().split('\n')
+ # Walk full log newest-to-oldest; first time a filename appears = its most recent commit date
log = self.run_git_command(repo_path, [
- 'log', '-1', '--name-only',
- '--pretty=format:%ad|%an',
- '--date=format:%Y-%m-%d'
+ 'log', '--format=%ad', '--date=format:%Y-%m-%d',
+ '--name-only', '--diff-filter=ACDMRT'
])
- file_meta = {}
+ file_dates: Dict[str, str] = {}
if log:
- lines = log.splitlines()
- if lines:
- meta = lines[0].split('|', 1)
- for f in lines[1:]:
- file_meta[f] = meta
+ current_date = ''
+ for line in log.splitlines():
+ line = line.rstrip()
+ if not line:
+ continue
+ if len(line) == 10 and line[4] == '-' and line[7] == '-':
+ current_date = line
+ elif current_date and line not in file_dates:
+ file_dates[line] = current_date
result = []
for f in files:
- meta = file_meta.get(f, ['', ''])
result.append({
'path': f,
'name': os.path.basename(f),
'directory': os.path.dirname(f) or '.',
- 'last_modified': meta[0],
- 'last_author': meta[1],
+ 'last_modified': file_dates.get(f, ''),
'path_escaped': html.escape(f),
})
@@ -660,14 +662,15 @@ class HTMLGenerator:
for file_info in files_by_dir[directory]:
html_fragments.append(f"""
<div class="file-item">
- <div class="file-info">
- <div class="file-path">
- <span class="file-icon">🗎</span>
- {file_info['name']}
- </div>
- </div>
+ <div class="file-info">
+ <div class="file-path">
+ <span class="file-icon">🗎</span>
+ {html.escape(file_info['name'])}
+ </div>
+ </div>
+ <div class="file-date">{html.escape(file_info['last_modified'])}</div>
</div>
- """)
+ """)
else:
html_fragments.append("""
<div style="padding: 3rem; text-align: center; color: #718096;">
@@ -1129,4 +1132,3 @@ def main():
if __name__ == "__main__":
main()
-