Skip to content

Commit

Permalink
Merge pull request apple#34124 from nate-chandler/update-checkout/bet…
Browse files Browse the repository at this point in the history
…ter-config-validation-failure-diagnostic

[update_checkout] Improved validation failure diagnostic.
  • Loading branch information
shahmishal committed Sep 30, 2020
2 parents 8857deb + f6b9d14 commit e903630
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions utils/update_checkout/update_checkout/update_checkout.py
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

0 comments on commit e903630

Please sign in to comment.