Skip to content
Merged
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
3 changes: 2 additions & 1 deletion code_review_graph/communities.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,8 @@ def store_communities(
count = 0
for comm in communities:
cursor = conn.execute(
"""INSERT INTO communities (name, level, cohesion, size, dominant_language, description)
"""INSERT INTO communities
(name, level, cohesion, size, dominant_language, description)
VALUES (?, ?, ?, ?, ?, ?)""",
(
comm["name"],
Expand Down
2 changes: 1 addition & 1 deletion code_review_graph/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2432,7 +2432,7 @@ def _get_name(self, node, language: str, kind: str) -> Optional[str]:
if language == "go" and node.type == "method_declaration":
for child in node.children:
if child.type == "field_identifier":
return child.text.decode("utf-8", errors="replace")
return child.text.decode("utf-8", errors="replace")
# Most languages use a 'name' child
for child in node.children:
if child.type in (
Expand Down
10 changes: 5 additions & 5 deletions code_review_graph/skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,14 @@ def install_git_hook(repo_root: Path) -> Path | None:
existing one — preserving any hooks already there. Returns None when no
``.git`` directory is found.
"""
_SCRIPT = """\
script = """\
#!/bin/sh
# Installed by code-review-graph. Remove this file to disable pre-commit graph checks.
if command -v code-review-graph >/dev/null 2>&1; then
code-review-graph detect-changes --brief || true
fi
"""
_MARKER = "code-review-graph detect-changes"
marker = "code-review-graph detect-changes"

git_dir = repo_root / ".git"
if not git_dir.is_dir():
Expand All @@ -465,11 +465,11 @@ def install_git_hook(repo_root: Path) -> Path | None:

if hook_path.exists():
existing = hook_path.read_text(encoding="utf-8")
if _MARKER in existing:
if marker in existing:
return hook_path
hook_path.write_text(existing.rstrip("\n") + "\n" + _SCRIPT, encoding="utf-8")
hook_path.write_text(existing.rstrip("\n") + "\n" + script, encoding="utf-8")
else:
hook_path.write_text(_SCRIPT, encoding="utf-8")
hook_path.write_text(script, encoding="utf-8")

hook_path.chmod(0o755)
logger.info("Wrote git pre-commit hook: %s", hook_path)
Expand Down
2 changes: 1 addition & 1 deletion code_review_graph/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def generate_html(
# ---------------------------------------------------------------------------

# Template lives in this file for zero-dependency packaging (no external files
# to locate at runtime). The ``# noqa: E501`` on the module is set via
# to locate at runtime). The E501 suppression for this module is configured via
# pyproject.toml per-file-ignores for this reason.

_HTML_TEMPLATE = r"""<!DOCTYPE html>
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ dev = [
"pytest-asyncio>=0.23,<1",
"pytest-cov>=4.0,<8",
"ruff>=0.3.0,<1",
"tomli>=2.0; python_version < '3.11'",
]

[tool.hatch.build.targets.wheel]
Expand Down
6 changes: 5 additions & 1 deletion tests/test_skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import json
import os
import sys
from pathlib import Path
from unittest.mock import patch

import tomllib
if sys.version_info >= (3, 11):
import tomllib
else: # pragma: no cover - Python 3.10 backport
import tomli as tomllib

from code_review_graph.skills import (
_CLAUDE_MD_SECTION_MARKER,
Expand Down
138 changes: 137 additions & 1 deletion uv.lock

Large diffs are not rendered by default.

Loading