Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: PRESUBMIT.py

Issue 3038036: Add a PRESUBMIT check for header files that are missing the |#pragma once| directive. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698