View | Details | Raw Unified | Return to bug 41634
Collapse All | Expand All

(-)a/.podtidyrc (+3 lines)
Line 0 Link Here
1
--columns=120
2
--indent=4
3
--quiet
(-)a/Makefile.PL (+1 lines)
Lines 350-355 my $target_map = { Link Here
350
    './patroncards'                                    => 'INTRANET_CGI_DIR',
350
    './patroncards'                                    => 'INTRANET_CGI_DIR',
351
    './patron_lists'                                   => 'INTRANET_CGI_DIR',
351
    './patron_lists'                                   => 'INTRANET_CGI_DIR',
352
    './perltidyrc'                                     => 'NONE',
352
    './perltidyrc'                                     => 'NONE',
353
    './.podtidyrc'                                     => 'NONE',
353
    './plugins'                                        => 'INTRANET_CGI_DIR',
354
    './plugins'                                        => 'INTRANET_CGI_DIR',
354
    './pos'                                            => 'INTRANET_CGI_DIR',
355
    './pos'                                            => 'INTRANET_CGI_DIR',
355
    './preservation'                                   => 'INTRANET_CGI_DIR',
356
    './preservation'                                   => 'INTRANET_CGI_DIR',
(-)a/debian/control (+2 lines)
Lines 121-126 Build-Depends: libalgorithm-checkdigits-perl, Link Here
121
 libplack-middleware-logwarn-perl,
121
 libplack-middleware-logwarn-perl,
122
 libplack-middleware-reverseproxy-perl,
122
 libplack-middleware-reverseproxy-perl,
123
 libpod-coverage-perl,
123
 libpod-coverage-perl,
124
 libpod-tidy-perl,
124
 libreadonly-perl,
125
 libreadonly-perl,
125
 libscalar-list-utils-perl,
126
 libscalar-list-utils-perl,
126
 libschedule-at-perl,
127
 libschedule-at-perl,
Lines 372-377 Depends: libalgorithm-checkdigits-perl, Link Here
372
 libplack-middleware-logwarn-perl,
373
 libplack-middleware-logwarn-perl,
373
 libplack-middleware-reverseproxy-perl,
374
 libplack-middleware-reverseproxy-perl,
374
 libpod-coverage-perl,
375
 libpod-coverage-perl,
376
 libpod-tidy-perl,
375
 libreadonly-perl,
377
 libreadonly-perl,
376
 libscalar-list-utils-perl,
378
 libscalar-list-utils-perl,
377
 libschedule-at-perl,
379
 libschedule-at-perl,
(-)a/misc/devel/tidy.pl (-1 / +10 lines)
Lines 141-146 sub tidy_perl { Link Here
141
        : sprintf q{perltidy --backup-and-modify-in-place --nostandard-output -pro=%s %s}, $perltidyrc, $file;
141
        : sprintf q{perltidy --backup-and-modify-in-place --nostandard-output -pro=%s %s}, $perltidyrc, $file;
142
142
143
    print qx{$cmd};
143
    print qx{$cmd};
144
145
    # Run podtidy on the same file
146
    my $pod_cmd =
147
        $no_write
148
        ? sprintf q{podtidy --config=.podtidyrc --stdout %s}, $file
149
        : sprintf q{podtidy --config=.podtidyrc --backup-and-modify-in-place %s}, $file;
150
151
    print qx{$pod_cmd};
144
}
152
}
145
153
146
sub tidy_js {
154
sub tidy_js {
Lines 197-203 sub l { Link Here
197
205
198
=head1 NAME
206
=head1 NAME
199
207
200
tidy.pl - Tidy Perl, Javascript, Vue and Template::Toolkit files.
208
tidy.pl - Tidy Perl (including POD), Javascript, Vue and Template::Toolkit files.
201
209
202
=head1 SYNOPSIS
210
=head1 SYNOPSIS
203
211
Lines 216-221 tidy.pl [options] [files] Link Here
216
=head1 DESCRIPTION
224
=head1 DESCRIPTION
217
225
218
This script will tidy the different files present in the git repository.
226
This script will tidy the different files present in the git repository.
227
For Perl files, it runs both perltidy (for code formatting) and podtidy (for POD documentation formatting).
219
228
220
If the file is an exception and should be tidy, it will be skipped.
229
If the file is an exception and should be tidy, it will be skipped.
221
However if only one file is passed with --no-write then the content of the file will be print to STDOUT.
230
However if only one file is passed with --no-write then the content of the file will be print to STDOUT.
(-)a/xt/podtidy.t (-1 / +46 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
use Modern::Perl;
3
use Test::More;
4
use Test::NoWarnings;
5
use IPC::Cmd    qw(run);
6
use File::Temp  qw(tempfile);
7
use File::Slurp qw(read_file write_file);
8
9
use Koha::Devel::CI::IncrementalRuns;
10
11
my $ci    = Koha::Devel::CI::IncrementalRuns->new( { context => 'tidy' } );
12
my @files = $ci->get_files_to_test('pl');
13
14
plan tests => scalar(@files) + 1;
15
16
my %results;
17
for my $file (@files) {
18
    ok( is_pod_tidy($file) ) or $results{$file} = 1;
19
}
20
21
$ci->report_results( \%results );
22
23
sub is_pod_tidy {
24
    my ($file) = @_;
25
26
    # Create a temp file to check tidiness
27
    my ( $fh, $tempfile ) = tempfile();
28
    write_file( $tempfile, read_file($file) );
29
30
    # Run podtidy on the temp file
31
    my ( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf ) =
32
        run( command => "podtidy --config=.podtidyrc $tempfile" );
33
34
    unless ($success) {
35
        unlink $tempfile;
36
        return 0;    # podtidy failed
37
    }
38
39
    # Check if the file changed
40
    my $original = read_file($file);
41
    my $tidied   = read_file($tempfile);
42
43
    unlink $tempfile;
44
45
    return $original eq $tidied;
46
}

Return to bug 41634