mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix: _paths_overlap() false positives for sibling paths
The old implementation compared a common-length prefix of path parts, which incorrectly reported overlaps for sibling paths sharing a directory (e.g. /a/b/c and /a/b/d both report True). The fix only returns True when one path is a proper prefix of the other by comparing the shorter path's parts against the same-length prefix of the longer path.
This commit is contained in:
parent
78fa758451
commit
399dc3aa74
1 changed files with 3 additions and 2 deletions
|
|
@ -332,8 +332,9 @@ def _paths_overlap(left: Path, right: Path) -> bool:
|
||||||
if not left_parts or not right_parts:
|
if not left_parts or not right_parts:
|
||||||
# Empty paths shouldn't reach here (guarded upstream), but be safe.
|
# Empty paths shouldn't reach here (guarded upstream), but be safe.
|
||||||
return bool(left_parts) == bool(right_parts) and bool(left_parts)
|
return bool(left_parts) == bool(right_parts) and bool(left_parts)
|
||||||
common_len = min(len(left_parts), len(right_parts))
|
if len(left_parts) < len(right_parts):
|
||||||
return left_parts[:common_len] == right_parts[:common_len]
|
return left_parts == right_parts[:len(left_parts)]
|
||||||
|
return right_parts == left_parts[:len(right_parts)]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue