Skip to content

Commit 88b615b

Browse files
authored
Fix replace_string badge replacements (#296)
Fix version replacement in badge URLs. Noticed in #295: ```diff -[![Maven Central](https://img.shields.io/badge/Maven%20Central-2024.2.0--alpha01-blue)][14] -[![Javadoc](https://img.shields.io/badge/Javadoc-2024.2.0--alpha01-orange)][7] +[![Maven Central](https://img.shields.io/badge/�-2024.2.0--alpha02-�)][14] +[![Javadoc](https://img.shields.io/badge/�-2024.2.0--alpha02-�)][7] ```
1 parent 8c7f5d1 commit 88b615b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

.github/scripts/replace_string.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def replace_string(path: Path, old: str, new: str) -> None:
3737
def _replace_badge_versions(text: str, old: str, new: str) -> str:
3838
return re.sub(
3939
rf'''https://img\.shields\.io/badge/(.+?)-{_badge_version(old)}-(\w+)''',
40-
f'''https://img.shields.io/badge/\1-{_badge_version(new)}-\3''',
40+
rf'''https://img.shields.io/badge/\1-{_badge_version(new)}-\2''',
4141
text
4242
)
4343

.github/scripts/test_replace_string.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _assert_regular_versions_replaced(self, content, old, new):
6464
self.assertNotIn(old, content)
6565

6666
def _assert_badge_versions_replaced(self, content, old, new):
67-
if "badge/Maven%20Central-" not in content:
67+
if "badge/" not in content:
6868
return
6969
self.assertIn(
7070
f"badge/Maven%20Central-{new.replace('-', '--')}-blue", content)

0 commit comments

Comments
 (0)