@@ -585,6 +585,21 @@ sub _load_cache ( $self, $cache_file ) {
585
585
return Sereal::read_sereal($cache_file );
586
586
}
587
587
588
+ sub _parse_query_filetype ( $self , $query_filetype ) {
589
+
590
+ return unless defined $query_filetype ;
591
+ return unless length $query_filetype ;
592
+
593
+ my @filetypes = split ( / \s *,\s */ , $query_filetype );
594
+ @filetypes
595
+ = grep { length ($_ ) && m { ^ [a-zA-Z0-9_\-\.\* ]+ $} x } @filetypes ;
596
+
597
+ # ignore rules using '..'
598
+ return if grep {m {\.\.}} @filetypes ;
599
+
600
+ return \@filetypes ;
601
+ }
602
+
588
603
# convert a string of patterns (file to exclude) to a list of git rules to ignore the path
589
604
# t/*, *.md, *.json, *.yaml, *.yml, *.conf, cpanfile, LICENSE, MANIFEST, INSTALL, Changes, Makefile.PL, Build.PL, Copying, *.SKIP, *.ini, README
590
605
sub _parse_ignore_files ( $self , $ignore_files ) {
@@ -653,12 +668,21 @@ sub _get_match_cache(
653
668
}
654
669
655
670
# filter on some type files distro + query filetype
656
- if ( defined $query_filetype
657
- && length $query_filetype
658
- && $query_filetype =~ qr { ^[0-9\.\-\* _a-zA-Z]+$} )
659
- {
660
- # append to the distros search
661
- $git_cmd [-1] .= ' *' . $query_filetype ;
671
+ if ( my $rules = $self -> _parse_query_filetype($query_filetype ) ) {
672
+ my $base_search = $git_cmd [-1];
673
+ my $is_first_rule = 1;
674
+ foreach my $rule (@$rules ) {
675
+
676
+ my $search = $base_search . ' *' . $rule ;
677
+
678
+ if ($is_first_rule ) {
679
+ $git_cmd [-1] = $search ;
680
+ $is_first_rule = 0;
681
+ next ;
682
+ }
683
+
684
+ push @git_cmd , $search ;
685
+ }
662
686
}
663
687
664
688
if ( my $rules = $self -> _parse_ignore_files($ignore_files ) ) {
@@ -868,7 +892,7 @@ sub run_git_cmd_limit ( $self, %opts ) {
868
892
exit 42;
869
893
}
870
894
871
- note " Running in kid command: " . join ( ' ' , @$cmd );
895
+ note " Running in kid command: " . join ( ' ' , ' git ' , @$cmd );
872
896
note " KID is caching to file " , $cache_file ;
873
897
874
898
my $to_cache ;
@@ -898,7 +922,7 @@ sub run_git_cmd_limit ( $self, %opts ) {
898
922
print {$to_cache } END_OF_FILE_MARKER() . qq{ \n } if $cache_file ;
899
923
print {$CW } END_OF_FILE_MARKER() . qq{ \n } if $can_write_to_pipe ;
900
924
note " -- Request finished by kid: $counter lines - "
901
- . join ( ' ' , @$cmd );
925
+ . join ( ' ' , ' git ' , @$cmd );
902
926
exit $? ;
903
927
}
904
928
0 commit comments