Commit 14a6131c authored by joi@chromium.org's avatar joi@chromium.org

Do per-file OWNERS check for per-file DEPS changes.

Before this, an OWNER of the entire directory that a new DEPS rule was pointing to would be required, even when the DEPS rule specified an individual file for which there are per-file OWNERS in the OWNERS file.

BUG=290401

Review URL: https://codereview.chromium.org/116443011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243459 0039d316-1c4b-4281-b951-d872f2087c98
parent 566755f8
...@@ -781,9 +781,14 @@ def _CheckNoAbbreviationInPngFileName(input_api, output_api): ...@@ -781,9 +781,14 @@ def _CheckNoAbbreviationInPngFileName(input_api, output_api):
return results return results
def _DepsFilesToCheck(re, changed_lines): def _FilesToCheckForIncomingDeps(re, changed_lines):
"""Helper method for _CheckAddedDepsHaveTargetApprovals. Returns """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. # We ignore deps entries on auto-generated directories.
AUTO_GENERATED_DIRS = ['grit', 'jni'] AUTO_GENERATED_DIRS = ['grit', 'jni']
...@@ -799,7 +804,10 @@ def _DepsFilesToCheck(re, changed_lines): ...@@ -799,7 +804,10 @@ def _DepsFilesToCheck(re, changed_lines):
if m: if m:
path = m.group(1) path = m.group(1)
if path.split('/')[0] not in AUTO_GENERATED_DIRS: 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 return results
...@@ -819,7 +827,8 @@ def _CheckAddedDepsHaveTargetApprovals(input_api, output_api): ...@@ -819,7 +827,8 @@ def _CheckAddedDepsHaveTargetApprovals(input_api, output_api):
if not changed_lines: if not changed_lines:
return [] 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: if not virtual_depended_on_files:
return [] return []
...@@ -848,12 +857,22 @@ def _CheckAddedDepsHaveTargetApprovals(input_api, output_api): ...@@ -848,12 +857,22 @@ def _CheckAddedDepsHaveTargetApprovals(input_api, output_api):
reviewers_plus_owner.add(owner_email) reviewers_plus_owner.add(owner_email)
missing_files = owners_db.files_not_covered_by(virtual_depended_on_files, missing_files = owners_db.files_not_covered_by(virtual_depended_on_files,
reviewers_plus_owner) 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] for path in missing_files]
if unapproved_dependencies: if unapproved_dependencies:
output_list = [ 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)))] '\n '.join(sorted(unapproved_dependencies)))]
if not input_api.is_committing: if not input_api.is_committing:
suggested_owners = owners_db.reviewers_for(missing_files, owner_email) suggested_owners = owners_db.reviewers_for(missing_files, owner_email)
......
...@@ -394,7 +394,7 @@ class InvalidOSMacroNamesTest(unittest.TestCase): ...@@ -394,7 +394,7 @@ class InvalidOSMacroNamesTest(unittest.TestCase):
class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase): class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase):
def testDepsFilesToCheck(self): def testFilesToCheckForIncomingDeps(self):
changed_lines = [ changed_lines = [
'"+breakpad",', '"+breakpad",',
'"+chrome/installer",', '"+chrome/installer",',
...@@ -404,6 +404,7 @@ class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase): ...@@ -404,6 +404,7 @@ class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase):
'"+components/breakpad",', '"+components/breakpad",',
'"+components/nacl/common",', '"+components/nacl/common",',
'"+content/public/browser/render_process_host.h",', '"+content/public/browser/render_process_host.h",',
'"+jni/fooblat.h",',
'"+grit", # For generated headers', '"+grit", # For generated headers',
'"+grit/generated_resources.h",', '"+grit/generated_resources.h",',
'"+grit/",', '"+grit/",',
...@@ -412,20 +413,20 @@ class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase): ...@@ -412,20 +413,20 @@ class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase):
'"+tools/memory_watcher",', '"+tools/memory_watcher",',
'"+third_party/lss/linux_syscall_support.h",', '"+third_party/lss/linux_syscall_support.h",',
] ]
files_to_check = PRESUBMIT._DepsFilesToCheck(re, changed_lines) files_to_check = PRESUBMIT._FilesToCheckForIncomingDeps(re, changed_lines)
expected = set([ expected = set([
'breakpad/DEPS', 'breakpad/DEPS',
'chrome/installer/DEPS', 'chrome/installer/DEPS',
'chrome/plugin/DEPS', 'chrome/plugin/chrome_content_plugin_client.h',
'chrome/utility/DEPS', 'chrome/utility/chrome_content_utility_client.h',
'chromeos/DEPS', 'chromeos/chromeos_paths.h',
'components/breakpad/DEPS', 'components/breakpad/DEPS',
'components/nacl/common/DEPS', 'components/nacl/common/DEPS',
'content/public/browser/DEPS', 'content/public/browser/render_process_host.h',
'policy/DEPS', 'policy/DEPS',
'sandbox/DEPS', 'sandbox/DEPS',
'tools/memory_watcher/DEPS', 'tools/memory_watcher/DEPS',
'third_party/lss/DEPS', 'third_party/lss/linux_syscall_support.h',
]) ])
self.assertEqual(expected, files_to_check); self.assertEqual(expected, files_to_check);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment