diff options
author | Tom Lane | 2022-04-11 15:20:13 +0000 |
---|---|---|
committer | Tom Lane | 2022-04-11 15:20:20 +0000 |
commit | dfd0f2bbc5776f261ef4c8ab128469ef9091dcfe (patch) | |
tree | 72fec2b24fbbfc1f91c27159ca0887c95747f672 /src | |
parent | ad385a494f6ad863b38aa7c708f23aaf223438a7 (diff) |
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
Diffstat (limited to 'src')
-rwxr-xr-x | src/tools/copyright.pl | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/tools/copyright.pl b/src/tools/copyright.pl index cc5411673c0..182177e9b6b 100755 --- a/src/tools/copyright.pl +++ b/src/tools/copyright.pl @@ -46,18 +46,23 @@ sub wanted my @lines; 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) { # We only care about lines with a copyright notice. next unless $line =~ m/$cc.*$pgdg/i; - # Skip line if already matches the current year; if not - # we get $year-$year, e.g. 2012-2012 + # Skip line if it already matches the current year; if not + # we get $year-$year, e.g. 2012-2012. next if $line =~ m/$cc $year, $pgdg/i; - # We process all lines because some files have copyright - # strings embedded in them, e.g. src/bin/psql/help.c + # Skip already-updated lines too, to avoid unnecessary + # 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}), $pgdg/$ccliteral $1-$year, $pgdg/i; } |