Skip to content

[update_checkout] Improved validation failure diagnostic. #34124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions utils/update_checkout/update_checkout/update_checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import re
import sys
import traceback
from functools import reduce
from multiprocessing import Lock, Pool, cpu_count, freeze_support

from build_swift.build_swift.constants import SWIFT_SOURCE_ROOT
Expand Down Expand Up @@ -408,19 +407,16 @@ def validate_config(config):
'too.'.format(scheme_name))

# Then make sure the alias names used by our branches are unique.
#
# We do this by constructing a list consisting of len(names),
# set(names). Then we reduce over that list summing the counts and taking
# the union of the sets. We have uniqueness if the length of the union
# equals the length of the sum of the counts.
data = [(len(v['aliases']), set(v['aliases']))
for v in config['branch-schemes'].values()]
result = reduce(lambda acc, x: (acc[0] + x[0], acc[1] | x[1]), data,
(0, set([])))
if result[0] == len(result[1]):
return
raise RuntimeError('Configuration file has schemes with duplicate '
'aliases?!')
seen = dict()
for (scheme_name, scheme) in config['branch-schemes'].items():
aliases = scheme['aliases']
for alias in aliases:
if alias in seen:
raise RuntimeError('Configuration file defines the alias {0} '
'in both the {1} scheme and the {2} scheme?!'
.format(alias, seen[alias], scheme_name))
else:
seen[alias] = scheme_name


def full_target_name(repository, target):
Expand Down