Revert "[owners] Refactor OwnersClient."
This reverts commit 9c7f6c25c004fe59187fa0695fbd02cb06f9aa4e.
Reason for revert:
Not working
https://logs.chromium.org/logs/infra-internal/buildbucket/cr-buildbucket.appspot.com/8858807889610091152/+/steps/franky/0/steps/git_cl_upload/0/stdout
Original change's description:
> [owners] Refactor OwnersClient.
>
> - Remove GetChangeApprovalStatus and GetFilesApprovalStatus.
> - Make host, project and branch part of GerritClient.
> - Rename ListOwnersForFile to ListOwners.
>
> Change-Id: I1f610a64f0217ce54e5ce4a210026535adc1c2e5
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2587268
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Gavin Mak <gavinmak@google.com>
TBR=ehmaldonado@chromium.org,gavinmak@google.com,infra-scoped@luci-project-accounts.iam.gserviceaccount.com,sokcevic@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I4928df90856526210a4fd4d104e6cc96aa005bc2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2613925
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Stephen Martinis <martiniss@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index d3b2ce5..9fc56f1 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -42,6 +42,7 @@
import git_new_branch
import metrics
import metrics_utils
+import owners
import owners_client
import owners_finder
import presubmit_canned_checks
@@ -1375,16 +1376,19 @@
add_owners = []
if options.add_owners_to:
# Fill gaps in OWNERS coverage to tbrs/reviewers if requested.
+ project = self.GetGerritProject()
+ branch = self.GetCommonAncestorWithUpstream()
client = owners_client.DepotToolsClient(
+ host=self.GetGerritHost(),
root=settings.GetRoot(),
- branch=self.GetCommonAncestorWithUpstream())
+ branch=branch)
status = client.GetFilesApprovalStatus(
- files, [], options.tbrs + options.reviewers)
+ project, branch, files, [], options.tbrs + options.reviewers)
missing_files = [
f for f in files
if status[f] == owners_client.INSUFFICIENT_REVIEWERS
]
- add_owners = client.SuggestOwners(missing_files)
+ add_owners = client.SuggestOwners(project, branch, missing_files)
change_description.update_reviewers(
options.reviewers, options.tbrs, options.add_owners_to, add_owners)
@@ -4791,13 +4795,16 @@
if len(args) == 0:
print('No files specified for --show-all. Nothing to do.')
return 0
+ project = cl.GetGerritProject()
+ branch = cl.GetCommonAncestorWithUpstream()
client = owners_client.DepotToolsClient(
+ host=cl.GetGerritHost(),
root=settings.GetRoot(),
- branch=cl.GetCommonAncestorWithUpstream())
- owners_by_file = client.BatchListOwners(args)
- for f, owners in owners_by_file.items():
- print('Owners for %s:' % f)
- print('\n'.join(' - %s' % owner for owner in owners))
+ branch=branch)
+ for arg in args:
+ print('Owners for %s:' % arg)
+ for owner in client.ListOwnersForFile(project, branch, arg):
+ print(' - %s' % owner)
return 0
if args:
@@ -4812,10 +4819,13 @@
affected_files = cl.GetAffectedFiles(base_branch)
if options.batch:
+ project = cl.GetGerritProject()
+ branch = cl.GetCommonAncestorWithUpstream()
client = owners_client.DepotToolsClient(
+ host=cl.GetGerritHost(),
root=settings.GetRoot(),
- branch=cl.GetCommonAncestorWithUpstream())
- print('\n'.join(client.SuggestOwners(affected_files)))
+ branch=branch)
+ print('\n'.join(client.SuggestOwners(project, branch, affected_files)))
return 0
owner_files = [f for f in affected_files if 'OWNERS' in os.path.basename(f)]