Skip to content

Commit 9230833

Browse files
committed
fix(pre-push-review): support optional bold and hyphen/space in fingerprint regex
1 parent 3eb378f commit 9230833

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎scripts/pre-push-review.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def extract_section(text, header_pattern):
384384

385385
# Verify Reviewed-Commit fingerprint if expected SHA provided
386386
if expected_commit_sha:
387-
all_shas = re.findall(r"(?i)Reviewed-Commit:\s*([a-f0-9A-F]+)", unfenced_report)
387+
all_shas = re.findall(r"(?im)^\*{0,2}Reviewed[- ]Commit\*{0,2}[ \t]*:[ \t]*([a-f0-9A-F]+)", unfenced_report)
388388
if not all_shas:
389389
return False, False, f"Missing required 'Reviewed-Commit: {expected_commit_sha[:8]}' fingerprint."
390390
exp_sha = expected_commit_sha.lower()
@@ -403,7 +403,10 @@ def extract_section(text, header_pattern):
403403
# timeout, so the guard hung rather than failing. It was redundant as
404404
# well: `\s*\Z` below already reaches the same strings with zero
405405
# iterations of the group.
406-
if not re.search(r"(?i)Reviewed-Commit:\s*[a-f0-9A-F]+(?:\s*(?:_?Posted by[^\n]+|={3,}|Status:[^\n]+|\*\*Stopping Point\*\*:[^\n]+|(?:###\s*)?(?:Summary\s+)?Verdict:[^\n]+))*\s*\Z", unfenced_report):
406+
if not re.search(
407+
r"(?im)^\*{0,2}Reviewed[- ]Commit\*{0,2}[ \t]*:[ \t]*[a-f0-9A-F]+(?:\s*(?:_?Posted by[^\n]+|={3,}|Status:[^\n]+|\*\*Stopping Point\*\*:[^\n]+|(?:###\s*)?(?:Summary\s+)?Verdict:[^\n]+))*\s*\Z",
408+
unfenced_report,
409+
):
407410
return False, False, "Reviewed-Commit fingerprint must be at the very end of the report."
408411

409412
verdict_matches = re.findall(r"(?im)^(?:###\s*)?(?:Summary\s+)?Verdict:\s*(.+)$", summary_text)

0 commit comments

Comments
 (0)