Skip to content

Commit 76d058f

Browse files
ppenzinrhuanjl
authored andcommitted
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.
1 parent 1c26375 commit 76d058f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tools/StyleChecks/check_copyright.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,17 @@
4848
pattern = '^.{1,5}%s$' % line
4949
regexes.append(re.compile(pattern))
5050

51-
def report_incorrect(file_name, pairs):
51+
def report_incorrect(file_name, pairs, fail_line):
5252
# found a problem so report the problem to the caller and exit
5353
print(file_name, "... does not contain a correct copyright notice.\n")
5454
# print the relevant lines to help the reader find the problem
5555
for (_, line) in pairs:
5656
print(" ", line, end="")
5757
print()
58+
if (fail_line != ""):
59+
print("Match failed at line:")
60+
print(" ", fail_line, end="")
61+
print()
5862

5963
linecount = 0
6064
pairs = []
@@ -69,12 +73,12 @@ def report_incorrect(file_name, pairs):
6973
line = line.rstrip()
7074
matches = regex.match(line)
7175
if not matches:
72-
report_incorrect(file_name, pairs)
76+
report_incorrect(file_name, pairs, line)
7377
exit(1)
7478

7579
if linecount == 0:
7680
# the file was empty (e.g. dummy.js) so no problem
7781
exit(0)
7882
elif linecount != len(regexes):
79-
report_incorrect(file_name, pairs)
83+
report_incorrect(file_name, pairs, "")
8084
exit(1)

0 commit comments

Comments
 (0)