fix: codegraph init
This commit is contained in:
@@ -16,7 +16,8 @@ class CodeGraphError(RuntimeError):
|
|||||||
class CodeGraphClient:
|
class CodeGraphClient:
|
||||||
async def prepare(self, workspace: Path) -> None:
|
async def prepare(self, workspace: Path) -> None:
|
||||||
self._exclude_index(workspace)
|
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()
|
started = monotonic()
|
||||||
log.info(
|
log.info(
|
||||||
"CodeGraph index preparation started",
|
"CodeGraph index preparation started",
|
||||||
|
|||||||
@@ -10,11 +10,12 @@ class FakeProcess:
|
|||||||
return b"", b""
|
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
|
tmp_path: Path, monkeypatch
|
||||||
) -> None:
|
) -> None:
|
||||||
workspace = tmp_path / "repo"
|
workspace = tmp_path / "repo"
|
||||||
(workspace / ".git" / "info").mkdir(parents=True)
|
(workspace / ".git" / "info").mkdir(parents=True)
|
||||||
|
(workspace / ".codegraph").mkdir()
|
||||||
calls: list[tuple[object, ...]] = []
|
calls: list[tuple[object, ...]] = []
|
||||||
|
|
||||||
async def create_subprocess_exec(*args, **_kwargs):
|
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 = tmp_path / "repo"
|
||||||
(workspace / ".git" / "info").mkdir(parents=True)
|
(workspace / ".git" / "info").mkdir(parents=True)
|
||||||
(workspace / ".codegraph").mkdir()
|
(workspace / ".codegraph").mkdir()
|
||||||
|
(workspace / ".codegraph" / "codegraph.db").touch()
|
||||||
exclude = workspace / ".git" / "info" / "exclude"
|
exclude = workspace / ".git" / "info" / "exclude"
|
||||||
exclude.write_text("# local excludes\n.codegraph/\n")
|
exclude.write_text("# local excludes\n.codegraph/\n")
|
||||||
calls: list[tuple[object, ...]] = []
|
calls: list[tuple[object, ...]] = []
|
||||||
|
|||||||
Reference in New Issue
Block a user