@@ -133,6 +133,9 @@ def __call__(self, parser, namespace, values, option_string=None):
133133
134134 # ... limited to those with an active StableRequest result
135135 pkgdev bugs --find-by-maintainer foo@gentoo.org --filter-stablereqs
136+
137+ # file stablereq bugs for all packages inside category "dev-libs" with an active StableRequest
138+ pkgdev bugs --filter-stablereqs "dev-libs/*"
136139 """ ,
137140)
138141BugzillaApiKey .mangle_argparser (bugs )
@@ -676,6 +679,21 @@ def _find_dependencies(self, pkg: package, keywords: set[str], stable: bool = Tr
676679 )
677680 yield from results .items ()
678681
682+ def _stablereqs (self , pkgset ) -> list [tuple [atom , list [package ]]]:
683+ """The stablereq of every package in the set, as a target of its own."""
684+ per_pkg : dict [str , list [package ]] = defaultdict (list )
685+ for pkg in pkgset :
686+ per_pkg [pkg .key ].append (pkg )
687+
688+ found = []
689+ # the check reads the versions of a single package, so feed one at a time
690+ for pkgs in per_pkg .values ():
691+ for res in self .stablereq_check .feed (sorted (pkgs )):
692+ if isinstance (res , stablereq .StableRequest ):
693+ found .append ((atom (f"={ res .category } /{ res .package } -{ res .version } " ), pkgs ))
694+ break
695+ return found
696+
679697 def load_targets (self , targets : list [tuple [str , object , frozenset [str ]]]):
680698 result = []
681699 search_repo = self .options .search_repo
@@ -684,23 +702,23 @@ def load_targets(self, targets: list[tuple[str, object, frozenset[str]]]):
684702 try :
685703 pkgset = search_repo .match (target )
686704 if self .options .filter_stablereqs :
687- for res in self .stablereq_check .feed (sorted (pkgset )):
688- if isinstance (res , stablereq .StableRequest ):
689- target = atom (f"={ res .category } /{ res .package } -{ res .version } " )
690- break
691- else : # no stablereq
705+ # a target may match many packages, each with its own stablereq
706+ found = self ._stablereqs (pkgset )
707+ else :
708+ found = [(target , pkgset )]
709+
710+ for restrict , candidates in found :
711+ if masked .match (restrict ):
712+ self .err .write (
713+ self .err .fg ("yellow" ),
714+ f"Target { restrict } is masked, skipping" ,
715+ self .err .reset ,
716+ )
692717 continue
693- if masked .match (target ):
694- self .err .write (
695- self .err .fg ("yellow" ),
696- f"Target { target } is masked, skipping" ,
697- self .err .reset ,
698- )
699- continue
700- match = self .find_best_match ([target ], pkgset , False )
701- result .append (match )
702- if arches :
703- self .target_arches [match ] = arches
718+ match = self .find_best_match ([restrict ], candidates , False )
719+ result .append (match )
720+ if arches :
721+ self .target_arches [match ] = arches
704722 except (ValueError , IndexError ):
705723 bugs .error (f"Restriction { target } has no match in repository" , status = 3 )
706724 self .targets = tuple (result )
0 commit comments