diff --git a/scripts/test_triage_pr.py b/scripts/test_triage_pr.py index 59fdd272e0..1877e5d0dd 100644 --- a/scripts/test_triage_pr.py +++ b/scripts/test_triage_pr.py @@ -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, diff --git a/scripts/triage_pr.py b/scripts/triage_pr.py index f2c469e986..5fa8dd5260 100644 --- a/scripts/triage_pr.py +++ b/scripts/triage_pr.py @@ -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", @@ -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. @@ -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