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 <david@davidnind.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit e7e42c5e88)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Jonathan Druart 2025-05-12 12:35:43 +02:00 committed by Paul Derscheid
parent 87c14156bb
commit 32ccc7b61c
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
2 changed files with 13 additions and 9 deletions

View File

@ -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

View File

@ -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) {