🚧 Add file time information in commit message
This commit is contained in:
@@ -19,21 +19,30 @@ _SUMMARY_LABELS = (
|
||||
|
||||
|
||||
def _format_ts(moment: dt.datetime | None) -> str:
|
||||
"""Render an aware datetime in local time with an explicit offset.
|
||||
|
||||
Local wall-clock time plus the UTC offset, e.g. 2026-09-12 08:00:00+02:00
|
||||
(matching the log timestamp style in logging/setup.py, which also uses
|
||||
local time rather than UTC).
|
||||
"""
|
||||
if moment is None:
|
||||
return ""
|
||||
return moment.strftime("%Y-%m-%d %H:%M:%S%z")
|
||||
return moment.astimezone().isoformat(sep=" ", timespec="seconds")
|
||||
|
||||
|
||||
def _author_lines(record) -> list[str]: # noqa: ANN001 - ChangeRecord, avoid cycle
|
||||
lines: list[str] = []
|
||||
author = record.author
|
||||
if author is not None:
|
||||
lines.append(f" Last modified by: {author.identifier}")
|
||||
ts = _format_ts(author.timestamp)
|
||||
if ts:
|
||||
lines.append(f" Modified at: {ts}")
|
||||
else:
|
||||
lines.append(" Last modified by: UNKNOWN")
|
||||
identifier = author.identifier if author is not None else "UNKNOWN"
|
||||
lines.append(f" Last modified by: {identifier}")
|
||||
# Filesystem last-modified time (Section 12: file_timestamp); rendered
|
||||
# in local time like the log timestamps. Resolver-provided timestamps
|
||||
# (author.timestamp) stay authoritative and are shown as well.
|
||||
file_ts = _format_ts(record.file_timestamp)
|
||||
if file_ts:
|
||||
lines.append(f" Modified at: {file_ts}")
|
||||
if author is not None and author.timestamp is not None:
|
||||
lines.append(f" Changed at: {_format_ts(author.timestamp)}")
|
||||
return lines
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user