Skip to content

Commit 915c97a

Browse files
committed
fix: respect prune rules for symlink aliases
1 parent 2ae9f90 commit 915c97a

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/index_graph/scan.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ def _onerror(exc: OSError) -> None:
5252
if ".git" in dirnames or ".git" in filenames:
5353
repos.add(current)
5454
for dirname in dirnames:
55+
if dirname in prune:
56+
continue
5557
child = current / dirname
5658
try:
5759
if child.is_symlink() and ((child / ".git").is_dir() or (child / ".git").is_file()):

tests/test_scan.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ def test_discover_reports_sole_directory_symlink_alias(tmp_path: Path):
6969
assert discover_repos(alias.parent, Config()) == [alias]
7070

7171

72+
def test_discover_prunes_directory_symlink_repo_alias(tmp_path: Path):
73+
if os.name == "nt":
74+
pytest.skip("directory symlink behavior covered on POSIX; Windows uses junction fixture")
75+
target = tmp_path / "outside" / "target"
76+
_make_repo(target)
77+
alias = tmp_path / "scan-root" / "node_modules"
78+
alias.parent.mkdir()
79+
alias.symlink_to(target, target_is_directory=True)
80+
assert discover_repos(alias.parent, Config()) == []
81+
82+
7283
def test_deduplicate_repo_aliases_collapses_mocked_physical_identity(
7384
tmp_path: Path, monkeypatch
7485
):

0 commit comments

Comments
 (0)