Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions code_review_graph/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,21 +322,6 @@ def _handle_init(args: argparse.Namespace) -> None:
print(" 2. Restart your AI coding tool to pick up the new config")


def _cli_post_process(store: GraphStore) -> None:
"""Run post-build pipeline and print a summary line for each step."""
from .postprocessing import run_post_processing

pp = run_post_processing(store)
if pp.get("signatures_computed"):
print(f"Signatures: {pp['signatures_computed']} nodes")
if pp.get("fts_indexed"):
print(f"FTS indexed: {pp['fts_indexed']} nodes")
if pp.get("flows_detected") is not None:
print(f"Flows: {pp['flows_detected']}")
if pp.get("communities_detected") is not None:
print(f"Communities: {pp['communities_detected']}")


def _handle_data_dir_option(args, repo_root: Path) -> None:
"""Handle --data-dir option by updating registry if specified."""
if hasattr(args, "data_dir") and args.data_dir:
Expand Down Expand Up @@ -923,7 +908,6 @@ def main() -> None:
print(f"Full build: {parsed} files, {nodes} nodes, {edges} edges (postprocess={pp})")
if result.get("errors"):
print(f"Errors: {len(result['errors'])}")
_cli_post_process(store)

elif args.command == "update":
pp = (
Expand All @@ -947,8 +931,6 @@ def main() -> None:
f"{nodes} nodes, {edges} edges"
f" (postprocess={pp})"
)
if result.get("files_updated", 0) > 0:
_cli_post_process(store)

elif args.command == "status":
stats = store.get_stats()
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,5 @@ norecursedirs = ["tests/fixtures"]
[dependency-groups]
dev = [
"pytest>=8.4.2",
"pytest-asyncio>=0.23,<1",
]
75 changes: 75 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,78 @@ def test_watch_exits_when_lock_is_held(self):
assert False, "Expected SystemExit"
except SystemExit as exc:
assert exc.code == 1


class TestBuildUpdateCommands:
def test_build_skip_postprocess_does_not_run_extra_cli_postprocess(self):
argv = [
"code-review-graph",
"build",
"--skip-postprocess",
"--repo",
"repo-root",
]
result = {
"files_parsed": 1,
"total_nodes": 2,
"total_edges": 1,
"postprocess_level": "none",
}

with patch.object(sys, "argv", argv):
with patch("code_review_graph.graph.GraphStore") as mock_store:
mock_store.return_value = MagicMock()
with patch("code_review_graph.incremental.get_db_path") as mock_db:
mock_db.return_value = MagicMock()
with patch(
"code_review_graph.tools.build.build_or_update_graph",
return_value=result,
) as mock_build:
with patch(
"code_review_graph.postprocessing.run_post_processing",
) as mock_postprocess:
cli.main()

mock_build.assert_called_once_with(
full_rebuild=True,
repo_root="repo-root",
postprocess="none",
)
mock_postprocess.assert_not_called()

def test_update_skip_flows_does_not_run_extra_cli_postprocess(self):
argv = [
"code-review-graph",
"update",
"--skip-flows",
"--repo",
"repo-root",
]
result = {
"files_updated": 1,
"total_nodes": 2,
"total_edges": 1,
"postprocess_level": "minimal",
}

with patch.object(sys, "argv", argv):
with patch("code_review_graph.graph.GraphStore") as mock_store:
mock_store.return_value = MagicMock()
with patch("code_review_graph.incremental.get_db_path") as mock_db:
mock_db.return_value = MagicMock()
with patch(
"code_review_graph.tools.build.build_or_update_graph",
return_value=result,
) as mock_build:
with patch(
"code_review_graph.postprocessing.run_post_processing",
) as mock_postprocess:
cli.main()

mock_build.assert_called_once_with(
full_rebuild=False,
repo_root="repo-root",
base="HEAD~1",
postprocess="minimal",
)
mock_postprocess.assert_not_called()
6 changes: 5 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.