]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
checksrc: repair the copyrightyear check
authorDaniel Stenberg <daniel@haxx.se>
Fri, 1 Nov 2019 12:58:27 +0000 (13:58 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 8 Nov 2019 13:51:42 +0000 (14:51 +0100)
- Consider a modified file to be committed this year.

- Make the travis CHECKSRC also do COPYRIGHTYEAR scan in examples and
  includes

- Ignore 0 parents when getting latest commit date of file.

since in the CI we're dealing with a truncated repo of last 50 commits,
the file's most recent commit may not be available. when this happens
git log and rev-list show the initial commit (ie first commit not to be
truncated) but that's incorrect so ignore it.

Ref: https://github.com/curl/curl/pull/4547

Closes https://github.com/curl/curl/pull/4549

Co-authored-by: Jay Satiro
.travis.yml
lib/checksrc.pl

index 3c4fb43e5459e1a750651b4bc76f5967ec86eeaf..73ac0fb0181b61abee01ff1a94cbb52d110d8bea 100644 (file)
@@ -609,6 +609,8 @@ script:
                 make test-nonflaky
              fi
              if [ -n $CHECKSRC ]; then
+                echo "enable COPYRIGHTYEAR" > ./docs/examples/.checksrc
+                echo "enable COPYRIGHTYEAR" > ./include/curl/.checksrc
                 make checksrc
              fi
         fi
index b2cfa835592435c773c384e6da07353364c6d0db..8343645610003f55936128cc7c455c8add9b736e 100755 (executable)
@@ -6,7 +6,7 @@
 #                            | (__| |_| |  _ <| |___
 #                             \___|\___/|_| \_\_____|
 #
-# Copyright (C) 2011 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 2011 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
@@ -717,12 +717,17 @@ sub scanfile {
         my $commityear = undef;
         @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;
         }
-        elsif (`git rev-list --count origin/master..HEAD -- $file` !~ /^0/) {
-            my $grl = `git rev-list --max-count=1 --timestamp HEAD -- $file`;
-            $commityear = (localtime((split(/ /, $grl))[0]))[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) &&