From a7b7c672e9b53966761e0dada497c59670f45b72 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dylan=20A=C3=AFssi?= <dylan.aissi@collabora.com>
Date: Mon, 15 Jan 2024 17:09:54 +0100
Subject: [PATCH] Don't report missing packages on apt for packages no longer
 in an active Apertis release
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Dashboard goes through all the packages in GitLab and reports
an error if they are not published in apt repositories. Unfortunately,
this behavior does not take into account the fact that packages can
be dropped in a release, so they are no longer published.
To fix that, don't report missing packages on apt for packages no
longer in an active Apertis release.

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

diff --git a/bin/packaging-check-invariants b/bin/packaging-check-invariants
index 87ee138..14f51a0 100755
--- a/bin/packaging-check-invariants
+++ b/bin/packaging-check-invariants
@@ -1043,6 +1043,19 @@ class InvariantChecker:
         if not set(package).intersection({"git", "obs", "published"}):
             return
         if "published" not in package:
+            if package.git.default_branch:
+                default_branch = package.git.default_branch
+                channels = set(package.git.branches).intersection(self.data.channels)
+                active_channels = [
+                    name
+                    for name in channels
+                    if channel_is_active(self.data.channels[name])
+                ]
+                if default_branch not in active_channels:
+                    logging.info(
+                        f"{package.name}: ignoring missing package on apt: no longer in an active Apertis release: {package.git.default_branch}"
+                    )
+                    return
             self.error(package.name, Report.APT_PACKAGE_MISSING)
             return
         if "obs" not in package:
-- 
GitLab