docs: set_versions.py: fix latest release of a branch being shown twice in switchers.js

versions array is supposed to store the latest version of all active
releases. However, in the loop it is reassigned and therefore, the check
on whether our version is already in the versions array will always
return false (except for the latest version of the last active release)
and write our version again in the list.

By using a local variable for the logic instead of versions array, the
check now works properly.

Fixes: f2b069be8c307 "set_versions: Various improvements"
Cc: Quentin Schulz <foss+yocto@0leil.net>
(From yocto-docs rev: 36a088c8c99dd37f5ca07ec8f90f2c51ef8b36f2)

Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Quentin Schulz 2022-04-19 17:30:47 +02:00 committed by Richard Purdie
parent 460012e04a
commit 36ccca5cba

View File

@ -211,13 +211,13 @@ with open("sphinx-static/switchers.js.in", "r") as r, open("sphinx-static/switch
for branch in activereleases: for branch in activereleases:
if branch == devbranch: if branch == devbranch:
continue continue
versions = subprocess.run('git tag --list yocto-%s*' % (release_series[branch]), shell=True, capture_output=True, text=True).stdout.split() branch_versions = subprocess.run('git tag --list yocto-%s*' % (release_series[branch]), shell=True, capture_output=True, text=True).stdout.split()
versions = sorted([v.replace("yocto-" + release_series[branch] + ".", "").replace("yocto-" + release_series[branch], "0") for v in versions], key=int) branch_versions = sorted([v.replace("yocto-" + release_series[branch] + ".", "").replace("yocto-" + release_series[branch], "0") for v in branch_versions], key=int)
if not versions: if not branch_versions:
continue continue
version = release_series[branch] version = release_series[branch]
if versions[-1] != "0": if branch_versions[-1] != "0":
version = version + "." + versions[-1] version = version + "." + branch_versions[-1]
versions.append(version) versions.append(version)
w.write(" '%s': {'title': '%s', 'obsolete': %s,},\n" % (version, version, str(branch == ourseries).lower())) w.write(" '%s': {'title': '%s', 'obsolete': %s,},\n" % (version, version, str(branch == ourseries).lower()))
if ourversion not in versions and ourseries != devbranch: if ourversion not in versions and ourseries != devbranch: