Index: PRESUBMIT.py |
diff --git a/PRESUBMIT.py b/PRESUBMIT.py |
index 383819e2320ae3f8852a48b511a0d7f7cfc6d4eb..fd08ecb9b476e4d011c6bfa60e4f764d2a9b072c 100644 |
--- a/PRESUBMIT.py |
+++ b/PRESUBMIT.py |
@@ -60,9 +60,28 @@ def _CommonChecks(input_api, output_api): |
return results |
+def _CheckPragmaOnce(input_api, output_api): |
+ """Checks to make sure all new headers have |#pragma once|.""" |
+ files = [] |
+ for f in input_api.change.AffectedTextFiles(): |
+ if f.LocalPath().endswith('.h'): |
+ contents = input_api.ReadFile(f) |
+ if not '#pragma once' in contents.splitlines(False): |
+ files.append(f) |
+ |
+ if len(files): |
+ if input_api.is_committing: |
+ res_type = output_api.PresubmitPromptWarning |
+ else: |
+ res_type = output_api.PresubmitNotifyResult |
+ return [ res_type('Missing |#pragma once| directive:', files) ] |
+ return [] |
+ |
+ |
def CheckChangeOnUpload(input_api, output_api): |
results = [] |
results.extend(_CommonChecks(input_api, output_api)) |
+ results.extend(_CheckPragmaOnce(input_api, output_api)) |
return results |