fix(mcp): line-anchor conflict scan and worktree scan paths (#272)
Match git conflict markers on whole lines only so decorative equals borders in mcp_discoverability.py no longer false-positive. Scan session worktrees under branches/ without skipping the entire tree when the worktree path contains "branches". Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
@@ -5,6 +5,7 @@ import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
import role_session_router
|
||||
from role_session_router import python_bytes_have_conflict_markers
|
||||
from mcp_server import gitea_route_task_session, gitea_resolve_task_capability
|
||||
|
||||
_HEALTH_SUBPROCESS_TIMEOUT_SEC = 30
|
||||
@@ -80,6 +81,20 @@ class TestMCPHealth(unittest.TestCase):
|
||||
with self.assertRaises(unittest.SkipTest):
|
||||
_health_test_python()
|
||||
|
||||
def test_conflict_marker_helper_ignores_decorative_equals_border(self):
|
||||
sample = b'banner = """\n===========================================\n"""\n'
|
||||
self.assertFalse(python_bytes_have_conflict_markers(sample))
|
||||
|
||||
def test_conflict_marker_helper_detects_real_markers(self):
|
||||
sample = (
|
||||
b"<" * 7 + b" HEAD\n"
|
||||
b"print('hello')\n"
|
||||
b"=" * 7 + b"\n"
|
||||
b"print('world')\n"
|
||||
b">" * 7 + b" main\n"
|
||||
)
|
||||
self.assertTrue(python_bytes_have_conflict_markers(sample))
|
||||
|
||||
def test_startup_conflict_detection(self):
|
||||
# Create a Python file with conflict markers constructed dynamically
|
||||
with open(self.temp_file, "w") as f:
|
||||
|
||||
@@ -204,5 +204,49 @@ class TestRoleSessionRouter(unittest.TestCase):
|
||||
self.assertTrue(complete["complete"])
|
||||
|
||||
|
||||
class TestCheckMidMerge(unittest.TestCase):
|
||||
def test_skip_scan_walk_root_skips_sibling_worktrees_only(self):
|
||||
worktree_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
main_root = os.path.dirname(os.path.dirname(worktree_root))
|
||||
self.assertFalse(
|
||||
role_session_router.skip_python_scan_walk_root(
|
||||
main_root, main_root
|
||||
)
|
||||
)
|
||||
self.assertTrue(
|
||||
role_session_router.skip_python_scan_walk_root(
|
||||
main_root, os.path.join(main_root, "branches", "fix-issue-1")
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
role_session_router.skip_python_scan_walk_root(
|
||||
worktree_root, worktree_root
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
role_session_router.skip_python_scan_walk_root(
|
||||
worktree_root, os.path.join(worktree_root, "tests")
|
||||
)
|
||||
)
|
||||
|
||||
def test_decorative_equals_banner_is_not_mid_merge(self):
|
||||
self.assertFalse(role_session_router.check_mid_merge())
|
||||
|
||||
def test_python_bytes_have_conflict_markers_rejects_decorative_equals(self):
|
||||
banner = b"===========================================\n"
|
||||
self.assertFalse(role_session_router.python_bytes_have_conflict_markers(banner))
|
||||
|
||||
def test_python_bytes_have_conflict_markers_detects_real_markers(self):
|
||||
self.assertTrue(
|
||||
role_session_router.python_bytes_have_conflict_markers(b"<<<<<<< HEAD\n")
|
||||
)
|
||||
self.assertTrue(
|
||||
role_session_router.python_bytes_have_conflict_markers(b"=======\n")
|
||||
)
|
||||
self.assertTrue(
|
||||
role_session_router.python_bytes_have_conflict_markers(b">>>>>>> topic\n")
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user