Bugzilla – Attachment 184789 Details for
Bug 40541
Add new line at the end of the files when missing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40541: Add missing new line at the end of files when missing
Bug-40541-Add-missing-new-line-at-the-end-of-files.patch (text/plain), 2.04 KB, created by
Jonathan Druart
on 2025-07-29 09:55:25 UTC
(
hide
)
Description:
Bug 40541: Add missing new line at the end of files when missing
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-07-29 09:55:25 UTC
Size:
2.04 KB
patch
obsolete
>From 26978cedca336428512ffb16add3ebb81d740895 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 29 Jul 2025 11:53:22 +0200 >Subject: [PATCH] Bug 40541: Add missing new line at the end of files when > missing > >We have insert_final_newline = true to ensure files will contain a new line at the end. >However we have seen commits with "No new line" added in the git log. > >We should have a xt test to prevent more occurrences. > >We should also have a test at the QA script level: https://gitlab.com/koha-community/qa-test-tools/-/issues/96 > >Test plan: > prove xt/find-missing-new-lines-at-the-end-of-file.t >should return green. > >Remove the new line at the end of a file, eg. >vim -b mainpage.pl >:set noeol >:wq > >Now > prove xt/find-missing-new-lines-at-the-end-of-file.t >is failing on mainpage.pl. >--- > ...ind-missing-new-lines-at-the-end-of-file.t | 32 +++++++++++++++++++ > 1 file changed, 32 insertions(+) > create mode 100755 xt/find-missing-new-lines-at-the-end-of-file.t > >diff --git a/xt/find-missing-new-lines-at-the-end-of-file.t b/xt/find-missing-new-lines-at-the-end-of-file.t >new file mode 100755 >index 00000000000..b897acbbd90 >--- /dev/null >+++ b/xt/find-missing-new-lines-at-the-end-of-file.t >@@ -0,0 +1,32 @@ >+#!/usr/bin/perl >+use Modern::Perl; >+use Test::PerlTidy; >+use Test::More; >+use Test::NoWarnings; >+ >+use Koha::Devel::Files; >+ >+my $dev_files = Koha::Devel::Files->new( { context => 'all' } ); >+my @files; >+push @files, $dev_files->ls_perl_files; >+push @files, $dev_files->ls_tt_files; >+push @files, $dev_files->ls_js_files; >+push @files, $dev_files->ls_yml_files; >+push @files, $dev_files->ls_css_files; >+ >+#plan tests => scalar @files + 1; >+plan tests => scalar @files; >+ >+for my $file (@files) { >+ if ( -z $file ) { >+ >+ # File is empty >+ ok(1); >+ next; >+ } >+ open my $fh, '<', $file or die "Can't open file ($file): $!"; >+ seek $fh, -1, 2 or die "Can't seek ($file): $!"; >+ read $fh, my $char, 1; >+ close $fh; >+ is( $char, "\n", "$file should end with a new line" ); >+} >-- >2.34.1
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 40541
:
184789
|
184791
|
184794
|
184807