Skip to content

Commit 9bf2e64

Browse files
authored
Remove duplicate Previous Stable headers (#83)
If you look at the commit in d5728f9, notice that `Previous Stable` has been duplicated for `latest` releases. Tweaked extraction/combination logic to fix.
1 parent df51433 commit 9bf2e64

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

.github/python/add-release/add_release.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,30 @@ def update_hazelcast_metadata(
109109

110110
# Assume the first "version"
111111
content = file_path.read_text()
112-
current_stable_section = content.split(current_stable_header, 1)[1].split(
113-
previous_stable_header
114-
)[0]
112+
current_stable_section = (
113+
content.split(current_stable_header, 1)[1]
114+
.split("---" + os.linesep + previous_stable_header + os.linesep, 1)[0]
115+
.strip()
116+
)
115117
latest = is_latest(version_metadata.version, current_stable_section)
116118
logging.debug("latest=%s", latest)
117119

118120
if latest:
119121
# Example - https://github.com/hazelcast/rel-scripts/commit/d5728f98dc00da5e54455f41fbe1583768a11803
120-
# Demote current stable -> previous stable
121-
content = content.replace(current_stable_header, previous_stable_header, 1)
122-
# Prepend new current stable
122+
# Extract previous block(s)
123+
previous_stable_section = content.split(
124+
"---" + os.linesep + previous_stable_header + os.linesep, 1
125+
)[1]
126+
# Update sequence
123127
content = os.linesep.join(
124-
[current_stable_header, version_block, "---", content]
128+
[
129+
current_stable_header,
130+
version_block,
131+
"---",
132+
previous_stable_header,
133+
current_stable_section,
134+
previous_stable_section,
135+
]
125136
)
126137
file_path.write_text(content)
127138
else:

.github/python/add-release/tests/test_add_release.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ def test_update_hazelcast_metadata_latest_demotes_current_stable(tmp_path):
6161
previous_stable_header = header + "Previous Stable"
6262
content = (
6363
f"{current_stable_header}\n"
64-
"---\nVersion: 5.3.0\n"
64+
"---\n"
65+
"Version: 5.3.0\n"
66+
"---\n"
6567
f"{previous_stable_header}\n"
6668
"---\nVersion: 5.2.0\n"
6769
)
@@ -84,7 +86,9 @@ def test_update_hazelcast_metadata_not_latest_inserts_under_previous(tmp_path):
8486
current_stable_header = header + "Current Stable"
8587
content = (
8688
f"{current_stable_header}\n"
87-
"---\nVersion: 5.4.0\n"
89+
"---\n"
90+
"Version: 5.4.0\n"
91+
"---\n"
8892
f"{previous_stable_header}\n"
8993
"---\nVersion: 5.3.0\n"
9094
)

0 commit comments

Comments
 (0)