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

Unified Diff: PRESUBMIT.py

Issue 116443011: Do per-file OWNERS check for per-file DEPS changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 12 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 | 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 04cea10dffee5aed22c9e0372b8bae7fb6e03974..1615cf1e6bc6154da985b2a28c480362887fac5c 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -783,9 +783,14 @@ def _CheckNoAbbreviationInPngFileName(input_api, output_api):
return results
-def _DepsFilesToCheck(re, changed_lines):
+def _FilesToCheckForIncomingDeps(re, changed_lines):
"""Helper method for _CheckAddedDepsHaveTargetApprovals. Returns
- a set of DEPS entries that we should look up."""
+ a set of DEPS entries that we should look up.
+
+ For a directory (rather than a specific filename) we fake a path to
+ a specific filename by adding /DEPS. This is chosen as a file that
+ will seldom or never be subject to per-file include_rules.
+ """
# We ignore deps entries on auto-generated directories.
AUTO_GENERATED_DIRS = ['grit', 'jni']
@@ -801,7 +806,10 @@ def _DepsFilesToCheck(re, changed_lines):
if m:
path = m.group(1)
if path.split('/')[0] not in AUTO_GENERATED_DIRS:
- results.add('%s/DEPS' % m.group(1))
+ if m.group(2):
+ results.add('%s%s' % (path, m.group(2)))
+ else:
+ results.add('%s/DEPS' % path)
return results
@@ -821,7 +829,8 @@ def _CheckAddedDepsHaveTargetApprovals(input_api, output_api):
if not changed_lines:
return []
- virtual_depended_on_files = _DepsFilesToCheck(input_api.re, changed_lines)
+ virtual_depended_on_files = _FilesToCheckForIncomingDeps(input_api.re,
+ changed_lines)
if not virtual_depended_on_files:
return []
@@ -850,12 +859,22 @@ def _CheckAddedDepsHaveTargetApprovals(input_api, output_api):
reviewers_plus_owner.add(owner_email)
missing_files = owners_db.files_not_covered_by(virtual_depended_on_files,
reviewers_plus_owner)
- unapproved_dependencies = ["'+%s'," % path[:-len('/DEPS')]
+
+ # We strip the /DEPS part that was added by
+ # _FilesToCheckForIncomingDeps to fake a path to a file in a
+ # directory.
+ def StripDeps(path):
+ start_deps = path.rfind('/DEPS')
+ if start_deps != -1:
+ return path[:start_deps]
+ else:
+ return path
+ unapproved_dependencies = ["'+%s'," % StripDeps(path)
for path in missing_files]
if unapproved_dependencies:
output_list = [
- output('Missing LGTM from OWNERS of directories added to DEPS:\n %s' %
+ output('Missing LGTM from OWNERS of dependencies added to DEPS:\n %s' %
'\n '.join(sorted(unapproved_dependencies)))]
if not input_api.is_committing:
suggested_owners = owners_db.reviewers_for(missing_files, owner_email)
« 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