fix(gitstore): resolve staged paths relative to workspace

This commit is contained in:
Pei Futong
2026-07-19 16:01:11 +08:00
committed by chengyongru
parent ffb7ddfa1e
commit cea8617096
2 changed files with 24 additions and 2 deletions
+9 -2
View File
@@ -113,7 +113,10 @@ class GitStore:
p.write_text("", encoding="utf-8")
# Initial commit
porcelain.add(str(self._workspace), paths=[".gitignore"] + self._tracked_files)
porcelain.add(
str(self._workspace),
paths=self._staging_paths(".gitignore", *self._tracked_files),
)
porcelain.commit(
str(self._workspace),
message=b"init: nanobot memory store",
@@ -146,7 +149,7 @@ class GitStore:
return None
msg_bytes = message.encode("utf-8") if isinstance(message, str) else message
porcelain.add(str(self._workspace), paths=self._tracked_files)
porcelain.add(str(self._workspace), paths=self._staging_paths(*self._tracked_files))
sha_bytes = porcelain.commit(
str(self._workspace),
message=msg_bytes,
@@ -164,6 +167,10 @@ class GitStore:
# -- internal helpers ------------------------------------------------------
def _staging_paths(self, *paths: str) -> list[str]:
"""Return absolute paths so Dulwich resolves them inside this workspace."""
return [str((self._workspace / path).resolve()) for path in paths]
def _resolve_sha(self, short_sha: str) -> bytes | None:
"""Resolve a short SHA prefix to the full SHA bytes."""
try: