fix(dream): filter non-Dream history commits (#4905)
* fix(dream): filter non-Dream history commits * fix(dream): resolve filtered commit diffs
This commit is contained in:
@@ -117,6 +117,17 @@ class TestLog:
|
||||
git_ready.auto_commit(f"c{i}")
|
||||
assert len(git_ready.log(max_entries=3)) == 3
|
||||
|
||||
def test_message_prefix_skips_unrelated_commits_before_counting_limit(self, git_ready):
|
||||
ws = git_ready._workspace
|
||||
messages = ["dream: older", "backup: first", "dream: latest", "backup: newest"]
|
||||
for i, message in enumerate(messages):
|
||||
(ws / "SOUL.md").write_text(f"v{i}", encoding="utf-8")
|
||||
git_ready.auto_commit(message)
|
||||
|
||||
commits = git_ready.log(max_entries=2, message_prefix="dream:")
|
||||
|
||||
assert [commit.message for commit in commits] == ["dream: latest", "dream: older"]
|
||||
|
||||
def test_commit_info_fields(self, git_ready):
|
||||
c = git_ready.log()[0]
|
||||
assert isinstance(c, CommitInfo)
|
||||
@@ -178,6 +189,25 @@ class TestShowCommitDiff:
|
||||
def test_returns_none_for_unknown(self, git_ready):
|
||||
assert git_ready.show_commit_diff("deadbeef") is None
|
||||
|
||||
def test_message_prefix_finds_commit_beyond_unrelated_history_window(self, git_ready):
|
||||
ws = git_ready._workspace
|
||||
(ws / "SOUL.md").write_text("dream content", encoding="utf-8")
|
||||
dream_sha = git_ready.auto_commit("dream: latest")
|
||||
for i in range(20):
|
||||
(ws / "SOUL.md").write_text(f"backup {i}", encoding="utf-8")
|
||||
git_ready.auto_commit(f"backup: {i}")
|
||||
|
||||
result = git_ready.show_commit_diff(
|
||||
dream_sha,
|
||||
max_entries=1,
|
||||
message_prefix="dream:",
|
||||
)
|
||||
|
||||
assert result is not None
|
||||
commit, diff = result
|
||||
assert commit.sha == dream_sha
|
||||
assert "dream content" in diff
|
||||
|
||||
|
||||
class TestCommitInfoFormat:
|
||||
def test_format_with_diff(self):
|
||||
@@ -221,6 +251,19 @@ class TestRevert:
|
||||
def test_invalid_sha_returns_none(self, git_ready):
|
||||
assert git_ready.revert("deadbeef") is None
|
||||
|
||||
def test_message_prefix_rejects_unrelated_commit_without_changing_files(self, git_ready):
|
||||
ws = git_ready._workspace
|
||||
(ws / "SOUL.md").write_text("dream v1", encoding="utf-8")
|
||||
git_ready.auto_commit("dream: v1")
|
||||
(ws / "SOUL.md").write_text("backup state", encoding="utf-8")
|
||||
backup_sha = git_ready.auto_commit("backup: workspace")
|
||||
(ws / "SOUL.md").write_text("dream v2", encoding="utf-8")
|
||||
latest_sha = git_ready.auto_commit("dream: v2")
|
||||
|
||||
assert git_ready.revert(backup_sha, message_prefix="dream:") is None
|
||||
assert (ws / "SOUL.md").read_text(encoding="utf-8") == "dream v2"
|
||||
assert git_ready.log()[0].sha == latest_sha
|
||||
|
||||
|
||||
class TestMemoryStoreGitProperty:
|
||||
def test_git_property_exposes_gitstore(self, tmp_path):
|
||||
|
||||
Reference in New Issue
Block a user