mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
[owners] Fix SuggestOwners when there is only one owner.
If there are less than two owners for the given paths, current implementation will get stuck in infinite loop. Change it to return any possible owner. Change-Id: I75f18e0a00057c58d227dac23dc8572f1fba23f5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2572802 Auto-Submit: Edward Lesmes <ehmaldonado@chromium.org> Commit-Queue: Josip Sokcevic <sokcevic@google.com> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
This commit is contained in:
@@ -38,7 +38,6 @@ def _owner_combinations(owners, num_owners):
|
||||
return reversed(list(itertools.combinations(reversed(owners), num_owners)))
|
||||
|
||||
|
||||
|
||||
class InvalidOwnersConfig(Exception):
|
||||
pass
|
||||
|
||||
@@ -124,15 +123,16 @@ class OwnersClient(object):
|
||||
# Select the minimum number of owners that can approve all paths.
|
||||
# We start at 2 to avoid sending all changes that require multiple reviewers
|
||||
# to top-level owners.
|
||||
num_owners = 2
|
||||
while True:
|
||||
if len(owners) < 2:
|
||||
return owners
|
||||
|
||||
for num_owners in range(2, len(owners)):
|
||||
# Iterate all combinations of `num_owners` by decreasing score, and select
|
||||
# the first one that covers all paths.
|
||||
for selected in _owner_combinations(owners, num_owners):
|
||||
covered = set.union(*(paths_by_owner[o] for o in selected))
|
||||
if len(covered) == len(paths):
|
||||
return selected
|
||||
num_owners += 1
|
||||
|
||||
|
||||
class DepotToolsClient(OwnersClient):
|
||||
|
||||
Reference in New Issue
Block a user