mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-02 13:51:27 +02:00
Avoid re-writing files unnecessarily in src/tools/copyright.pl.
The existing coding resulted in touching every copyright-containing file in the tree, even if it was already up to date. That doesn't matter much for the annual run, but it's an annoyance if you try to use the script for mop-up at the close of a devel cycle, as I just did. Discussion: https://postgr.es/m/266030.1649685473@sss.pgh.pa.us
This commit is contained in:
parent
ad385a494f
commit
dfd0f2bbc5
@ -46,18 +46,23 @@ sub wanted
|
|||||||
my @lines;
|
my @lines;
|
||||||
tie @lines, "Tie::File", $File::Find::name;
|
tie @lines, "Tie::File", $File::Find::name;
|
||||||
|
|
||||||
|
# We process all lines because some files have copyright
|
||||||
|
# strings embedded in them, e.g. src/bin/psql/help.c
|
||||||
foreach my $line (@lines)
|
foreach my $line (@lines)
|
||||||
{
|
{
|
||||||
|
|
||||||
# We only care about lines with a copyright notice.
|
# We only care about lines with a copyright notice.
|
||||||
next unless $line =~ m/$cc.*$pgdg/i;
|
next unless $line =~ m/$cc.*$pgdg/i;
|
||||||
|
|
||||||
# Skip line if already matches the current year; if not
|
# Skip line if it already matches the current year; if not
|
||||||
# we get $year-$year, e.g. 2012-2012
|
# we get $year-$year, e.g. 2012-2012.
|
||||||
next if $line =~ m/$cc $year, $pgdg/i;
|
next if $line =~ m/$cc $year, $pgdg/i;
|
||||||
|
|
||||||
# We process all lines because some files have copyright
|
# Skip already-updated lines too, to avoid unnecessary
|
||||||
# strings embedded in them, e.g. src/bin/psql/help.c
|
# file updates.
|
||||||
|
next if $line =~ m/$cc \d{4}-$year, $pgdg/i;
|
||||||
|
|
||||||
|
# Apply the update, relying on Tie::File to write the file.
|
||||||
$line =~ s/$cc (\d{4})-\d{4}, $pgdg/$ccliteral $1-$year, $pgdg/i;
|
$line =~ s/$cc (\d{4})-\d{4}, $pgdg/$ccliteral $1-$year, $pgdg/i;
|
||||||
$line =~ s/$cc (\d{4}), $pgdg/$ccliteral $1-$year, $pgdg/i;
|
$line =~ s/$cc (\d{4}), $pgdg/$ccliteral $1-$year, $pgdg/i;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user