From 40fcb1fcf389ee7ce39b07ca5b3c0013853bad55 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 12 May 2025 12:35:43 +0200 Subject: [PATCH] Bug 39876: Add context for tidy With this patch we adjust what's needed to make misc/devel/tidy.pl run identically as before Signed-off-by: David Nind --- Koha/Devel/Files.pm | 20 ++++++++++++-------- misc/devel/tidy.pl | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Koha/Devel/Files.pm b/Koha/Devel/Files.pm index 00a721a98b..fb339ef839 100644 --- a/Koha/Devel/Files.pm +++ b/Koha/Devel/Files.pm @@ -30,11 +30,13 @@ The module defines a set of exceptions for different file types and contexts. Th =cut my $exceptions = { - pl => [qw(Koha/Schema/Result Koha/Schema.pm)], - js => [ - qw(koha-tmpl/intranet-tmpl/lib koha-tmpl/intranet-tmpl/js/Gettext.js koha-tmpl/opac-tmpl/lib Koha/ILL/Backend/) - ], - tt => [qw(Koha/ILL/Backend/ *doc-head-open.inc misc/cronjobs/rss)], + pl => { tidy => [qw(Koha/Schema/Result Koha/Schema.pm)] }, + js => { + tidy => [ + qw(koha-tmpl/intranet-tmpl/lib koha-tmpl/intranet-tmpl/js/Gettext.js koha-tmpl/opac-tmpl/lib Koha/ILL/Backend/) + ] + }, + tt => { tidy => [qw(Koha/ILL/Backend/ *doc-head-open.inc misc/cronjobs/rss)] }, }; =head1 METHODS @@ -50,8 +52,8 @@ Creates a new instance of Koha::Devel::Files. The constructor accepts a hash ref =cut sub new { - my ($class) = @_; - my $self = {}; + my ( $class, $args ) = @_; + my $self = { context => $args->{context} }; bless $self, $class; return $self; } @@ -66,7 +68,9 @@ Builds a Git exclude pattern for a given file type based on the context provided sub build_git_exclude { my ( $self, $filetype ) = @_; - return join( " ", map( "':(exclude)$_'", @{ $exceptions->{$filetype} } ) ); + return $self->{context} && exists $exceptions->{$filetype}->{ $self->{context} } + ? join( " ", map( "':(exclude)$_'", @{ $exceptions->{$filetype}->{ $self->{context} } } ) ) + : q{}; } =head2 ls_perl_files diff --git a/misc/devel/tidy.pl b/misc/devel/tidy.pl index ff338528ff..f8829044ee 100755 --- a/misc/devel/tidy.pl +++ b/misc/devel/tidy.pl @@ -36,7 +36,7 @@ pod2usage("--no-write can only be passed with a single file") if $no_write && @f pod2usage("--perl, --js and --tt can only be passed without any other files in parameter") if @files && ( $perl_files || $js_files || $tt_files ); -my $dev_files = Koha::Devel::Files->new; +my $dev_files = Koha::Devel::Files->new( { context => 'tidy' } ); my @original_files = @files; if (@files) { -- 2.39.5