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(mcp): name git when get_change_risk cannot find it on PATH (#3659)
Swati Ahuja01b3df8b4891
diff --git a/packages/server/src/repowise/server/mcp_server/tool_change_risk.py b/packages/server/src/repowise/server/mcp_server/tool_change_risk.pyindex 512bfca15..3f3aef51c 100644--- a/packages/server/src/repowise/server/mcp_server/tool_change_risk.py+++ b/packages/server/src/repowise/server/mcp_server/tool_change_risk.py@@ -5,6 +5,7 @@ from __future__ import annotationsimport asyncioimport contextlibimport math+import shutilimport subprocessimport threadingimport time@@ -174,6 +175,14 @@ async def _score_change(return None, {"error": f"Could not read change {revspec or 'HEAD'!r}: {detail}"}except subprocess.TimeoutExpired:return None, {"error": f"git timed out reading change {revspec or 'HEAD'!r}."}+ except FileNotFoundError:+ # Scoring spawns git from several readers, so the missing binary is+ # named once here. Any other missing file is a real bug: re-raise.+ if shutil.which("git") is not None:+ raise+ return None, {+ "error": "git was not found on PATH; change risk reads the repository history."+ }return result, Nonediff --git a/tests/unit/server/mcp/test_tool_change_risk.py b/tests/unit/server/mcp/test_tool_change_risk.pyindex 73601a2d5..936b201b5 100644--- a/tests/unit/server/mcp/test_tool_change_risk.py+++ b/tests/unit/server/mcp/test_tool_change_risk.py@@ -54,6 +54,21 @@ async def test_git_timeout_is_an_error_naming_the_change(monkeypatch):assert result == {"error": "git timed out reading change 'a..b'."}+async def test_git_missing_from_path_is_an_error_naming_git(monkeypatch, tmp_path):+ """The real scorer with no git on PATH: a named error, not a raw FileNotFoundError."""++ async def _context(_repo):+ return SimpleNamespace(path=str(tmp_path))++ monkeypatch.setattr(tool, "_resolve_repo_context", _context)+ monkeypatch.setenv("PATH", str(tmp_path))+ result = await tool.get_change_risk("HEAD")+ assert result == {+ "error": "git was not found on PATH; change risk reads the repository history."+ }++# ---------------------------------------------------------------------------# Health comparison and its stored-finding references# ---------------------------------------------------------------------------