PRESUBMIT.py: Use owners client to check DEPS includes owners.
Replace input_api.owners_db with input_api.owners_client, a common interface to check owners using Depot Tools owners implementation and Gerrit Code-Owners plugin. Change-Id: I670c0294ad614537491c492fc53437ecd0305128 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2679151 Commit-Queue: Dirk Pranke <dpranke@google.com> Reviewed-by: Dirk Pranke <dpranke@google.com> Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org> Cr-Commit-Position: refs/heads/master@{#851321}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
3c22093c9f
commit
3f7ffdc226
16
PRESUBMIT.py
16
PRESUBMIT.py
@ -2355,20 +2355,19 @@ def CheckAddedDepsHaveTargetApprovals(input_api, output_api):
|
||||
else:
|
||||
output = output_api.PresubmitNotifyResult
|
||||
|
||||
owners_db = input_api.owners_db
|
||||
owner_email, reviewers = (
|
||||
input_api.canned_checks.GetCodereviewOwnerAndReviewers(
|
||||
input_api,
|
||||
owners_db.email_regexp,
|
||||
None,
|
||||
approval_needed=input_api.is_committing))
|
||||
|
||||
owner_email = owner_email or input_api.change.author_email
|
||||
|
||||
reviewers_plus_owner = set(reviewers)
|
||||
if owner_email:
|
||||
reviewers_plus_owner.add(owner_email)
|
||||
missing_files = owners_db.files_not_covered_by(virtual_depended_on_files,
|
||||
reviewers_plus_owner)
|
||||
approval_status = input_api.owners_client.GetFilesApprovalStatus(
|
||||
affected_files, reviewers.union([owner_email]), [])
|
||||
missing_files = [
|
||||
f for f in affected_files
|
||||
if approval_status[f] != input_api.owners_client.APPROVED]
|
||||
|
||||
# We strip the /DEPS part that was added by
|
||||
# _FilesToCheckForIncomingDeps to fake a path to a file in a
|
||||
@ -2387,7 +2386,8 @@ def CheckAddedDepsHaveTargetApprovals(input_api, output_api):
|
||||
output('You need LGTM from owners of depends-on paths in DEPS that were '
|
||||
'modified in this CL:\n %s' %
|
||||
'\n '.join(sorted(unapproved_dependencies)))]
|
||||
suggested_owners = owners_db.reviewers_for(missing_files, owner_email)
|
||||
suggested_owners = input_api.owners_client.SuggestOwners(
|
||||
missing_files, exclude=[owner_email])
|
||||
output_list.append(output(
|
||||
'Suggested missing target path OWNERS:\n %s' %
|
||||
'\n '.join(suggested_owners or [])))
|
||||
|
Reference in New Issue
Block a user