🚧 Add file time information in commit message
This commit is contained in:
@@ -102,6 +102,22 @@ class TestRunCycle:
|
||||
body = _git_out("log", "-1", "--format=%b", cwd=git_repo)
|
||||
assert "Last modified by: DOMAIN\\jsmith" in body
|
||||
|
||||
def test_file_mtime_appears_in_commit_local_time(
|
||||
self, git_repo: Path, tracker_config: dict, tmp_path: Path
|
||||
) -> None:
|
||||
"""Section 12 file_timestamp rendered as 'Modified at' (local time)."""
|
||||
import re as re_mod
|
||||
|
||||
(git_repo / "config.xml").write_text("<c/>", encoding="utf-8")
|
||||
_run(tracker_config, tmp_path)
|
||||
body = _git_out("log", "-1", "--format=%b", cwd=git_repo)
|
||||
# Local-time format with explicit +/-HH:MM offset (Section 15)
|
||||
assert re_mod.search(
|
||||
r"Modified at: \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}\b", body
|
||||
)
|
||||
# The timestamp block sits directly under the changed file entry
|
||||
assert " config.xml\n Last modified by: UNKNOWN\n Modified at:" in body
|
||||
|
||||
def test_excluded_files_not_committed(
|
||||
self, git_repo: Path, tracker_config: dict, tmp_path: Path
|
||||
) -> None:
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime as dt
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
@@ -152,6 +153,7 @@ class TestCommitMessage:
|
||||
ChangeRecord(
|
||||
path="Stations/PS101/project.xml",
|
||||
change_type=ChangeType.MODIFIED,
|
||||
file_timestamp=dt.datetime(2026, 9, 11, 6, 42, 9, tzinfo=dt.UTC),
|
||||
author=AuthorIdentity(
|
||||
identifier="DOMAIN\\jsmith",
|
||||
source="scada_audit_log",
|
||||
@@ -175,6 +177,13 @@ class TestCommitMessage:
|
||||
assert "Added: 1" in message
|
||||
assert "Last modified by: DOMAIN\\jsmith" in message
|
||||
assert "Last modified by: UNKNOWN" in message
|
||||
# Filesystem mtime rendered as 'Modified at' in local time with offset
|
||||
assert " Modified at: " in message
|
||||
assert re.search(
|
||||
r"Modified at: \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}\b", message
|
||||
)
|
||||
# Resolver-provided timestamp kept as a separate 'Changed at' line
|
||||
assert " Changed at: " in message
|
||||
assert "Stations/PS027/old.xml" in message
|
||||
# Trailers last (Section 36)
|
||||
assert "Tracker-Version: 1.0.0" in message
|
||||
|
||||
Reference in New Issue
Block a user