From 31eab4a00d1ec9d9c872becf8e61f4b5591d0721 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Mon, 14 Mar 2016 20:15:02 +0000 Subject: [PATCH] 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 --- tools/who-approves.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/who-approves.py b/tools/who-approves.py index 3d109d51ee..fcc6adfe83 100755 --- a/tools/who-approves.py +++ b/tools/who-approves.py @@ -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]: