Return (cleaned_title, links) where links list unique JIRA issues found in title.
(title)
| 245 | |
| 246 | |
| 247 | def extract_jira_issues_from_title(title): |
| 248 | """Return (cleaned_title, links) where links list unique JIRA issues found in title.""" |
| 249 | jira = re.compile(r'(?:SOLR|LUCENE|INFRA)-\d+') |
| 250 | |
| 251 | seen = set() |
| 252 | links = [ |
| 253 | {'name': m, 'url': f'https://issues.apache.org/jira/browse/{m}'} |
| 254 | for m in jira.findall(title) |
| 255 | if not (m in seen or seen.add(m)) |
| 256 | ] |
| 257 | |
| 258 | cleaned = title |
| 259 | # Remove variants at start or when slash-separated, then normalize whitespace |
| 260 | cleaned = re.sub(r'^\s*/\s*' + jira.pattern + r'[\s:]*', '', cleaned) |
| 261 | cleaned = re.sub(r'\s+/\s*' + jira.pattern + r'[\s:]*', ' ', cleaned) |
| 262 | cleaned = re.sub(r'^' + jira.pattern + r'[\s:]*', '', cleaned) |
| 263 | cleaned = re.sub(r'^\s*/\s*', '', cleaned).strip() |
| 264 | cleaned = re.sub(r'\s+', ' ', cleaned) |
| 265 | |
| 266 | return cleaned, links |
| 267 | |
| 268 | |
| 269 | if __name__ == '__main__': |
no test coverage detected
searching dependent graphs…