Index: chrome/common/extensions/PRESUBMIT.py |
diff --git a/chrome/common/extensions/PRESUBMIT.py b/chrome/common/extensions/PRESUBMIT.py |
index 2a8f7bc2fa2f947752b97f63aa0dbfe5e9c13d09..05e2cae57d8d496045dfbb3f971e7f1d167a9bc2 100644 |
--- a/chrome/common/extensions/PRESUBMIT.py |
+++ b/chrome/common/extensions/PRESUBMIT.py |
@@ -73,8 +73,24 @@ def _CreateIntegrationTestArgs(affected_files): |
_ListFilesInPublic())) |
return args |
+def _CheckHeadingIDs(input_api): |
+ ids_re = re.compile('<h[23].*id=.*?>') |
+ headings_re = re.compile('<h[23].*?>') |
+ bad_files = [] |
+ for name in input_api.AbsoluteLocalPaths(): |
+ if (fnmatch.fnmatch(name, '*%s*' % INTROS_PATH) or |
+ fnmatch.fnmatch(name, '*%s*' % ARTICLES_PATH)): |
+ contents = input_api.ReadFile(name) |
+ if (len(re.findall(headings_re, contents)) != |
+ len(re.findall(ids_re, contents))): |
+ bad_files.append(name) |
+ return bad_files |
+ |
def _CheckChange(input_api, output_api): |
results = [] |
+ results.extend( |
+ output_api.PresubmitError('File %s needs an id for each heading.' % name) |
+ for name in _CheckHeadingIDs(input_api)) |
not at google - send to devlin
2012/09/26 01:57:17
just assign into results straight away?
cduvall
2012/09/27 23:39:39
Done.
|
try: |
integration_test = [] |
# From depot_tools/presubmit_canned_checks.py:529 |