@@ -357,6 +357,38 @@ def find_all_providers_affected(
357
357
return sorted (all_providers )
358
358
359
359
360
+ def _match_files_with_regexps (files : tuple [str , ...], matched_files , matching_regexps ):
361
+ for file in files :
362
+ if any (re .match (regexp , file ) for regexp in matching_regexps ):
363
+ matched_files .append (file )
364
+
365
+
366
+ def _exclude_files_with_regexps (files : tuple [str , ...], matched_files , exclude_regexps ):
367
+ for file in files :
368
+ if any (re .match (regexp , file ) for regexp in exclude_regexps ):
369
+ if file in matched_files :
370
+ matched_files .remove (file )
371
+
372
+
373
+ @lru_cache (maxsize = None )
374
+ def _matching_files (
375
+ files : tuple [str , ...], match_group : FileGroupForCi , match_dict : HashableDict , exclude_dict : HashableDict
376
+ ) -> list [str ]:
377
+ matched_files : list [str ] = []
378
+ match_regexps = match_dict [match_group ]
379
+ excluded_regexps = exclude_dict .get (match_group )
380
+ _match_files_with_regexps (files , matched_files , match_regexps )
381
+ if excluded_regexps :
382
+ _exclude_files_with_regexps (files , matched_files , excluded_regexps )
383
+ count = len (matched_files )
384
+ if count > 0 :
385
+ get_console ().print (f"[warning]{ match_group } matched { count } files.[/]" )
386
+ get_console ().print (matched_files )
387
+ else :
388
+ get_console ().print (f"[warning]{ match_group } did not match any file.[/]" )
389
+ return matched_files
390
+
391
+
360
392
class SelectiveChecks :
361
393
__HASHABLE_FIELDS = {"_files" , "_default_branch" , "_commit_ref" , "_pr_labels" , "_github_event" }
362
394
@@ -588,34 +620,10 @@ def kubernetes_combos_list_as_string(self) -> str:
588
620
)
589
621
return " " .join (short_combo_titles )
590
622
591
- def _match_files_with_regexps (self , matched_files , matching_regexps ):
592
- for file in self ._files :
593
- if any (re .match (regexp , file ) for regexp in matching_regexps ):
594
- matched_files .append (file )
595
-
596
- def _exclude_files_with_regexps (self , matched_files , exclude_regexps ):
597
- for file in self ._files :
598
- if any (re .match (regexp , file ) for regexp in exclude_regexps ):
599
- if file in matched_files :
600
- matched_files .remove (file )
601
-
602
- @lru_cache (maxsize = None )
603
623
def _matching_files (
604
- self , match_group : T , match_dict : dict [ T , list [ str ]], exclude_dict : dict [ T , list [ str ]]
624
+ self , match_group : FileGroupForCi , match_dict : HashableDict , exclude_dict : HashableDict
605
625
) -> list [str ]:
606
- matched_files : list [str ] = []
607
- match_regexps = match_dict [match_group ]
608
- excluded_regexps = exclude_dict .get (match_group )
609
- self ._match_files_with_regexps (matched_files , match_regexps )
610
- if excluded_regexps :
611
- self ._exclude_files_with_regexps (matched_files , excluded_regexps )
612
- count = len (matched_files )
613
- if count > 0 :
614
- get_console ().print (f"[warning]{ match_group } matched { count } files.[/]" )
615
- get_console ().print (matched_files )
616
- else :
617
- get_console ().print (f"[warning]{ match_group } did not match any file.[/]" )
618
- return matched_files
626
+ return _matching_files (self ._files , match_group , match_dict , exclude_dict )
619
627
620
628
def _should_be_run (self , source_area : FileGroupForCi ) -> bool :
621
629
if self .full_tests_needed :
0 commit comments