Skip to content

Commit dfd0f2b

Browse files
committed
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
1 parent ad385a4 commit dfd0f2b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/tools/copyright.pl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,23 @@ sub wanted
4646
my @lines;
4747
tie @lines, "Tie::File", $File::Find::name;
4848

49+
# We process all lines because some files have copyright
50+
# strings embedded in them, e.g. src/bin/psql/help.c
4951
foreach my $line (@lines)
5052
{
5153

5254
# We only care about lines with a copyright notice.
5355
next unless $line =~ m/$cc.*$pgdg/i;
5456

55-
# Skip line if already matches the current year; if not
56-
# we get $year-$year, e.g. 2012-2012
57+
# Skip line if it already matches the current year; if not
58+
# we get $year-$year, e.g. 2012-2012.
5759
next if $line =~ m/$cc $year, $pgdg/i;
5860

59-
# We process all lines because some files have copyright
60-
# strings embedded in them, e.g. src/bin/psql/help.c
61+
# Skip already-updated lines too, to avoid unnecessary
62+
# file updates.
63+
next if $line =~ m/$cc \d{4}-$year, $pgdg/i;
64+
65+
# Apply the update, relying on Tie::File to write the file.
6166
$line =~ s/$cc (\d{4})-\d{4}, $pgdg/$ccliteral $1-$year, $pgdg/i;
6267
$line =~ s/$cc (\d{4}), $pgdg/$ccliteral $1-$year, $pgdg/i;
6368
}

0 commit comments

Comments
 (0)