]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
www: mail_diff: add final newline before diffing
authorEric Wong <e@80x24.org>
Tue, 28 Nov 2023 17:37:00 +0000 (17:37 +0000)
committerEric Wong <e@80x24.org>
Wed, 29 Nov 2023 02:13:30 +0000 (02:13 +0000)
This gets rid of the "\ No newline at end of file"
since it's distracting noise.

lib/PublicInbox/MailDiff.pm
t/lei-mail-diff.t
t/psgi_v2.t

index 98284b23a59ed36fd72fef1a13d44b3807d5245f..89284e39c37e536cbef999652a0ad4680395c6ab 100644 (file)
@@ -24,7 +24,7 @@ sub write_part { # Eml->each_part callback
        $s //= $part->body;
        $s =~ s/\r\n/\n/gs; # TODO: consider \r+\n to match View
        $s =~ s/\s*\z//s;
-       write_file '>:utf8', "$self->{curdir}/$idx.$sfx", $s;
+       write_file '>:utf8', "$self->{curdir}/$idx.$sfx", $s, "\n";
 }
 
 # public
index 9398596aba0d25bd6eeee675323fb6e0a047936d..1a896e515d8f11c8c0ee5e5d0b95af521f887a5c 100644 (file)
@@ -7,6 +7,7 @@ test_lei(sub {
        ok(!lei('mail-diff', 't/data/0001.patch', 't/data/binary.patch'),
                'different messages are different');
        like($lei_out, qr/^\+/m, 'diff shown');
+       unlike $lei_out, qr/No newline at end of file/;
        lei_ok('mail-diff', 't/data/0001.patch', 't/data/0001.patch');
        is($lei_out, '', 'no output if identical');
 });
index 5ccaab19964aa8e77d2557899d13113abf2f604b..54faae9b4c60801ddf23e57e5497dddfa1d307c5 100644 (file)
@@ -287,6 +287,7 @@ my $client1 = sub {
                'cr_mismatch is only diff context');
        like($raw, qr!>\-pipe !s, 'pipe diff del line');
        like($raw, qr!>\+pipe !s, 'pipe diff ins line');
+       unlike $raw, qr/No newline at end of file/;
 };
 
 test_psgi(sub { $www->call(@_) }, $client1);