From 5341bf062edaa7fb9225450590e7d3ff7ac2edc1 Mon Sep 17 00:00:00 2001
From: Yiwei Zhang <yiwzhang@google.com>
Date: Thu, 20 Mar 2025 09:34:13 -0700
Subject: [PATCH] add CheckNewDEPSHookReviewers presubmit check

It will make sure any new hooks added to the DEPS are reviewed by
people in OWNERS tagged with `For new DEPS hook`.

Change-Id: I2fc8d606a92f0b4d87a5b9dc5daa819e3f47012e
Bug: 396736534
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6313602
Reviewed-by: Dirk Pranke <dpranke@google.com>
Auto-Submit: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Gary Tong <gatong@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1435490}
---
 OWNERS       |  5 +++++
 PRESUBMIT.py | 11 +++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/OWNERS b/OWNERS
index 92388619df9f9..eb6d61e7386e9 100644
--- a/OWNERS
+++ b/OWNERS
@@ -28,6 +28,11 @@ per-file CODE_OF_CONDUCT.md=dpranke@google.com
 per-file CODE_OF_CONDUCT.md=ellyjones@chromium.org
 per-file CPPLINT.cfg=file://styleguide/c++/OWNERS
 per-file DEPS=*
+per-file DEPS=bryner@google.com # For new DEPS hook
+per-file DEPS=dpranke@google.com # For new DEPS hook
+per-file DEPS=gatong@chromium.org # For new DEPS hook
+per-file DEPS=guterman@google.com # For new DEPS hook
+per-file DEPS=treilly@google.com # For new DEPS hook
 per-file PRESUBMIT*.py=agrieve@chromium.org  # For .pydeps changes
 per-file PRESUBMIT*.py=dcheng@chromium.org
 per-file PRESUBMIT*.py=dpranke@google.com
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 1f55134bacb85..49b4d867b1ac5 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -6130,6 +6130,9 @@ def ChecksCommon(input_api, output_api):
                 'infra', 'inclusive_language_presubmit_exempt_dirs.txt'
             ],
             non_inclusive_terms=_NON_INCLUSIVE_TERMS))
+    results.extend(
+        input_api.canned_checks.CheckNewDEPSHooksHasRequiredReviewers(
+            input_api, output_api))
 
     presubmit_py_filter = lambda f: input_api.FilterSourceFile(
         f, files_to_check=[r'.*PRESUBMIT\.py$'])
@@ -7518,10 +7521,10 @@ def CheckAndroidTestAnnotations(input_api, output_api):
             if m := robolectric_test.search(line):
                 is_instrumentation_test = False
                 if m.group(1) == '' and not has_base_robolectric_rule:
-                  path = str(f.LocalPath())
-                  # These two spots cannot use it.
-                  if 'webapk' not in path and 'build' not in path:
-                    wrong_robolectric_test_runner_errors.append(path)
+                    path = str(f.LocalPath())
+                    # These two spots cannot use it.
+                    if 'webapk' not in path and 'build' not in path:
+                        wrong_robolectric_test_runner_errors.append(path)
                 break
             if uiautomator_test.search(line):
                 is_instrumentation_test = False