From: Tom Lane Date: Mon, 11 Apr 2022 15:20:13 +0000 (-0400) Subject: Avoid re-writing files unnecessarily in src/tools/copyright.pl. X-Git-Tag: REL_15_BETA1~201 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=dfd0f2bbc5776f261ef4c8ab128469ef9091dcfe;p=postgresql.git 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 --- 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; }