Skip to content

Commit a0422f3

Browse files
otykierclaude
andauthored
Fix latest release notes redirect for four-part versions (#401)
find_latest_release_notes only matched {major}_{minor}_{patch}.html, so 3_27_0_0.html was ignored and /references/release-notes redirected to 3.26.3. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a7366ac commit a0422f3

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

‎build_scripts/gen_staticwebapp_config.py‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def find_latest_release_notes(site_dir: str = "_site", default_lang: str = "en")
125125
"""Find the filename of the latest versioned release notes in the built site.
126126
127127
Scans {site_dir}/{default_lang}/references/release-notes/ for files matching
128-
the pattern {major}_{minor}_{patch}.html, sorts them by semantic version,
128+
the pattern {major}_{minor}_{patch}[_{build}].html, sorts them by semantic version,
129129
and returns the filename of the newest one (e.g. '3_25_5.html').
130130
Returns None if the directory doesn't exist or contains no versioned files.
131131
"""
@@ -134,13 +134,12 @@ def find_latest_release_notes(site_dir: str = "_site", default_lang: str = "en")
134134
if not release_notes_dir.exists():
135135
return None
136136

137-
version_pattern = re.compile(r"^(\d+)_(\d+)_(\d+)\.html$")
138-
versioned: list[tuple[tuple[int, int, int], str]] = []
137+
version_pattern = re.compile(r"^\d+(?:_\d+){2,3}\.html$")
138+
versioned: list[tuple[tuple[int, ...], str]] = []
139139

140140
for html_file in release_notes_dir.glob("*.html"):
141-
m = version_pattern.match(html_file.name)
142-
if m:
143-
version = (int(m.group(1)), int(m.group(2)), int(m.group(3)))
141+
if version_pattern.match(html_file.name):
142+
version = tuple(int(p) for p in html_file.stem.split("_"))
144143
versioned.append((version, html_file.name))
145144

146145
if not versioned:

0 commit comments

Comments
 (0)