Skip to content

Commit 777af2b

Browse files
committed
[releaser] Fix backport insertion for RST changelog #532
Fix the Unreleased block regex to include content under the header (e.g., 'Work in progress.') when inserting backported bugfix changelog entries. Added a test to assert that unreleased content remains above the newly inserted block. Fixes #532
1 parent f3fc7c2 commit 777af2b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

openwisp_utils/releaser/changelog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def update_changelog_file(changelog_path, new_block, is_port=False):
247247
unreleased_block_regex_str = (
248248
r"^(##\s+(?:Version\s+)?\S+\s+\[Unreleased\](?:.|\n)*?)(?=\n##\s+(?:Version\s+)?|\Z)"
249249
if is_md
250-
else r"^((?:Version\s+)?\S+\s+\[Unreleased\]\n-+(?:.|\n)*?)(?=\n^(?:Version\s+)?\S|\Z)"
250+
else r"^((?:Version\s+)?\S+\s+\[Unreleased\]\n-+(?:.|\n)*?)(?=\n(?:Version\s+)?\d+\.\d+\.\d+\s+\[|\Z)"
251251
)
252252
unreleased_block_regex = re.compile(
253253
unreleased_block_regex_str, re.IGNORECASE | re.MULTILINE

openwisp_utils/releaser/tests/test_changelog.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,10 @@ def test_update_changelog_bugfix_port_flow(mock_file):
280280
"Version 1.2.0 [Unreleased]"
281281
)
282282
assert written_content.find("Version 1.1.3") < written_content.find("Version 1.1.2")
283+
# "Work in progress." text below unreleased header should come before new bugfix block
284+
assert written_content.find("Work in progress.") < written_content.find(
285+
"Version 1.1.3"
286+
)
283287

284288

285289
@patch("builtins.open", new_callable=mock_open, read_data=SAMPLE_CHANGELOG)

0 commit comments

Comments
 (0)