From da9287f715418364fec76e9c8c907e57ceb10c2e Mon Sep 17 00:00:00 2001 From: Bryan Mutai Date: Thu, 31 Jul 2025 18:00:51 +0300 Subject: [PATCH] Refactor issue extraction logic in findIssuesInPR function (#2332) --- extend-awards.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/extend-awards.py b/extend-awards.py index e2252568..a1c18f54 100644 --- a/extend-awards.py +++ b/extend-awards.py @@ -16,14 +16,14 @@ def getIssue(n): return j def findIssuesInPR(j): - p = re.compile('(#|https://github.com/stackernews/stacker.news/issues/)([0-9]+)') + closing_keywords = ['close', 'closes', 'closed', 'fix', 'fixes', 'fixed', 'resolve', 'resolves', 'resolved'] + # Support both #123 and full URL + closing_pattern = re.compile( + r'(?i)\b(' + '|'.join(closing_keywords) + r')\s+(?:#|https://github\.com/stackernews/stacker\.news/issues/)(\d+)' + ) issues = set() - for m in p.finditer(j['title']): - issues.add(m.group(2)) - if not 'body' in j or j['body'] is None: - return - for s in j['body'].split('\n'): - for m in p.finditer(s): + for text in [j.get('title', ''), j.get('body', '') or '']: + for m in closing_pattern.finditer(text): issues.add(m.group(2)) return list(issues)