Remove consecutive spaces after removing patterns

This commit is contained in:
Álison Fernandes 2025-11-17 22:23:51 +00:00
parent 9e05a07f23
commit 115e37a9fe
No known key found for this signature in database
GPG Key ID: B8CE98903DFC87BC
2 changed files with 23 additions and 16 deletions

View File

@ -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)

View File

@ -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):