fix(gitstore): detect rapid same-size rewrites

This commit is contained in:
qtds
2026-08-26 16:19:10 +08:00
committed by chengyongru
parent 9d34fc5af2
commit 9f5a56f1ec
2 changed files with 18 additions and 5 deletions
+13
View File
@@ -1,5 +1,6 @@
"""Tests for GitStore — git-backed version control for memory files."""
import os
from unittest.mock import patch
import pytest
@@ -98,6 +99,18 @@ class TestAutoCommit:
assert len(commits) == 2
assert commits[0].sha == sha
def test_commits_same_size_rewrite_with_unchanged_mtime(self, git_ready):
path = git_ready._workspace / "SOUL.md"
path.write_text("v1", encoding="utf-8")
git_ready.auto_commit("v1")
previous_stat = path.stat()
path.write_text("v2", encoding="utf-8")
os.utime(path, ns=(previous_stat.st_atime_ns, previous_stat.st_mtime_ns))
assert git_ready.auto_commit("v2") is not None
assert [commit.message for commit in git_ready.log()[:2]] == ["v2", "v1"]
def test_does_not_create_empty_commits(self, git_ready):
git_ready.auto_commit("nothing 1")
git_ready.auto_commit("nothing 2")