Skip to content

Commit 381199a

Browse files
committed
Make shebang a multi-value config item as well
1 parent 9434d72 commit 381199a

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

Changes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{{$NEXT}}
22

3+
- Changed the shebang config item to actually accept multi items on different
4+
lines. The old method of specifying more than one item on a single line,
5+
separated by spaces, will continue to work, but is no longer documented.
6+
7+
38
0.43 2016-03-27
49

510
- Use the same improved "git status" code for Code::TidyAll::Git::Precommit as

bin/tidyall

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,15 +425,15 @@ C<select>. e.g.
425425
426426
=item shebang
427427
428-
One or more words, separated by whitespace or on multiple lines, indicating
429-
which shebang lines to accept. This is optional and further filters C<select>.
430-
e.g.
428+
One or more words on multiple lines, indicating which shebang lines to
429+
accept. This is optional and further filters C<select>. e.g.
431430
432431
; All files with no extension anywhere under bin that include a "perl" or
433432
; "perl5" shebang line.
434433
select = bin/**/*
435434
ignore = bin/**/*.*
436-
shebang = perl perl5
435+
shebang = perl
436+
shebang = perl5
437437
438438
=item only_modes
439439

lib/Code/TidyAll.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ sub find_matched_files {
454454
@selected = grep { !$is_ignored{$_} } @selected;
455455
}
456456
if ( my $shebang = $plugin->shebang ) {
457-
my $re = join '|', map {quotemeta} split ' ', $shebang;
457+
my $re = join '|', map {quotemeta} @{$shebang};
458458
$re = qr/^#!.*\b(?:$re)\b/;
459459
@selected = grep {
460460
my $fh;

lib/Code/TidyAll/Config/INI/Reader.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ use base qw(Config::INI::Reader);
66

77
our $VERSION = '0.44';
88

9+
my %multi_value = map { $_ => 1 } qw( select ignore shebang );
10+
911
sub set_value {
1012
my ( $self, $name, $value ) = @_;
1113

12-
if ( $name eq 'select' || $name eq 'ignore' ) {
14+
if ( $multi_value{$name} ) {
1315
push @{ $self->{data}{ $self->current_section }{$name} }, $value;
1416
return;
1517
}

lib/Code/TidyAll/Plugin.pm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ around BUILDARGS => sub {
3737

3838
my $args = $class->$orig(@_);
3939

40+
# When the feature was first released it was documented as accepting a
41+
# space separated list, and we want that to still work.
42+
if ( defined $args->{shebang} && !ref $args->{shebang} ) {
43+
$args->{shebang} = [ split /\s+/, $args->{shebang} ];
44+
}
45+
4046
for my $key (qw( select ignore )) {
4147
if ( defined $args->{$key} && !ref $args->{$key} ) {
4248
$args->{$key} = [ $args->{$key} ];

0 commit comments

Comments
 (0)