From 9097fe04718a83fd9cb853ec4ed39a2787346fb9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dylan=20A=C3=AFssi?= <dylan.aissi@collabora.com>
Date: Fri, 15 Mar 2024 15:11:04 +0100
Subject: [PATCH] updates-upstream-linux: check detected version before trying
 to use it
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Just after adding apertis/v202*-security and -updates branches to be
tracked by the dashboard, the returned version is "None" because the
cache file is not yet updated. This "None" value makes the pipeline
failing with:

Traceback (most recent call last):
  File "/builds/infrastructure/dashboard/./bin/packaging-updates-upstream-linux", line 209, in <module>
    results = compute_linux_updates(data)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builds/infrastructure/dashboard/./bin/packaging-updates-upstream-linux", line 134, in compute_linux_updates
    process = subprocess.run(
              ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', '-c', 'versionsort.suffix=-', 'ls-remote', '--exit-code', '--tags', '--refs', '--sort=version:refname', 'https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git', 'vNone*']' returned non-zero exit status 2.

To avoid failures, just skip this branch for this iteration.

Signed-off-by: Dylan Aïssi <dylan.aissi@collabora.com>
---
 bin/packaging-updates-upstream-linux | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/bin/packaging-updates-upstream-linux b/bin/packaging-updates-upstream-linux
index 2002887..4663444 100755
--- a/bin/packaging-updates-upstream-linux
+++ b/bin/packaging-updates-upstream-linux
@@ -88,6 +88,9 @@ def compute_linux_updates(data):
     logging.debug(f"{release_to_debian=}")
 
     for branch, version in branch_versions.items():
+        if version is None:
+            logging.warning(f"{branch}: no version found")
+            continue
         # Fetch the downstream linux version
         # If the version is 5.4.134-0~apertis2, the downstream tag is 5.4
         downstream_release = release_major_minor(version)
-- 
GitLab