Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/scripts/check_issue_readiness.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
BUG_LABEL = "bug"
ENHANCEMENT_LABEL = "enhancement"

# Issue-form fields render as `### Label` h3 headings. Match case-insensitively
# and tolerate trailing whitespace/colons. `^###\s+` is specific enough because
# h1/h2 are not produced by issue forms.
HEADING_RE = re.compile(r"(?m)^###\s+(.+?)\s*$")
# Issue-form fields render as `### Label` h3 headings, but free-form issues
# (and issues edited by agents) commonly use `##` h2 headings. Match any
# heading level of two or more hashes case-insensitively and tolerate trailing
# whitespace/colons, so `##` and `###` sections are treated equivalently. A
# bare `#` (single-hash title) is deliberately not matched.
HEADING_RE = re.compile(r"(?m)^#{2,}\s+(.+?)\s*$")

# `_No response_` is what GitHub writes for an empty optional form field.
NO_RESPONSE = "_No response_"
Expand Down
20 changes: 20 additions & 0 deletions tests/cross/test_check_issue_readiness.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ def test_extract_sections_splits_on_headings():
assert sections["beta"] == "\nmore\n"


def test_extract_sections_splits_on_h2_headings():
sections = extract_sections("## Alpha\n\ntext\n\n## Beta\n\nmore\n")
assert sections["alpha"] == "\ntext\n\n"
assert sections["beta"] == "\nmore\n"


def test_enhancement_h2_headings_passes():
body = ENHANCEMENT_READY.replace("### ", "## ")
result = evaluate_readiness(body, ["enhancement"])
assert result.ready is True
assert result.reasons == []


def test_bug_h2_headings_passes():
body = BUG_READY.replace("### ", "## ")
result = evaluate_readiness(body, ["bug"])
assert result.ready is True
assert result.reasons == []


def test_enhancement_ready_passes():
result = evaluate_readiness(ENHANCEMENT_READY, ["enhancement"])
assert result.ready is True
Expand Down
Loading