presubmit: Skip owners checks if code-owners plugin is enabled.
If code-owners plugin is enable for the repo, skip owners check on
commit, and skip checking owners format, as that will be done by
the plugin.
Change-Id: I1663baef4f0f27b00423071343fe740f6da50ce7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2727131
Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/gerrit_util.py b/gerrit_util.py
index 7704e23..1b6bca6 100644
--- a/gerrit_util.py
+++ b/gerrit_util.py
@@ -771,13 +771,20 @@
'in change %s' % change)
-def IsCodeOwnersEnabled(host):
+def IsCodeOwnersEnabledOnHost(host):
"""Check if the code-owners plugin is enabled for the host."""
path = 'config/server/capabilities'
capabilities = ReadHttpJsonResponse(CreateHttpConn(host, path))
return 'code-owners-checkCodeOwner' in capabilities
+def IsCodeOwnersEnabledOnRepo(host, repo):
+ """Check if the code-owners plugin is enabled for the repo."""
+ path = '/projects/%s/code_owners.project_config' % repo
+ config = ReadHttpJsonResponse(CreateHttpConn(host, path))
+ return config['status'].get('disabled', False)
+
+
def GetOwnersForFile(host, project, branch, path, limit=100,
resolve_all_users=True, o_params=('DETAILS',)):
"""Gets information about owners attached to a file."""