Index: presubmit_canned_checks.py |
diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py |
index 3a57490078bc2a8fd0af1de414d32f231fa4d404..577dfc99526935b7f4b997cfa944647bd4523713 100755 |
--- a/presubmit_canned_checks.py |
+++ b/presubmit_canned_checks.py |
@@ -267,6 +267,25 @@ def CheckLongLines(input_api, output_api, maxlen=80, source_file_filter=None): |
return [] |
+def CheckLicense(input_api, output_api, license, source_file_filter=None): |
+ """Verifies the license header. |
+ """ |
+ license_re = input_api.re.compile(license, input_api.re.MULTILINE) |
+ bad_files = [] |
+ for f in input_api.AffectedSourceFiles(source_file_filter): |
+ contents = input_api.ReadFile(f, 'rb') |
+ if not license_re.search(contents): |
+ bad_files.append(f.LocalPath()) |
+ if bad_files: |
+ if input_api.is_committing: |
+ res_type = output_api.PresubmitPromptWarning |
+ else: |
+ res_type = output_api.PresubmitNotifyResult |
+ return [res_type( |
+ "Found a bad license header in these files:", items=bad_files)] |
+ return [] |
+ |
+ |
def CheckChangeSvnEolStyle(input_api, output_api, source_file_filter=None): |
"""Checks that the source files have svn:eol-style=LF.""" |
return CheckSvnProperty(input_api, output_api, |