Add BatchListBestOwners and ListBestOwners to GerritClient
ListOwners returns all OWNERS for a file, which is undesirable in cases
when only direct OWNERS are needed.
Bug: 1351212, 1351519
Change-Id: I693b6645c780aa589e8ab24d0b58691f4aeb30f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3823299
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
diff --git a/gerrit_util.py b/gerrit_util.py
index fea3862..6668756 100644
--- a/gerrit_util.py
+++ b/gerrit_util.py
@@ -874,14 +874,23 @@
return not config['status'].get('disabled', False)
-def GetOwnersForFile(host, project, branch, path, limit=100,
- resolve_all_users=True, seed=None, o_params=('DETAILS',)):
+def GetOwnersForFile(host,
+ project,
+ branch,
+ path,
+ limit=100,
+ resolve_all_users=True,
+ highest_score_only=False,
+ seed=None,
+ o_params=('DETAILS',)):
"""Gets information about owners attached to a file."""
path = 'projects/%s/branches/%s/code_owners/%s' % (
urllib.parse.quote(project, ''),
urllib.parse.quote(branch, ''),
urllib.parse.quote(path, ''))
q = ['resolve-all-users=%s' % json.dumps(resolve_all_users)]
+ if highest_score_only:
+ q.append('highest-score-only=%s' % json.dumps(highest_score_only))
if seed:
q.append('seed=%d' % seed)
if limit: