Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
Fix git indexer hanging by using per-thread Repo instances
RaghavChamadiya0b0713612209
diff --git a/packages/cli/src/repowise/cli/commands/update_cmd.py b/packages/cli/src/repowise/cli/commands/update_cmd.pyindex 687bce324..4a7f97f06 100644--- a/packages/cli/src/repowise/cli/commands/update_cmd.py+++ b/packages/cli/src/repowise/cli/commands/update_cmd.py@@ -113,8 +113,23 @@ def update_command(graph_builder.build()# Re-index git metadata for changed files- # NOTE: disabled due to git subprocess hanging on Windows — see separate fixgit_meta_map: dict[str, dict] = {}+ try:+ from repowise.core.ingestion.git_indexer import GitIndexer++ _commit_limit = repo_config.get("commit_limit")+ _follow_renames = repo_config.get("follow_renames", False)+ git_indexer = GitIndexer(+ repo_path,+ commit_limit=_commit_limit,+ follow_renames=_follow_renames,+ )+ changed_paths = [fd.path for fd in file_diffs]+ updated_meta = run_async(git_indexer.index_changed_files(changed_paths))+ git_meta_map = {m["file_path"]: m for m in updated_meta}+ graph_builder.update_co_change_edges(git_meta_map)+ except Exception as exc:+ console.print(f"[yellow]Git re-index skipped: {exc}[/yellow]")# Determine affected pagesaffected = detector.get_affected_pages(file_diffs, graph_builder.graph(), cascade_budget)diff --git a/packages/core/src/repowise/core/ingestion/git_indexer.py b/packages/core/src/repowise/core/ingestion/git_indexer.pyindex a15ce391a..3edbb08f2 100644--- a/packages/core/src/repowise/core/ingestion/git_indexer.py+++ b/packages/core/src/repowise/core/ingestion/git_indexer.py@@ -244,12 +244,26 @@ class GitIndexer:semaphore = asyncio.Semaphore(20)loop = asyncio.get_event_loop()+ def _index_one_sync(file_path: str) -> dict:+ """Use a per-thread Repo to avoid shared-handle issues on Windows."""+ try:+ import git as gitpython+ thread_repo = gitpython.Repo(+ self.repo_path, search_parent_directories=True,+ )+ try:+ return self._index_file(file_path, thread_repo)+ finally:+ thread_repo.close()+ except Exception:+ return {"file_path": file_path}+async def index_one(file_path: str) -> dict:async with semaphore:try:result = await asyncio.wait_for(loop.run_in_executor(- executor, self._index_file, file_path, repo+ executor, _index_one_sync, file_path),timeout=_FILE_INDEX_TIMEOUT_SECS,)@@ -342,11 +356,25 @@ class GitIndexer:loop = asyncio.get_event_loop()semaphore = asyncio.Semaphore(20)+ def _index_one_sync(file_path: str) -> dict:+ """Use a per-thread Repo to avoid shared-handle issues on Windows."""+ try:+ import git as gitpython+ thread_repo = gitpython.Repo(+ self.repo_path, search_parent_directories=True,+ )+ try:+ return self._index_file(file_path, thread_repo)+ finally:+ thread_repo.close()+ except Exception:+ return {"file_path": file_path}+async def index_one(file_path: str) -> dict:async with semaphore:try:return await asyncio.wait_for(- loop.run_in_executor(None, self._index_file, file_path, repo),+ loop.run_in_executor(None, _index_one_sync, file_path),timeout=_FILE_INDEX_TIMEOUT_SECS,)except (asyncio.TimeoutError, Exception) as exc: