MCPcopy Index your code
hub / github.com/tirth8205/code-review-graph / get_db_path

Function get_db_path

code_review_graph/incremental.py:301–324  ·  view source on GitHub ↗

Determine the database path for a repository. Respects ``CRG_DATA_DIR`` (see :func:`get_data_dir`). Migrates a legacy top-level ``.code-review-graph.db`` file into the new directory when it exists (WAL/SHM side-files are discarded).

(repo_root: Path)

Source from the content-addressed store, hash-verified

299
300
301def get_db_path(repo_root: Path) -> Path:
302 """Determine the database path for a repository.
303
304 Respects ``CRG_DATA_DIR`` (see :func:`get_data_dir`). Migrates a
305 legacy top-level ``.code-review-graph.db`` file into the new
306 directory when it exists (WAL/SHM side-files are discarded).
307 """
308 crg_dir = get_data_dir(repo_root)
309 new_db = crg_dir / "graph.db"
310
311 # Migrate legacy database if present (only meaningful when the
312 # legacy file sits at the repo root — if CRG_DATA_DIR is set we
313 # skip the migration because there's no relationship between the
314 # legacy location and the new one).
315 legacy_db = repo_root / ".code-review-graph.db"
316 if legacy_db.exists() and not new_db.exists():
317 legacy_db.rename(new_db)
318 # Discard stale WAL/SHM side-files from the old location
319 for suffix in ("-wal", "-shm", "-journal"):
320 side = repo_root / f".code-review-graph.db{suffix}"
321 if side.exists():
322 side.unlink()
323
324 return new_db
325
326
327def ensure_repo_gitignore_excludes_crg(repo_root: Path) -> str:

Calls 1

get_data_dirFunction · 0.85