Kill the mutant that strips more than blank lines off a changelog with no section

This commit is contained in:
Lilleman
2026-11-24 14:48:06 +01:00
parent 39cb2f4d9e
commit 3f74d32cae
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -137,7 +137,7 @@ def headed(changelog: str, entries: list[str], named: str) -> str:
added = f"## {named}\n\n" + "\n".join(entries) + "\n"
first = re.search(r"^## ", changelog, flags=re.M)
if first is None:
return changelog.rstrip("\n") + "\n\n" + added
return changelog.rstrip() + "\n\n" + added
return changelog[:first.start()] + added + "\n" + changelog[first.start():]
+1 -1
View File
@@ -619,7 +619,7 @@ class PatchChangelog(unittest.TestCase):
self.assertEqual(patch.headed("# Changelog\n\n## 0.1.0\n\n- First.\n", ["- Fixed.", "- Also."], "0.1.1"), "# Changelog\n\n## 0.1.1\n\n- Fixed.\n- Also.\n\n## 0.1.0\n\n- First.\n")
def test_ends_a_changelog_with_no_section_with_the_patchs_section(self):
self.assertEqual(patch.headed("# Changelog\n\n", ["- Fixed."], "0.1.1"), "# Changelog\n\n## 0.1.1\n\n- Fixed.\n")
self.assertEqual(patch.headed("# Changelog\n\nFor Linux and macOS X\n\n", ["- Fixed."], "0.1.1"), "# Changelog\n\nFor Linux and macOS X\n\n## 0.1.1\n\n- Fixed.\n")
def test_moves_the_patchs_entries_from_unreleased_to_a_section_after_it(self):
changelog = "# Changelog\n\n## Unreleased\n\n- Second.\n- Fixed.\n\n## 0.1.0\n\n- First.\n"