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

Unified Diff: PRESUBMIT.py

Issue 11418128: PRESUBMIT #include check enhancement: <sys/..> includes can be in any order. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 7d93fa247e5a50f29ad6f771da500ddcd36a960d..8cf9cf0129f483f013f307088d69d25af2010b52 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -558,6 +558,9 @@ def _CheckIncludeOrderInFile(input_api, f, is_source, changed_linenums):
"""Checks the #include order for the given file f."""
system_include_pattern = input_api.re.compile(r'\s*#include \<.*')
+ # Exclude #include <sys/...> includes from the check; they often need to
M-A Ruel 2012/11/22 14:36:51 I'd exclude anything with the pattern \<.+\?/.+?\>
marja 2012/11/22 18:08:53 Done; though I used a simpler pattern: \s*#include
+ # appear in a specific order.
+ sys_include_pattern = input_api.re.compile(r'\s*#include \<sys/.*')
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).*')
@@ -596,8 +599,9 @@ def _CheckIncludeOrderInFile(input_api, f, is_source, changed_linenums):
if if_pattern.match(line):
scopes.append(current_scope)
current_scope = []
- elif (system_include_pattern.match(line) or
- custom_include_pattern.match(line)):
+ elif ((system_include_pattern.match(line) or
+ custom_include_pattern.match(line)) and
+ not sys_include_pattern.match(line)):
current_scope.append((line_num, line))
scopes.append(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