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

Function get_data_dir

code_review_graph/incremental.py:258–298  ·  view source on GitHub ↗

Return the directory where this project's graph data lives. Resolution priority: 1. Registry entry for this repo (set via --data-dir) 2. CRG_DATA_DIR environment variable (global override) 3. Default: /.code-review-graph/ By default, `` /.code-review-graph``. If

(repo_root: Path)

Source from the content-addressed store, hash-verified

256
257
258def get_data_dir(repo_root: Path) -> Path:
259 """Return the directory where this project's graph data lives.
260
261 Resolution priority:
262 1. Registry entry for this repo (set via --data-dir)
263 2. CRG_DATA_DIR environment variable (global override)
264 3. Default: <repo>/.code-review-graph/
265
266 By default, ``<repo_root>/.code-review-graph``. If the
267 ``CRG_DATA_DIR`` environment variable is set, it is used verbatim
268 instead — letting you keep graphs outside the working tree (useful
269 for ephemeral workspaces, Docker volumes, or shared caches). See: #155
270
271 The directory is created if it does not already exist; an inner
272 ``.gitignore`` (with ``*``) is written so any accidentally-nested
273 files never get committed. Both are idempotent.
274 """
275 # Check registry first
276 try:
277 from .registry import Registry
278 registry_data_dir = Registry().get_data_dir_for_repo(str(repo_root))
279 if registry_data_dir:
280 data_dir = Path(registry_data_dir).resolve()
281 data_dir.mkdir(parents=True, exist_ok=True)
282 _write_data_dir_gitignore(data_dir)
283 return data_dir
284 except Exception as exc:
285 # If registry lookup fails, log and fall through to other methods
286 logger.debug("Registry lookup failed for %s: %s", repo_root, exc)
287
288 # Check environment variable
289 env_override = os.environ.get("CRG_DATA_DIR", "").strip()
290 if env_override:
291 data_dir = Path(env_override).expanduser().resolve()
292 else:
293 data_dir = repo_root / ".code-review-graph"
294
295 data_dir.mkdir(parents=True, exist_ok=True)
296 _write_data_dir_gitignore(data_dir)
297
298 return data_dir
299
300
301def get_db_path(repo_root: Path) -> Path:

Calls 4

RegistryClass · 0.85
get_data_dir_for_repoMethod · 0.80
getMethod · 0.80