fix(dream): ignore line-ending-only memory diffs
This commit is contained in:
committed by
chengyongru
parent
6b5820ea89
commit
ed47cf1562
@@ -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="",
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user