Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

Parallelize per-file git indexing with co-change analysis

RaghavChamadiya67a00b20cc68
diff --git a/packages/cli/src/repowise/cli/commands/init_cmd.py b/packages/cli/src/repowise/cli/commands/init_cmd.py
index 20ec58e4a..f00c95fa9 100644
--- a/packages/cli/src/repowise/cli/commands/init_cmd.py
+++ b/packages/cli/src/repowise/cli/commands/init_cmd.py
@@ -456,14 +456,19 @@ def init_command(
graph_builder.build()
progress.update(task_graph, completed=1)
- # Wait for git indexing to complete
+ # Wait for git indexing to complete — show a spinner so the user
+ # doesn't think it's stuck after the co-change bar hits 100%.
if git_future is not None:
+ task_git_finalize = progress.add_task(
+ "Finalizing git analysis...", total=None, visible=True,
+ )
try:
git_summary, git_metadata_list = git_future.result()
git_meta_map = {m["file_path"]: m for m in git_metadata_list}
graph_builder.add_co_change_edges(git_meta_map)
except Exception as exc:
progress.console.print(f"[yellow]Git indexing failed: {exc}[/yellow]")
+ progress.update(task_git_finalize, visible=False)
git_executor.shutdown(wait=False)
diff --git a/packages/core/src/repowise/core/ingestion/git_indexer.py b/packages/core/src/repowise/core/ingestion/git_indexer.py
index e2baa2350..5b60fd69c 100644
--- a/packages/core/src/repowise/core/ingestion/git_indexer.py
+++ b/packages/core/src/repowise/core/ingestion/git_indexer.py
@@ -267,8 +267,20 @@ class GitIndexer:
on_file_done()
return result
- tasks = [index_one(fp) for fp in indexable_files]
- metadata_list = await asyncio.gather(*tasks, return_exceptions=True)
+ # Run per-file indexing and co-change analysis in parallel — they are
+ # independent (co-change only needs tracked_files, not per-file results).
+ file_tasks = [index_one(fp) for fp in indexable_files]
+
+ async def _co_change_task() -> dict[str, list[dict]]:
+ return await loop.run_in_executor(
+ None, self._compute_co_changes, repo, set(tracked_files),
+ self.commit_limit, 3, on_commit_done, on_co_change_start,
+ )
+
+ metadata_list, co_changes = await asyncio.gather(
+ asyncio.gather(*file_tasks, return_exceptions=True),
+ _co_change_task(),
+ )
# Filter out failures
results: list[dict] = []
@@ -278,12 +290,7 @@ class GitIndexer:
else:
results.append(r)
- # Co-change analysis uses ALL tracked files (not just indexable ones) so
- # that relationships like "whenever auth.py changes, config.yaml changes too"
- # are captured even for files we didn't run full git log/blame on.
- co_changes = await loop.run_in_executor(
- None, self._compute_co_changes, repo, set(tracked_files), self.commit_limit, 3, on_commit_done, on_co_change_start
- )
+ # Merge co-change partners into per-file metadata
for meta in results:
fp = meta["file_path"]
if fp in co_changes: