From b25e837b580dc0416958b7c597c9519aab58b755 Mon Sep 17 00:00:00 2001 From: Mohan Boddu Date: Apr 01 2020 21:48:31 +0000 Subject: Check if the requestor is part of the any FAS groups Also, adding the check for commit acls Signed-off-by: Mohan Boddu --- diff --git a/fedscm_admin/utils.py b/fedscm_admin/utils.py index e37067a..c34d763 100644 --- a/fedscm_admin/utils.py +++ b/fedscm_admin/utils.py @@ -550,14 +550,25 @@ def prompt_for_new_branch(issue_json, issue_body_json, force=False, auto_approve issue_owner = issue_json['user']['name'] issue_ui_url = fedscm_admin.pagure.get_pagure_issue_url(issue_id) - # Check if the branch requestor is one of the maintainers + # Check if the branch requestor is one of the maintainers or part of the groups click.echo('- Checking if {0} is one of the maintainers of the package'.format(issue_owner)) if force: msg = ' WARNING: Checking of maintainers is skipped' click.secho(msg, fg='yellow') else: - maintainers = set(project['access_users']['owner']) | set(project['access_users']['admin']) - if issue_owner not in maintainers: + # Get the list of maintainers of the package + maintainers = set(project['access_users']['owner']) | set(project['access_users']['admin'])\ + | set(project['access_users']['commit']) + # Get the list of FAS groups who can maintain the package + access_groups = set(project['access_groups']['admin'])\ + | set(project['access_groups']['commit']) + group_member = False + for access_group in access_groups: + # Check if the requestor is part of any of the FAS groups who can maintain the package + if FAS_CLIENT.user_member_of(FAS_CLIENT.get_fas_user(issue_owner), access_group): + group_member = True + break + if issue_owner not in maintainers and not group_member: prompt_to_close_bad_ticket( issue_json, '{0} is not a maintainer of the {1} package'.format(issue_owner, repo) )