From 2ca53c49a7f28c8115b47092147de80e6b375b11 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 19 Nov 2025 17:06:20 +0000 Subject: [PATCH] Bug 41274: Koha::Devel::Files - Fix exception filtering in incremental mode This patch fixes two bugs in the file exception filtering logic that caused generated files (like Koha/Schema/Result/*) to not be excluded properly when running in incremental/CI mode. Bug #1: Incorrect array assignment Lines 173 and 204 were assigning an arrayref as a single element instead of dereferencing it: my @exception_files = $exceptions->{...}; # Wrong: creates array with 1 element (arrayref) my @exception_files = @{ $exceptions->{...} }; # Correct: dereferences to array Bug #2: Pattern matching not supported array_minus() only performs exact string matches, so patterns like "Koha/Schema/Result" would not match "Koha/Schema/Result/Aqbasket.pm". The fix: - Properly dereferences exception patterns array - Replaces array_minus with grep + regex pattern matching - Uses /^\Q$_\E/ to match file paths starting with exception patterns - Removes now-unused Array::Utils dependency This ensures consistent behavior between: - Non-incremental mode: Uses git ls-files with :(exclude) patterns - Incremental mode: Now uses equivalent pattern matching Test plan: 1. Run tests locally (non-incremental): prove xt/perltidy.t 2. Verify Schema files are excluded 3. Run in CI (incremental mode) with Schema file changes 4. Verify Schema files are now correctly excluded (previously failing) --- Koha/Devel/Files.pm | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Koha/Devel/Files.pm b/Koha/Devel/Files.pm index ae4152b19a4..1840050ff9b 100644 --- a/Koha/Devel/Files.pm +++ b/Koha/Devel/Files.pm @@ -1,7 +1,6 @@ package Koha::Devel::Files; use Modern::Perl; -use Array::Utils qw( array_minus ); =head1 NAME @@ -170,8 +169,13 @@ sub ls_files { push @files, grep { -e && /\.(tt|inc)$/ } @modified_files; } - my @exception_files = $exceptions->{$filetype}->{ $self->{context} }; - @files = array_minus( @files, @exception_files ); + my @exception_patterns = @{ $exceptions->{$filetype}->{ $self->{context} } // [] }; + if (@exception_patterns) { + @files = grep { + my $file = $_; + !grep { $file =~ /^\Q$_\E/ } @exception_patterns + } @files; + } } else { if ( $filetype eq 'pl' ) { @files = $self->ls_perl_files; @@ -201,8 +205,13 @@ sub ls_perl_files { chomp @modified_files; push @files, grep { -e && /\.(pl|PL|pm|t)$/ } @modified_files; push @files, grep { -e && /^(svc|opac\/svc)/ } @modified_files; - my @exception_files = $exceptions->{pl}->{ $self->{context} }; - @files = array_minus( @files, @exception_files ); + my @exception_patterns = @{ $exceptions->{pl}->{ $self->{context} } // [] }; + if (@exception_patterns) { + @files = grep { + my $file = $_; + !grep { $file =~ /^\Q$_\E/ } @exception_patterns + } @files; + } } else { my $cmd = sprintf q{git ls-files '*.pl' '*.PL' '*.pm' '*.t' svc opac/svc opac/unapi debian/build-git-snapshot %s}, -- 2.51.1