Commit dc11c6bd authored by Edward Lesmes's avatar Edward Lesmes Committed by LUCI CQ

Reland "presubmit: Use code-owners plugin if available."

This is a reland of 36de4be9
Should be fixed after cl/363445481

Original change's description:
> presubmit: Use code-owners plugin if available.
>
> Change-Id: I56734de985731d007360a4a4e65f2b16de28b69a
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2753894
> Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
> Reviewed-by: Josip Sokcevic <sokcevic@google.com>

Change-Id: Id7d5c6c3bd0a246e3400ca99584bb41a92853d16
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2774218Reviewed-by: 's avatarJosip Sokcevic <sokcevic@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
parent 2b29d0f8
...@@ -652,10 +652,14 @@ class InputApi(object): ...@@ -652,10 +652,14 @@ class InputApi(object):
# Temporary files we must manually remove at the end of a run. # Temporary files we must manually remove at the end of a run.
self._named_temporary_files = [] self._named_temporary_files = []
# TODO(dpranke): figure out a list of all approved owners for a repo self.owners_client = None
# in order to be able to handle wildcard OWNERS files? if self.gerrit:
self.owners_client = owners_client.DepotToolsClient( self.owners_client = owners_client.GetCodeOwnersClient(
change.RepositoryRoot(), change.UpstreamBranch(), os_path=self.os_path) root=change.RepositoryRoot(),
upstream=change.UpstreamBranch(),
host=self.gerrit.host,
project=self.gerrit.project,
branch=self.gerrit.branch)
self.owners_db = owners_db.Database( self.owners_db = owners_db.Database(
change.RepositoryRoot(), fopen=open, os_path=self.os_path) change.RepositoryRoot(), fopen=open, os_path=self.os_path)
self.owners_finder = owners_finder.OwnersFinder self.owners_finder = owners_finder.OwnersFinder
......
...@@ -178,6 +178,7 @@ index fe3de7b..54ae6e1 100755 ...@@ -178,6 +178,7 @@ index fe3de7b..54ae6e1 100755
mock.patch('gclient_utils.FileWrite').start() mock.patch('gclient_utils.FileWrite').start()
mock.patch('json.load').start() mock.patch('json.load').start()
mock.patch('multiprocessing.cpu_count', lambda: 2) mock.patch('multiprocessing.cpu_count', lambda: 2)
mock.patch('gerrit_util.IsCodeOwnersEnabled').start()
mock.patch('os.chdir').start() mock.patch('os.chdir').start()
mock.patch('os.getcwd', self.RootDir) mock.patch('os.getcwd', self.RootDir)
mock.patch('os.listdir').start() mock.patch('os.listdir').start()
...@@ -2749,9 +2750,9 @@ the current line as well! ...@@ -2749,9 +2750,9 @@ the current line as well!
input_api.dry_run = dry_run input_api.dry_run = dry_run
input_api.gerrit._FetchChangeDetail = lambda _: response input_api.gerrit._FetchChangeDetail = lambda _: response
input_api.owners_client = owners_client.DepotToolsClient('root', 'branch') input_api.owners_client = owners_client.OwnersClient()
with mock.patch('owners_client.DepotToolsClient.ListOwners', with mock.patch('owners_client.OwnersClient.ListOwners',
side_effect=lambda f: owners_by_path.get(f, [])): side_effect=lambda f: owners_by_path.get(f, [])):
results = presubmit_canned_checks.CheckOwners( results = presubmit_canned_checks.CheckOwners(
input_api, presubmit.OutputApi, allow_tbr=allow_tbr) input_api, presubmit.OutputApi, allow_tbr=allow_tbr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment