From 115e37a9fefc39b75956f60622843c5cbfe069dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lison=20Fernandes?= Date: Mon, 17 Nov 2025 22:23:51 +0000 Subject: [PATCH] Remove consecutive spaces after removing patterns --- .../release-notes/process_release_notes.py | 22 ++++++++++++------- .../test_process_release_notes.py | 17 +++++++------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.github/scripts/release-notes/process_release_notes.py b/.github/scripts/release-notes/process_release_notes.py index c74b19fc04..9370128594 100644 --- a/.github/scripts/release-notes/process_release_notes.py +++ b/.github/scripts/release-notes/process_release_notes.py @@ -48,24 +48,30 @@ def process_line(line: str) -> str: # Remove keywords and their variations patterns = [ - r'BACKPORT', # BACKPORT -> "" - r'[deps]:', # [deps]: -> "" - r'feat(?:\([^)]*\))?:', # feat: or feat(ui): -> "" - r'bug(?:\([^)]*\))?:', # bug: or bug(core): -> "" - r'ci(?:\([^)]*\))?:' # ci: or ci(workflow): -> "" + r'🍒', # 🍒 -> "" + r'BACKPORT', # BACKPORT -> "" + r'[deps]:', # [deps]: -> "" + r'feat(?:\([^)]*\))?:', # feat: or feat(ui): -> "" + r'bug(?:\([^)]*\))?:', # bug: or bug(core): -> "" + r'ci(?:\([^)]*\))?:' # ci: or ci(workflow): -> "" ] for pattern in patterns: line = re.sub(pattern, '', line) + # Replace multiple consecutive spaces with a single space + line = re.sub(r'\s+', ' ', line) + cleaned = line.strip() - if cleaned != original.strip(): - print(f"Processed: {original.strip()} -> {cleaned}") + original_stripped = original.strip() + if cleaned != original_stripped: + print(f"Processed: {original_stripped} -> {cleaned}") return cleaned -def process_file(input_file: str) -> Tuple[List[str], List[str], List[str]]: +def process_file(input_file: str, app_label: str) -> Tuple[List[str], List[str], List[str]]: jira_tickets: List[str] = [] pr_numbers: List[str] = [] processed_lines: List[str] = [] + #community_highlights: List[str] = [] print("Processing file: ", input_file) diff --git a/.github/scripts/release-notes/test_process_release_notes.py b/.github/scripts/release-notes/test_process_release_notes.py index 6c0600fe82..c8f80df572 100644 --- a/.github/scripts/release-notes/test_process_release_notes.py +++ b/.github/scripts/release-notes/test_process_release_notes.py @@ -37,14 +37,15 @@ class TestProcessReleaseNotes(unittest.TestCase): def test_process_line(self): test_cases = [ - ("* [ABC-123] BACKPORT Some text", "Some text"), - ("* DEF-456: feat(component): Some text", "Some text"), - ("* GHI-789 - bug(fix): Some text", "Some text"), - ("* ci: Some text", "Some text"), - ("* ci(workflow): Some text", "Some text"), - ("* feat: Direct feature", "Direct feature"), - ("* bug: Simple bugfix", "Simple bugfix"), - ("* Normal text", "Normal text") + ("* [ABC-123] BACKPORT Some text", "* Some text"), + ("* DEF-456: feat(component): Some text", "* Some text"), + ("* GHI-789 - bug(fix): Some text", "* Some text"), + ("* ci: Some text", "* Some text"), + ("* ci(workflow): Some text", "* Some text"), + ("* feat: Direct feature", "* Direct feature"), + ("* bug: Simple bugfix", "* Simple bugfix"), + ("* Normal text", "* Normal text"), + ("* 🍒 Cherry picked PR", "* Cherry picked PR"), ] for input_text, expected in test_cases: with self.subTest(input_text=input_text):