Filter nonexistent groups in who-approves.py

More recent versions of Gerrit (somewhere between the 2.8 we were
running and the 2.11 to which we upgraded) switched some common
groups to be virtual routines, for example the Registered Users
group, so they no longer appear in the groups list. However we
should also not be counting members of these virtual groups as
approvers anyway (even though in the case of the sandbox repo they
are), so filter them out of the assembly loop in who-approves.py to
prevent it from breaking when it encounters them in an ACL.

Change-Id: Ibb73b68e6338cd2fe2e18c09993d6e02b03c312a
This commit is contained in:
Jeremy Stanley 2016-03-14 20:15:02 +00:00
parent f73fc067cb
commit 31eab4a00d

@ -124,9 +124,14 @@ for team in projects:
repos[repo]['tags'] = \
projects[team]['deliverables'][deli]['tags']
for aprv_group in aprv_groups.keys():
aprv_groups[aprv_group] = json.loads(requests.get(
gerrit_url + group_path % all_groups[aprv_group]['id'],
auth=gerrit_auth).text[4:])
# It's possible for built-in metagroups in recent Gerrit releases to
# appear in ACLs but not in the groups list
if aprv_group in all_groups:
aprv_groups[aprv_group] = json.loads(requests.get(
gerrit_url + group_path % all_groups[aprv_group]['id'],
auth=gerrit_auth).text[4:])
else:
sys.stderr.write('Ignoring nonexistent "%s" group.\n' % aprv_group)
for repo in repos:
for aprv_group in repos[repo]['approvers'].keys():
for approver in aprv_groups[aprv_group]: