post_version.py: fix branch name construction for release candidates
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2870
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Dylan Baker <dylan@pnwbakers.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4929>
diff --git a/bin/post_version.py b/bin/post_version.py
index e05d177..7ba24d8 100755
--- a/bin/post_version.py
+++ b/bin/post_version.py
@@ -37,6 +37,17 @@
return not version.endswith('.0')
+def is_release_candidate(version: str) -> bool:
+ return '-rc' in version
+
+
+def branch_name(version: str) -> str:
+ if is_release_candidate(version):
+ version = version.split('-')[0]
+ (major, minor, _) = version.split('.')
+ return f'{major}.{minor}'
+
+
def update_index(is_point: bool, version: str) -> None:
p = pathlib.Path(__file__).parent.parent / 'docs' / 'index.html'
with p.open('rt') as f:
@@ -89,7 +100,7 @@
with p.open('rt') as f:
tree = html.parse(f)
- base_version = version[:-2]
+ branch = branch_name(version)
old = None
new = None
@@ -100,7 +111,7 @@
break
for td in tr.xpath('./td'):
- if td.text == base_version:
+ if td.text == branch:
old = tr
break