🚧 Update commit message format
This commit is contained in:
@@ -100,23 +100,36 @@ class TestRunCycle:
|
||||
)
|
||||
_run(tracker_config, tmp_path)
|
||||
body = _git_out("log", "-1", "--format=%b", cwd=git_repo)
|
||||
assert "Last modified by: DOMAIN\\jsmith" in body
|
||||
# One-line entry: letter ; path ; author ; local-time mtime
|
||||
assert " A ; config.xml ; 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)."""
|
||||
"""Section 12 file_timestamp on the one-line entry (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)
|
||||
# A ; path ; author ; local-time mtime with +/-HH:MM offset
|
||||
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
|
||||
r"^ A ; config\.xml ; UNKNOWN ; "
|
||||
r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}$",
|
||||
body,
|
||||
flags=re_mod.MULTILINE,
|
||||
)
|
||||
# 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_custom_separator_in_real_commit(
|
||||
self, git_repo: Path, tracker_config: dict, tmp_path: Path
|
||||
) -> None:
|
||||
"""commit.file_separator flows from configuration into the commit."""
|
||||
tracker_config["commit"] = {"file_separator": "|"}
|
||||
(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)
|
||||
assert " A | config.xml | UNKNOWN | " in body
|
||||
assert "; config.xml" not in body
|
||||
|
||||
def test_excluded_files_not_committed(
|
||||
self, git_repo: Path, tracker_config: dict, tmp_path: Path
|
||||
|
||||
@@ -102,6 +102,7 @@ class TestConfig:
|
||||
assert config.repository_path == Path(tracker_config["repository"]["path"])
|
||||
assert config.branch == "main"
|
||||
assert config.author_resolution.minimum_confidence == "probable"
|
||||
assert config.commit.file_separator == ";" # default
|
||||
|
||||
def test_missing_file(self, tmp_path: Path) -> None:
|
||||
with pytest.raises(ConfigurationError):
|
||||
@@ -175,16 +176,19 @@ class TestCommitMessage:
|
||||
assert lines[0].startswith("SCADA automatic change capture - ")
|
||||
assert "Summary:" in lines
|
||||
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 "Deleted: 1" in message
|
||||
# One-line-per-file entries with the default ';' separator (Section 15)
|
||||
assert " A ; Stations/PS101/pump2.xml ; UNKNOWN ; " in message
|
||||
assert " M ; Stations/PS101/project.xml ; DOMAIN\\jsmith ; " in message
|
||||
assert " M ; System/global.xml ; UNKNOWN ; " in message
|
||||
assert " D ; Stations/PS027/old.xml" in message
|
||||
# Local-time timestamps with explicit +/-HH:MM offset
|
||||
assert re.search(
|
||||
r"Modified at: \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2}\b", message
|
||||
r"; \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
|
||||
# One 'Changes:' section; no multi-line author blocks remain
|
||||
assert "Last modified by:" not in message
|
||||
assert "Changes:" in message
|
||||
# Trailers last (Section 36)
|
||||
assert "Tracker-Version: 1.0.0" in message
|
||||
assert "Tracker-Run: 01J7K8HYV84ZKFH1J4T9R8DZQN" in message
|
||||
@@ -199,9 +203,12 @@ class TestCommitMessage:
|
||||
deleted=[ChangeRecord(path="gone.xml", change_type=ChangeType.DELETED)]
|
||||
)
|
||||
message = build_commit_message(change_set, self._run())
|
||||
idx = message.index("gone.xml")
|
||||
following = message[idx:].splitlines()
|
||||
assert not any("Last modified by" in line for line in following[1:3])
|
||||
# Deleted entries are bare: letter, separator, path - no author/time
|
||||
assert " D ; gone.xml" in message
|
||||
assert "UNKNOWN" not in message
|
||||
for line in message.splitlines():
|
||||
if "gone.xml" in line:
|
||||
assert line.count(";") == 1
|
||||
|
||||
def test_rename_rendered_with_arrow(self) -> None:
|
||||
change_set = ChangeSet(
|
||||
@@ -212,4 +219,15 @@ class TestCommitMessage:
|
||||
]
|
||||
)
|
||||
message = build_commit_message(change_set, self._run())
|
||||
assert "old.xml -> new.xml" in message
|
||||
assert " R ; old.xml -> new.xml" in message
|
||||
|
||||
def test_custom_separator(self) -> None:
|
||||
change_set = ChangeSet(
|
||||
added=[ChangeRecord(path="pump.xml", change_type=ChangeType.ADDED)],
|
||||
deleted=[ChangeRecord(path="gone.xml", change_type=ChangeType.DELETED)],
|
||||
)
|
||||
run = self._run()
|
||||
message = build_commit_message(change_set, run, file_separator="|")
|
||||
assert " A | pump.xml ; UNKNOWN ; " not in message
|
||||
assert " A | pump.xml | UNKNOWN | " in message
|
||||
assert " D | gone.xml" in message
|
||||
|
||||
Reference in New Issue
Block a user