Compare commits

..
2 Commits
Author SHA1 Message Date
grm-ci-bot 2e5ca5a88f release: v0.2.1
Publish Release / publish (push) Failing after 25s
2026-06-21 19:53:32 +02:00
emil e7f8e4ac66 GRM-35: fix: strip git-cliff header from CHANGELOG.md updates
The update_changelog function now strips the git-cliff header before inserting into CHANGELOG.md, preventing duplicate headers.

Closes GRM-35
2026-06-21 17:53:18 +00:00
5 changed files with 38 additions and 7 deletions
+4 -2
View File
@@ -2,9 +2,11 @@
All notable changes to this project will be documented in this file.
# Changelog
## [0.2.1] - 2026-06-21
All notable changes to this project will be documented in this file.
### Bug Fixes
- Strip git-cliff header from CHANGELOG.md updates
## [0.2.0] - 2026-06-21
+8 -3
View File
@@ -138,10 +138,15 @@ def update_init_version(new_version: str) -> None:
def update_changelog(changelog: str) -> None:
"""Prepend the new changelog section to CHANGELOG.md.
If the file doesn't exist, create it with the changelog as the sole content.
If it exists, insert the new version section after the header (before the
first existing version section).
The changelog from git-cliff may include a header (e.g., "# Changelog").
This function strips everything before the first ``## [`` version section
before inserting, to avoid duplicating the header.
"""
# Strip git-cliff header — keep only from the first version section
section_match = re.search(r"^## \[", changelog, flags=re.MULTILINE)
if section_match:
changelog = changelog[section_match.start() :]
try:
with open(CHANGELOG_FILE) as f:
existing = f.read()
+1 -1
View File
@@ -1,3 +1,3 @@
"""Gitea Runner Manager — lean CLI for managing Gitea Actions runners."""
__version__ = "0.2.0"
__version__ = "0.2.1"
+1 -1
View File
@@ -12,7 +12,7 @@ class TestCLI:
runner = CliRunner()
result = runner.invoke(cli, ["--version"])
assert result.exit_code == 0
assert "0.1.0" in result.output
assert "0.2.0" in result.output
@patch("gitea_runner_manager.cli.RunnerManager")
def test_install(self, mock_manager_class: MagicMock) -> None:
+24
View File
@@ -186,6 +186,30 @@ class TestUpdateChangelog:
assert "Some intro text" in content
assert "## [0.2.0]" in content
def test_strips_git_cliff_header(self, tmp_path, monkeypatch) -> None:
"""git-cliff output includes a header — should be stripped before inserting."""
changelog_file = tmp_path / "CHANGELOG.md"
changelog_file.write_text("# Changelog\n\n## [0.1.0] - 2026-06-20\n\n### Features\n- old thing\n")
monkeypatch.setattr("scripts.release.CHANGELOG_FILE", str(changelog_file))
# Simulate git-cliff output with header
cliff_output = "# Changelog\n\nAll notable changes...\n\n## [0.2.0] - 2026-06-21\n\n### Features\n- new thing"
update_changelog(cliff_output)
content = changelog_file.read_text()
# Header should appear only once (from the existing file)
assert content.count("# Changelog") == 1
assert "## [0.2.0]" in content
assert "new thing" in content
def test_strips_header_when_creating_new_file(self, tmp_path, monkeypatch) -> None:
"""When creating a new file, strip the git-cliff header."""
changelog_file = tmp_path / "CHANGELOG.md"
monkeypatch.setattr("scripts.release.CHANGELOG_FILE", str(changelog_file))
cliff_output = "# Changelog\n\nAll notable changes...\n\n## [0.2.0] - 2026-06-21\n\n### Features\n- new thing"
update_changelog(cliff_output)
content = changelog_file.read_text()
assert "# Changelog" not in content
assert "## [0.2.0]" in content
class TestCommitReleaseChanges:
@patch("scripts.release.run_cmd")