diff mbox series

[2/2] set_versions.py: fix get_latest_tag and milestone tags

Message ID 20260402-set-versions-fixes-v1-2-0609a8747b96@bootlin.com
State New
Headers show
Series set_versions.py fixes | expand

Commit Message

Antonin Godard April 2, 2026, 8:13 a.m. UTC
Milestone tags have a different format, e.g. 6.0_M1. This was breaking
this algorithm with:

  File ".../yocto-docs/documentation/./set_versions.py", line 277, in get_latest_tag
    branch_versions = sorted(
        [v.replace("yocto-" + release_series[branch] + ".", "")
         .replace("yocto-" + release_series[branch], "0") for v in branch_versions],
        key=int)
ValueError: invalid literal for int() with base 10: '0_M1'

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 documentation/set_versions.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/documentation/set_versions.py b/documentation/set_versions.py
index 465204998..375f96d99 100755
--- a/documentation/set_versions.py
+++ b/documentation/set_versions.py
@@ -274,9 +274,13 @@  def get_latest_tag(branch: str) -> str:
     branch_versions = subprocess.run(["git", "tag", "--list", f'yocto-{release_series[branch]}*'],
                                      stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                                      universal_newlines=True).stdout.split()
+    # Sort the branches as integers
+    # On milestone tags (e.g. 6.0_M2), remove everything after "_" (including
+    # "_")
     branch_versions = sorted(
         [v.replace("yocto-" + release_series[branch] + ".", "")
-         .replace("yocto-" + release_series[branch], "0") for v in branch_versions],
+         .replace("yocto-" + release_series[branch], "0")
+         .split("_")[0] for v in branch_versions],
         key=int)
     if not branch_versions:
         return ""