Skip to content

Commit 520f683

Browse files
committed
Remove duplicate Previous Stable headers
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 b8f5034 commit 520f683

1 file changed

Lines changed: 18 additions & 7 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:

0 commit comments

Comments
 (0)