Pārlūkot izejas kodu

Make copyright checker more verbose

Output the the line that failed the check in addition to what has been
found at the top of the file.
Petr Penzin 1 gadu atpakaļ
vecāks
revīzija
76d058f2b0
1 mainītis faili ar 7 papildinājumiem un 3 dzēšanām
  1. 7 3
      tools/StyleChecks/check_copyright.py

+ 7 - 3
tools/StyleChecks/check_copyright.py

@@ -48,13 +48,17 @@ else:
         pattern = '^.{1,5}%s$' % line
         regexes.append(re.compile(pattern))
 
-def report_incorrect(file_name, pairs):
+def report_incorrect(file_name, pairs, fail_line):
     # found a problem so report the problem to the caller and exit
     print(file_name, "... does not contain a correct copyright notice.\n")
     # print the relevant lines to help the reader find the problem
     for (_, line) in pairs:
         print("    ", line, end="")
     print()
+    if (fail_line != ""):
+        print("Match failed at line:")
+        print("    ", fail_line, end="")
+        print()
 
 linecount = 0
 pairs = []
@@ -69,12 +73,12 @@ for (regex, line) in pairs:
     line = line.rstrip()
     matches = regex.match(line)
     if not matches:
-        report_incorrect(file_name, pairs)
+        report_incorrect(file_name, pairs, line)
         exit(1)
 
 if linecount == 0:
     # the file was empty (e.g. dummy.js) so no problem
     exit(0)
 elif linecount != len(regexes):
-    report_incorrect(file_name, pairs)
+    report_incorrect(file_name, pairs, "")
     exit(1)