Bugzilla – Attachment 186792 Details for
Bug 40858
t/00-merge-conflict-markers.t should only test files part of git repo
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40858: Search merge conflict on files part of the git index
Bug-40858-Search-merge-conflict-on-files-part-of-t.patch (text/plain), 4.53 KB, created by
Lucas Gass (lukeg)
on 2025-09-23 12:11:48 UTC
(
hide
)
Description:
Bug 40858: Search merge conflict on files part of the git index
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-09-23 12:11:48 UTC
Size:
4.53 KB
patch
obsolete
>From 40726bbdd98f31c262df4d6994b56fddec3beebd Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 23 Sep 2025 10:22:15 +0200 >Subject: [PATCH] Bug 40858: Search merge conflict on files part of the git > index > >Same as bug 34303 and bug 33743, our test suite must parse/process files >that are part of the index, not all the other files. > >It's currently failing on kohadev-db-request.txt that is owned by root. >But it's not part of the Koha codebase, this file should not be tested. > >There were also node_modules and po files that were processed. > >Test plan: > prove t/00-merge-conflict-markers.t >must now return gren > >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >--- > Koha/Devel/Files.pm | 32 ++++++++++++++++++--- > t/00-merge-conflict-markers.t | 53 +++++++++++------------------------ > 2 files changed, 45 insertions(+), 40 deletions(-) > >diff --git a/Koha/Devel/Files.pm b/Koha/Devel/Files.pm >index 0fc5b2ec258..8ca8cc5cec9 100644 >--- a/Koha/Devel/Files.pm >+++ b/Koha/Devel/Files.pm >@@ -132,10 +132,18 @@ Builds a Git exclude pattern for a given file type based on the context provided > =cut > > sub build_git_exclude { >- my ( $self, $filetype ) = @_; >- return $self->{context} && exists $exceptions->{$filetype}->{ $self->{context} } >- ? join( " ", map( "':(exclude)$_'", @{ $exceptions->{$filetype}->{ $self->{context} } } ) ) >- : q{}; >+ my ( $self, $filetype, $extensions ) = @_; >+ my $exclude_list = q{}; >+ if ($filetype) { >+ $exclude_list .= >+ $self->{context} && exists $exceptions->{$filetype}->{ $self->{context} } >+ ? join( " ", map( "':(exclude)$_'", @{ $exceptions->{$filetype}->{ $self->{context} } } ) ) >+ : q{}; >+ } >+ if ($extensions) { >+ $exclude_list .= join( " ", map( "':(exclude)*.$_'", @$extensions ) ); >+ } >+ return $exclude_list; > } > > =head2 ls_perl_files >@@ -219,6 +227,22 @@ sub ls_css_files { > return @files; > } > >+=head2 ls_all_files >+ >+ my @files = $file_manager->ls_all_files([$extension_list_to_exclude]); >+ >+Lists all files in the repository. Accept a list of extension to exclude. >+ >+=cut >+ >+sub ls_all_files { >+ my ( $self, $extensions ) = @_; >+ my $cmd = sprintf q{git ls-files %s}, $self->build_git_exclude( undef, $extensions ); >+ my @files = qx{$cmd}; >+ chomp for @files; >+ return @files; >+} >+ > =head2 get_filetype > > my $filetype = $file_manager->get_filetype($filename); >diff --git a/t/00-merge-conflict-markers.t b/t/00-merge-conflict-markers.t >index dbfecbc04df..ad02e706477 100755 >--- a/t/00-merge-conflict-markers.t >+++ b/t/00-merge-conflict-markers.t >@@ -16,45 +16,26 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >- >+use Test::More; > use Test::NoWarnings; >-use Test::More tests => 2; >-use File::Spec; >-use File::Find; >-use IO::File; >- >-my @failures; >-find( >- { >- bydepth => 1, >- no_chdir => 1, >- wanted => sub { >- my $file = $_; > >- return if $file =~ /\.(ico|jpg|gif|ogg|pdf|png|psd|swf|zip|.*\~)$/; >- return unless -f $file; >+use Koha::Devel::Files; > >- my @name_parts = File::Spec->splitpath($file); >- my %dirs = map { $_ => 1 } File::Spec->splitdir( $name_parts[1] ); >- return if exists $dirs{'.git'}; >+my $dev_files = Koha::Devel::Files->new( { context => 'full' } ); >+my @files = $dev_files->ls_all_files( [qw(ico jpg gif ogg pdf png psd)] ); > >- my $fh = IO::File->new( $file, 'r' ); >- my $marker_found = 0; >- while ( my $line = <$fh> ) { >+plan tests => scalar @files + 1; > >- # could check for ^=====, but that's often used in text files >- $marker_found++ if $line =~ m|^<<<<<<|; >- $marker_found++ if $line =~ m|^>>>>>>|; >- last if $marker_found; >- } >- close $fh; >- push @failures, $file if $marker_found; >- }, >- }, >- File::Spec->curdir() >-); >+for my $file (@files) { >+ my $has_conflicts; >+ open my $fh, '<', $file or die "Cannot open $file: $!"; >+ while ( my $line = <$fh> ) { > >-is( >- @failures, 0, >- 'Files should not contain merge markers' . ( @failures ? ( ' (' . join( ', ', @failures ) . ' )' ) : '' ) >-); >+ # Could check for ^=====, but that's often used in text files >+ if ( $line =~ /^<<<<<<<|^>>>>>>>/ ) { >+ $has_conflicts = 1; >+ } >+ } >+ ok( !$has_conflicts, "$file should not contain merge conflict markers" ); >+ close $fh; >+} >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40858
:
186777
|
186778
|
186790
|
186791
|
186792
|
186876
|
186877