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.

fix: doctor table mode exits 1 when checks fail (#4289)

Swastik Tawatec27ba23de5bc
diff --git a/packages/cli/src/repowise/cli/commands/doctor_cmd/command.py b/packages/cli/src/repowise/cli/commands/doctor_cmd/command.py
index f1dd36669..ec3b6d31a 100644
--- a/packages/cli/src/repowise/cli/commands/doctor_cmd/command.py
+++ b/packages/cli/src/repowise/cli/commands/doctor_cmd/command.py
@@ -83,8 +83,8 @@ def doctor_command(
if fmt != "table":
payload = {"ok": all_ok, "checks": [c._asdict() for c in checks]}
click.echo(json.dumps(payload, indent=2))
- if not all_ok:
- raise SystemExit(1)
+ if not all_ok:
+ raise SystemExit(1)
return
# Workspace mode — iterate over every entry, run workspace-level
@@ -154,3 +154,4 @@ def doctor_command(
console.print("[bold yellow]All indexed repos healthy; some repos unindexed.[/bold yellow]")
else:
console.print("[bold yellow]Some checks failed across the workspace.[/bold yellow]")
+ raise SystemExit(1)
diff --git a/tests/unit/cli/test_doctor_json.py b/tests/unit/cli/test_doctor_json.py
index 45167d914..b76ad9c27 100644
--- a/tests/unit/cli/test_doctor_json.py
+++ b/tests/unit/cli/test_doctor_json.py
@@ -61,3 +61,26 @@ class TestDoctorFormatJson:
assert result.exit_code != 0
assert "--repair" in result.output
assert "json" in result.output.lower()
+
+
+class TestDoctorTableExitCode:
+ """Table mode must exit 1 when checks fail, like json mode does."""
+
+ def test_table_output_on_unindexed_repo_exits_1(self, tmp_path: Path) -> None:
+ _git_init(tmp_path)
+
+ result = CliRunner().invoke(doctor_command, [str(tmp_path), "--no-workspace"])
+
+ assert result.exit_code == 1, result.output
+ assert "Some checks failed" in result.output
+
+ def test_table_output_on_healthy_repo_exits_0(self, tmp_path: Path, monkeypatch) -> None:
+ _git_init(tmp_path)
+ monkeypatch.setattr(
+ "repowise.cli.commands.doctor_cmd.command._run_repo_checks",
+ lambda repo_path, repair, fmt="table": (True, []),
+ )
+
+ result = CliRunner().invoke(doctor_command, [str(tmp_path), "--no-workspace"])
+
+ assert result.exit_code == 0, result.output