Fix squasher stripping repeated newlines in ignored sections
This commit is contained in:
parent
4d4edd5e9d
commit
a26764fd2f
16
util/squash
16
util/squash
|
@ -20,6 +20,7 @@ for my $arg (@ARGV) {
|
||||||
my $in_pod = 0;
|
my $in_pod = 0;
|
||||||
my $in_section = '';
|
my $in_section = '';
|
||||||
my $ignore_lines = 0;
|
my $ignore_lines = 0;
|
||||||
|
my $empty_lines = 0;
|
||||||
while (<$fh>) {
|
while (<$fh>) {
|
||||||
if (/#.*:squash-ignore-start:$/) {
|
if (/#.*:squash-ignore-start:$/) {
|
||||||
$in_section = 'ignore';
|
$in_section = 'ignore';
|
||||||
|
@ -34,10 +35,22 @@ for my $arg (@ARGV) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($in_section eq 'ignore') {
|
if ($in_section eq 'ignore') {
|
||||||
|
$empty_lines = 0 unless /^$/;
|
||||||
$code .= $_;
|
$code .= $_;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Remove repeated newlines between paragraphs
|
||||||
|
# (Provided of course we're not in an 'ignore' section)
|
||||||
|
if (/^$/) {
|
||||||
|
++$empty_lines;
|
||||||
|
if ($empty_lines > 1) {
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$empty_lines = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (/#.*:squash-remove-start:$/) {
|
if (/#.*:squash-remove-start:$/) {
|
||||||
$in_section = 'remove';
|
$in_section = 'remove';
|
||||||
next;
|
next;
|
||||||
|
@ -74,9 +87,6 @@ for my $arg (@ARGV) {
|
||||||
close $fh;
|
close $fh;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove repeated newlines between paragraphs
|
|
||||||
$code =~ s/\n\n+/\n\n/gs;
|
|
||||||
|
|
||||||
print $code;
|
print $code;
|
||||||
|
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|
Loading…
Reference in New Issue