Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e5ca5a88f | ||
|
|
e7f8e4ac66 |
+4
-2
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
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
|
## [0.2.0] - 2026-06-21
|
||||||
|
|
||||||
|
|||||||
+8
-3
@@ -138,10 +138,15 @@ def update_init_version(new_version: str) -> None:
|
|||||||
def update_changelog(changelog: str) -> None:
|
def update_changelog(changelog: str) -> None:
|
||||||
"""Prepend the new changelog section to CHANGELOG.md.
|
"""Prepend the new changelog section to CHANGELOG.md.
|
||||||
|
|
||||||
If the file doesn't exist, create it with the changelog as the sole content.
|
The changelog from git-cliff may include a header (e.g., "# Changelog").
|
||||||
If it exists, insert the new version section after the header (before the
|
This function strips everything before the first ``## [`` version section
|
||||||
first existing 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:
|
try:
|
||||||
with open(CHANGELOG_FILE) as f:
|
with open(CHANGELOG_FILE) as f:
|
||||||
existing = f.read()
|
existing = f.read()
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
"""Gitea Runner Manager — lean CLI for managing Gitea Actions runners."""
|
"""Gitea Runner Manager — lean CLI for managing Gitea Actions runners."""
|
||||||
|
|
||||||
__version__ = "0.2.0"
|
__version__ = "0.2.1"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class TestCLI:
|
|||||||
runner = CliRunner()
|
runner = CliRunner()
|
||||||
result = runner.invoke(cli, ["--version"])
|
result = runner.invoke(cli, ["--version"])
|
||||||
assert result.exit_code == 0
|
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")
|
@patch("gitea_runner_manager.cli.RunnerManager")
|
||||||
def test_install(self, mock_manager_class: MagicMock) -> None:
|
def test_install(self, mock_manager_class: MagicMock) -> None:
|
||||||
|
|||||||
@@ -186,6 +186,30 @@ class TestUpdateChangelog:
|
|||||||
assert "Some intro text" in content
|
assert "Some intro text" in content
|
||||||
assert "## [0.2.0]" 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:
|
class TestCommitReleaseChanges:
|
||||||
@patch("scripts.release.run_cmd")
|
@patch("scripts.release.run_cmd")
|
||||||
|
|||||||
Reference in New Issue
Block a user