diff --git a/src/agentci/adapters/codegraph.py b/src/agentci/adapters/codegraph.py index 86c88f7..bcdcf23 100644 --- a/src/agentci/adapters/codegraph.py +++ b/src/agentci/adapters/codegraph.py @@ -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", diff --git a/tests/test_codegraph.py b/tests/test_codegraph.py index 0876496..d8f063d 100644 --- a/tests/test_codegraph.py +++ b/tests/test_codegraph.py @@ -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, ...]] = []