fix(dream): ignore line-ending-only memory diffs

This commit is contained in:
bingqilinweimaotai
2026-07-14 00:30:50 +08:00
committed by chengyongru
parent 6b5820ea89
commit ed47cf1562
2 changed files with 38 additions and 3 deletions
+7 -3
View File
@@ -377,12 +377,16 @@ class GitStore:
changed += 1
summary_lines.append(f"{path}: binary or non-UTF-8 file changed")
continue
if head_text == wt_text:
# Git blobs preserve line endings while read_text() normalizes
# them. Compare the same logical lines used by the diff.
head_lines = head_text.splitlines()
wt_lines = wt_text.splitlines()
if head_lines == wt_lines:
continue
changed += 1
hunks = list(difflib.unified_diff(
head_text.splitlines(),
wt_text.splitlines(),
head_lines,
wt_lines,
fromfile=path,
tofile=path,
lineterm="",
+31
View File
@@ -666,6 +666,37 @@ class TestDreamContentDiff:
store.git.auto_commit("initial")
assert store.dream_content_diff() == ""
def test_ignores_platform_line_ending_normalization(self, store, monkeypatch):
import subprocess
system_config = store.workspace / "system.gitconfig"
global_config = store.workspace / "global.gitconfig"
system_config.touch()
global_config.touch()
subprocess.run(
[
"git", "config", "--file", str(system_config),
"core.autocrlf", "false",
],
check=True,
capture_output=True,
)
monkeypatch.delenv("GIT_CONFIG_NOSYSTEM", raising=False)
monkeypatch.setenv("GIT_CONFIG_SYSTEM", str(system_config))
monkeypatch.setenv("GIT_CONFIG_GLOBAL", str(global_config))
store.soul_file.write_bytes(b"# Soul\r\n- Helpful")
store.memory_file.write_bytes(b"# Memory\r\n- Project X active")
store.git.init()
status = subprocess.check_output(
["git", "status", "--porcelain", "--", "SOUL.md", "memory/MEMORY.md"],
cwd=store.workspace,
text=True,
)
assert status == ""
assert store.dream_content_diff() == ""
def test_reflects_real_content_edits(self, store):
store.git.init()
store.git.auto_commit("initial")