fix(pr-overlap): bound explicit dependency declarations

This commit is contained in:
MrMha 2026-10-11 18:21:44 +04:00
parent a11c8f7f70
commit 14bbb1e00f
2 changed files with 10 additions and 1 deletions

View File

@ -9,7 +9,7 @@ from urllib.parse import urlencode
PARENT = 'if .parent then "\\(.parent.owner.login)/\\(.parent.name)" else .nameWithOwner end'
EXPORT = re.compile(r"^\+.*\bAPS5_VABI\s+(\w+)\s*\(")
DEPENDS = re.compile(r'Depends on:([^\r\n]*(?:\r?\n[ \t]*[-*][ \t]*#\d+[^\r\n]*)*)')
DEPENDS = re.compile(r'Depends on:[ \t]*((?:#\d+\b(?:(?:[ \t]*,[ \t]*(?:and[ \t]+)?|[ \t]+and[ \t]+)#\d+\b)*|none\b)?(?:\r?\n[ \t]*[-*][ \t]*#\d+\b[^\r\n]*)*)')
PLAIN_DEPENDS = re.compile(r'Depends on[ \t]+(#\d+\b(?:(?:[ \t]*,[ \t]*(?:and[ \t]+)?|[ \t]+and[ \t]+)#\d+\b)*)')
HUNK = re.compile(r"^@@ -(\d+)(?:,(\d+))?", re.M)
MARKER = "<!-- pr-overlap -->"

View File

@ -54,6 +54,15 @@ class DependencyTests(unittest.TestCase):
with self.subTest(body=body):
self.assertEqual(pull_requests(body)[1]["depends"], {2})
def test_colon_declaration_stops_before_unrelated_prose(self):
for body in ("Depends on: #2. Related #3 covers something else.",
"Depends on: #2; related #3 covers something else.",
"Depends on: none; see issue #3.",
"Depends on: #2, related work is in #3."):
with self.subTest(body=body):
expected = set() if "none" in body else {2}
self.assertEqual(pull_requests(body)[1]["depends"], expected)
def test_checklist_declaration_keeps_precedence(self):
for declaration, expected in (("#3", {3}), ("none", set())):
body = "Previously: Depends on #2.\n\n- [x] Depends on: " + declaration