copyright.pl: cease doing year verifications

As we have (mostly) removed the copyright year ranges.

Reported-by: Ryan Schmidt
Fixes #10345
Closes #10352
This commit is contained in:
Daniel Stenberg 2023-01-28 11:22:35 +01:00
parent ffe3e3c4e1
commit 0e293bacb1
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -59,7 +59,8 @@ sub scanfile {
chomp; chomp;
my $l = $_; my $l = $_;
# check for a copyright statement and save the years # check for a copyright statement and save the years
if($l =~ /.* ?copyright .* *\d\d\d\d/i) { if($l =~ /.* ?copyright .* (\d\d\d\d|)/i) {
my $count = 0;
while($l =~ /([\d]{4})/g) { while($l =~ /([\d]{4})/g) {
push @copyright, { push @copyright, {
year => $1, year => $1,
@ -67,8 +68,19 @@ sub scanfile {
col => index($l, $1), col => index($l, $1),
code => $l code => $l
}; };
$found++; $count++;
} }
if(!$count) {
# year-less
push @copyright, {
year => -1,
line => $line,
col => index($l, $1),
code => $l
};
$count++;
}
$found = $count;
} }
if($l =~ /SPDX-License-Identifier:/) { if($l =~ /SPDX-License-Identifier:/) {
$spdx = 1; $spdx = 1;
@ -84,8 +96,6 @@ sub scanfile {
sub checkfile { sub checkfile {
my ($file, $skipped, $pattern) = @_; my ($file, $skipped, $pattern) = @_;
my $fine = 0;
@copyright=();
$spdx = 0; $spdx = 0;
my $found = scanfile($file); my $found = scanfile($file);
@ -113,38 +123,12 @@ sub checkfile {
return 2; return 2;
} }
my $commityear = undef; if($skipped) {
@copyright = sort {$$b{year} cmp $$a{year}} @copyright;
# if the file is modified, assume commit year this year
if(`git status -s -- $file` =~ /^ [MARCU]/) {
$commityear = (localtime(time))[5] + 1900;
}
else {
# min-parents=1 to ignore wrong initial commit in truncated repos
my $grl = `git rev-list --max-count=1 --min-parents=1 --timestamp HEAD -- $file`;
if($grl) {
chomp $grl;
$commityear = (localtime((split(/ /, $grl))[0]))[5] + 1900;
}
}
if(defined($commityear) && scalar(@copyright) &&
$copyright[0]{year} != $commityear) {
printf "$file:%d: copyright year out of date, should be $commityear, " .
"is $copyright[0]{year}\n",
$copyright[0]{line} if(!$skipped || $verbose);
$skips{$pattern}++ if($skipped);
}
else {
$fine = 1;
}
if($skipped && $fine) {
print "$file:1: ignored superfluously by $pattern\n" if($verbose); print "$file:1: ignored superfluously by $pattern\n" if($verbose);
$superf{$pattern}++; $superf{$pattern}++;
} }
return $fine; return 1;
} }
sub dep5 { sub dep5 {