mirror of
https://github.com/bitwarden/android.git
synced 2025-12-10 09:56:45 -06:00
Remove consecutive spaces after removing patterns
This commit is contained in:
parent
9e05a07f23
commit
115e37a9fe
@ -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)
|
||||
|
||||
|
||||
@ -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):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user