PRESUBMIT: Skip DEPS owners checks when Bot-Commit or Owners-Override is present.

Bug: 1167342
Change-Id: I28b78f16f53c8b997c1d30c53ff9049135be5d56
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2634012
Reviewed-by: Dirk Pranke <[email protected]>
Reviewed-by: James Cook <[email protected]>
Commit-Queue: Edward Lesmes <[email protected]>
Cr-Commit-Position: refs/heads/master@{#845011}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index e4c0e39..0486c8d 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -2296,6 +2296,18 @@
   target file or directory, to avoid layering violations from being
   introduced. This check verifies that this happens.
   """
+  if input_api.change.issue:
+    # Skip OWNERS check when Bot-Commit label is approved. This label is
+    # intended for commits made by trusted bots that don't require review nor
+    # owners approval.
+    if input_api.gerrit.IsBotCommitApproved(input_api.change.issue):
+      return []
+    # Skip OWNERS check when Owners-Override label is approved. This is intended
+    # for global owners, trusted bots, and on-call sheriffs. Review is still
+    # required for these changes.
+    if input_api.gerrit.IsOwnersOverrideApproved(input_api.change.issue):
+      return []
+
   virtual_depended_on_files = set()
 
   file_filter = lambda f: not input_api.re.match(