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): keep non-code co-change partners when update re-walks history (#3896)
Raghav Chamadiyac757b5711ff5
diff --git a/packages/core/src/repowise/core/ingestion/git_indexer/indexer.py b/packages/core/src/repowise/core/ingestion/git_indexer/indexer.pyindex deaacf862..8e7169b5d 100644--- a/packages/core/src/repowise/core/ingestion/git_indexer/indexer.py+++ b/packages/core/src/repowise/core/ingestion/git_indexer/indexer.py@@ -638,6 +638,9 @@ class GitIndexer:)history_changed = history_files.intersection(changed_file_paths)changed_file_paths = [fp for fp in changed_file_paths if not _should_skip_index(fp)]+ # The co-change walk reads the same tracked-file set the full index+ # hands it, so a template or stylesheet stays a partner after an update.+ co_change_files = set(tier_paths) if tier_paths else Noneif all_files:all_files = {fp for fp in all_files if not _should_skip_index(fp)}@@ -825,7 +828,7 @@ class GitIndexer:executor,compute_co_changes_and_entropy,repo,- set(all_files),+ co_change_files or set(all_files),max(self.commit_limit, _DEFAULT_CO_CHANGE_COMMIT_LIMIT),_MAX_PARTNERS_PER_FILE,None,diff --git a/tests/unit/ingestion/test_git_update_equivalence.py b/tests/unit/ingestion/test_git_update_equivalence.pyindex e848d1ac1..9e774bb58 100644--- a/tests/unit/ingestion/test_git_update_equivalence.py+++ b/tests/unit/ingestion/test_git_update_equivalence.py@@ -146,6 +146,29 @@ async def test_update_path_recomputes_co_change_partners(tmp_path) -> None:assert meta["change_entropy"] > 0.0+async def test_update_path_keeps_non_code_co_change_partner(tmp_path) -> None:+ """The update walk reads the tracked-file set the full index does, so a+ template that changes with a module stays one of its partners."""+ import json++ import git as gitpython++ _build_repo_with_cochange(tmp_path)+ repo = gitpython.Repo(tmp_path)+ for i in range(4):+ (tmp_path / "a.py").write_text(f"x = {i + 100}\n")+ (tmp_path / "t.html").write_text(f"<p>{i}</p>\n")+ repo.index.add(["a.py", "t.html"])+ repo.index.commit(f"feat: change module and template together {i}")+ repo.close()++ upd = GitIndexer(tmp_path, tier=GitIndexTier.FULL)+ (meta,) = await upd.index_changed_files(["a.py"], all_files={"a.py", "b.py"})++ partners = {p["file_path"] for p in json.loads(meta["co_change_partners_json"])}+ assert "t.html" in partners++async def test_update_path_essential_tier_skips_co_change_walk(tmp_path) -> None:_build_repo_with_cochange(tmp_path)