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

Unified Diff: PRESUBMIT.py

Issue 11607019: PRESUBMIT #include check: exclude known cases which need a non-standard order. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | PRESUBMIT_test.py » ('j') | 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 b395233d2462df2c941367ae9b9a33ca0d2afce1..ee75ad3dde2a4d706208b33f1bfd15d6c5a6cc13 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -557,8 +557,13 @@ def _CheckIncludeOrderInFile(input_api, f, changed_linenums):
# often need to appear in a specific order.
excluded_include_pattern = input_api.re.compile(r'\s*#include \<.*/.*')
custom_include_pattern = input_api.re.compile(r'\s*#include "(?P<FILE>.*)"')
- if_pattern = (
- input_api.re.compile(r'\s*#\s*(if|elif|else|endif|define|undef).*'))
+ if_pattern = input_api.re.compile(
+ r'\s*#\s*(if|elif|else|endif|define|undef).*')
+ # Some files need specialized order of includes; exclude such files from this
+ # check.
+ uncheckable_includes_pattern = input_api.re.compile(
+ r'\s*#include '
+ '("ipc/.*macros\.h"|<windows\.h>|".*gl.*autogen.h")\s*')
contents = f.NewContents()
warnings = []
@@ -591,6 +596,8 @@ def _CheckIncludeOrderInFile(input_api, f, changed_linenums):
current_scope = []
for line in contents[line_num:]:
line_num += 1
+ if uncheckable_includes_pattern.match(line):
M-A Ruel 2012/12/18 13:37:33 Why not just skip the file instead of aborting?
marja 2012/12/18 14:57:40 I assume you meant "line" instead of "file"; such
M-A Ruel 2012/12/18 20:02:07 Yes I meant line and not file. I don't mind. lgtm
+ return []
if if_pattern.match(line):
scopes.append(current_scope)
current_scope = []
« no previous file with comments | « no previous file | PRESUBMIT_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698