Fix wiki TypeError on null source_file and skip nested worktrees/ dirs (#1016, #1023)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Safi
2026-05-26 09:06:43 +01:00
co-authored by Claude Sonnet 4.6
parent 3efae3827f
commit 4e80d8621f
4 changed files with 32 additions and 3 deletions
+13
View File
@@ -657,6 +657,19 @@ def test_detect_skips_worktrees_dir(tmp_path):
assert not any(".worktrees" in f for f in code)
def test_detect_skips_nested_worktrees_dir(tmp_path):
"""Files inside .claude/worktrees/ (nested placement) are never indexed (#1023)."""
wt = tmp_path / ".claude" / "worktrees" / "feature-branch"
wt.mkdir(parents=True)
(wt / "main.py").write_text("x = 1")
(tmp_path / "app.py").write_text("y = 2")
result = detect(tmp_path)
code = result["files"]["code"]
assert any("app.py" in f for f in code)
assert not any("worktrees" in f for f in code)
def test_detect_extra_excludes_pattern(tmp_path):
"""extra_excludes patterns exclude matching files from detect() (#947)."""
(tmp_path / "main.py").write_text("x = 1")
+13
View File
@@ -197,3 +197,16 @@ def test_to_wiki_stale_nodes_prints_warning(tmp_path, capsys):
err = capsys.readouterr().err
assert "2" in err # dropped count
assert "stale" in err.lower()
def test_community_article_handles_null_source_file(tmp_path):
"""source_file=None on a node must not crash sorted() with TypeError (#1016)."""
G = nx.Graph()
G.add_node("n1", label="parse", file_type="code", source_file=None, community=0)
G.add_node("n2", label="validate", file_type="code", source_file="parser.py", community=0)
G.add_edge("n1", "n2", relation="calls", confidence="EXTRACTED", weight=1.0)
communities = {0: ["n1", "n2"]}
labels = {0: "Parsing Layer"}
# Must not raise TypeError
to_wiki(G, communities, tmp_path, community_labels=labels)
assert (tmp_path / "index.md").exists()