π OpenHands: AI-Driven Development
fix(ci): keep a section whose first line opens a fenced block (#16814)
MarMar Labs10ec1495b2f6
diff --git a/.github/scripts/check_pr_description.py b/.github/scripts/check_pr_description.pyindex 9930cb23f5..54e1ec7388 100644--- a/.github/scripts/check_pr_description.py+++ b/.github/scripts/check_pr_description.py@@ -41,9 +41,12 @@ MIN_HUMAN_NOTE_CHARS = 20REQUIRED_TEMPLATE_FIELDS: tuple[str, ...] = ("Why", "Summary", "How to Test")HTML_COMMENT_RE = re.compile(r"<!--[\s\S]*?-->")-HEADING_RE = re.compile(r"(?m)^##\s+(.+?)\s*$")-HUMAN_HEADING_RE = re.compile(r"(?im)^\s*HUMAN:\s*$")-AGENT_HEADING_RE = re.compile(r"(?im)^\s*AGENT:\s*$")+HEADING_RE = re.compile(r"(?m)^##[ \t]+(.+?)[ \t]*$")+# `\r?$` rather than `\s*$` for the same reason as HEADING_RE above: these run+# against masked text too, and there is no capture group here to absorb the `\r`+# of a CRLF body, so it has to be matched explicitly.+HUMAN_HEADING_RE = re.compile(r"(?im)^[ \t]*HUMAN:[ \t]*\r?$")+AGENT_HEADING_RE = re.compile(r"(?im)^[ \t]*AGENT:[ \t]*\r?$")# A file counts as frontend code if its path is under one of these prefixes or# has one of these extensions. This mirrors the paths the E2E workflows treat asdiff --git a/.github/scripts/tests/test_pr_description.py b/.github/scripts/tests/test_pr_description.pyindex 0711c124fc..4891578ba8 100644--- a/.github/scripts/tests/test_pr_description.py+++ b/.github/scripts/tests/test_pr_description.py@@ -34,6 +34,24 @@ Describe testing hereassert set(extract_sections(body)) == {"Summary"}+def test_section_opening_with_a_fence_keeps_its_body():+ """Same masked-whitespace trap as the issue checker: `## Test Plan` then a fence."""+ body = """## Summary+Fixes the thing.++## How to Test+```bash+pytest .github/scripts/tests/+```++## Issue Number+Fixes #16553+"""+ sections = extract_sections(body)+ assert "pytest .github/scripts/tests/" in sections["How to Test"]+ assert set(sections) == {"Summary", "How to Test", "Issue Number"}++def test_fenced_heading_does_not_truncate_how_to_test():body = """## How to TestRun the focused checker tests.@@ -296,6 +314,28 @@ AGENT:"""+def test_human_note_opening_with_a_fence_survives():+ """`HUMAN:` then a fence hits the same masked-whitespace trap as the headings.++ The markers have no capture group to absorb a CRLF's `\\r`, so the pattern+ matches it explicitly and both line endings are pinned here.+ """+ body = """## Summary+Fixes it.++HUMAN:+```+I ran this by hand on my laptop and watched it reproduce twice.+```++AGENT:+did the work+"""+ for name, text in (("lf", body), ("crlf", body.replace("\n", "\r\n"))):+ note = extract_human_note(text)+ assert "reproduce twice" in note, name++def test_fenced_human_marker_does_not_supply_the_note():assert extract_human_note(FENCED_TEMPLATE_BODY) == ""