From e91d30f1a76cdd4a5e9a7fb0b896b3e3cb322d15 Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Jun 25 2019 11:21:16 +0000 Subject: [frontend] rather use universal algorithm for both selecting and excluding --- diff --git a/frontend/coprs_frontend/coprs/logic/modules_logic.py b/frontend/coprs_frontend/coprs/logic/modules_logic.py index 6448dc9..a240c5c 100644 --- a/frontend/coprs_frontend/coprs/logic/modules_logic.py +++ b/frontend/coprs_frontend/coprs/logic/modules_logic.py @@ -141,22 +141,21 @@ class ModuleBuildFacade(object): name_release = abbrev.replace("-", "").replace("f", "fedora-") return ["{}-{}".format(name_release, arch) for arch in chroot_archs.get(name_release, [])] - # Either we want to exclude chroots from all those enabled in the project - if any([abbrev.startswith("-") for abbrev in self.platform]): - chroots = {chroot.name for chroot in self.copr.active_chroots} - for abbrev in self.platform: - chroots -= set(abbrev2chroots(abbrev)) - return list(chroots) - - # Or specify the chroots list from scratch - else: - chroots = [] - for abbrev in self.platform: - if abbrev.startswith("-"): - # This shouldn't happen - continue - chroots.extend(abbrev2chroots(abbrev)) - return chroots + exclude_chroots = set() + select_chroots = set() + for abbrev in self.platform: + abbrev_chroots = abbrev2chroots(abbrev) + if not abbrev_chroots: + raise ValidationError("Module platform stream {} doesn't match to any enabled chroots in the {} project" + .format(abbrev, self.copr.full_name)) + (exclude_chroots if abbrev.startswith("-") else select_chroots).update(abbrev_chroots) + + chroots = {chroot.name for chroot in self.copr.active_chroots} + chroots -= exclude_chroots + if select_chroots: + chroots &= select_chroots + return chroots + def add_builds(self, rpms, module): blocked_by_id = None