Skip to content
Closed
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
11 changes: 11 additions & 0 deletions scripts/test_triage_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ def test_parses_linked_sha_and_deduplicates_and_excludes_author(self):
self.assertTrue(mc["tested_nvidia"])
self.assertTrue(mc["tested_amd"])

def test_check_starting_with_byte_order_mark_counts(self):
head = "d338db7a8e24aeb0f42c4c96d98bacd651550f29"
rest = f"\nhead: {head[:12]}\nverdict: safe to merge\nhardware / tool: RTX 5090"
comments = [
{"author": "a", "body": "\ufeff\u2229\u2557\u2510merge-check" + rest},
{"author": "b", "body": "\ufeffmerge-check" + rest},
]
mc = tp.parse_merge_checks(comments, "pr_author", head)
self.assertEqual(mc["safe_count"], 2)
self.assertEqual(mc["safe_users"], ["a", "b"])

def test_managed_labels_needs_2nd_check_and_amd_needed(self):
mc = {
"safe_count": 1,
Expand Down
6 changes: 4 additions & 2 deletions scripts/triage_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
# Matches a SHA in `head: abcdef1234` or ``head: [`abcdef1`](url)`` or `head: \`abcdef1\``
HEAD_SHA_RE = re.compile(r"^\s*head\s*:\s*(?:\[?`?([0-9a-fA-F]{7,40})`?\]?)", re.I)
VERDICT_RE = re.compile(r"^\s*verdict\s*:\s*(.+?)\s*$", re.I)
# a leading byte order mark, or its cp437 mojibake "", is not part of the first line
BOM_PREFIX_RE = re.compile("^(?:\\s|\ufeff|\u2229\u2557\u2510)+")

MEMORY_PATHS = (
"crates/xcl/src/gpu/uma.rs",
Expand Down Expand Up @@ -255,7 +257,7 @@ def parse_merge_checks(
"""Parse #3041 merge-check comments for the PR's current head commit.

Matches throny's #3041 parser rules:
- First non-empty line is exactly `merge-check`.
- First non-empty line is exactly `merge-check` (after any leading byte order mark).
- `head:` line carries a >=7-hex prefix of `head_sha` (plain or markdown-linked).
- `verdict:` starts with `safe to merge` or `not yet`.
- PR author's own comments do not count; latest valid check per account wins.
Expand All @@ -268,7 +270,7 @@ def parse_merge_checks(
user = (c.get("author") or "").strip()
if not user or user.lower() == author_low:
continue
body = c.get("body") or ""
body = BOM_PREFIX_RE.sub("", c.get("body") or "")
lines = [ln.strip() for ln in body.splitlines() if ln.strip()]
if not lines or lines[0].lower() != "merge-check":
continue
Expand Down
Loading