fix: codegraph init

This commit is contained in:
2026-07-19 20:01:56 +02:00
parent 29d12974fd
commit 1a7d688546
2 changed files with 5 additions and 2 deletions
+2 -1
View File
@@ -16,7 +16,8 @@ class CodeGraphError(RuntimeError):
class CodeGraphClient:
async def prepare(self, workspace: Path) -> None:
self._exclude_index(workspace)
command = "sync" if (workspace / ".codegraph").is_dir() else "init"
index = workspace / ".codegraph" / "codegraph.db"
command = "sync" if index.is_file() else "init"
started = monotonic()
log.info(
"CodeGraph index preparation started",
+3 -1
View File
@@ -10,11 +10,12 @@ class FakeProcess:
return b"", b""
async def test_initializes_index_and_excludes_it_from_git(
async def test_initializes_incomplete_index_and_excludes_it_from_git(
tmp_path: Path, monkeypatch
) -> None:
workspace = tmp_path / "repo"
(workspace / ".git" / "info").mkdir(parents=True)
(workspace / ".codegraph").mkdir()
calls: list[tuple[object, ...]] = []
async def create_subprocess_exec(*args, **_kwargs):
@@ -38,6 +39,7 @@ async def test_syncs_an_existing_index_without_duplicating_exclude(
workspace = tmp_path / "repo"
(workspace / ".git" / "info").mkdir(parents=True)
(workspace / ".codegraph").mkdir()
(workspace / ".codegraph" / "codegraph.db").touch()
exclude = workspace / ".git" / "info" / "exclude"
exclude.write_text("# local excludes\n.codegraph/\n")
calls: list[tuple[object, ...]] = []