From cded820450fa4e55a921e32eca4cf46168eae1cc Mon Sep 17 00:00:00 2001 From: Mohan Boddu Date: Feb 12 2020 14:45:09 +0000 Subject: Checking if the branch requestors are part of maintainers or not Signed-off-by: Mohan Boddu --- diff --git a/fedscm_admin/utils.py b/fedscm_admin/utils.py index e7592d3..77bdbd8 100644 --- a/fedscm_admin/utils.py +++ b/fedscm_admin/utils.py @@ -270,7 +270,8 @@ def process_ticket(issue, force=False, auto_approve=False): initial_commit=issue_body.get( 'initial_commit', True)) elif issue_body.get('action') == 'new_branch': - prompt_for_new_branch(issue, issue_body, auto_approve=auto_approve) + prompt_for_new_branch(issue, issue_body, force=force, + auto_approve=auto_approve) else: prompt_to_close_bad_ticket(issue, "Invalid or missing action field") return @@ -480,7 +481,7 @@ def prompt_for_new_repo(issue_json, issue_body_json, force=False, return -def prompt_for_new_branch(issue_json, issue_body_json, auto_approve=False): +def prompt_for_new_branch(issue_json, issue_body_json, force=False, auto_approve=False): """ A helper function that prompts the user with information on a new branch ticket @@ -549,6 +550,19 @@ def prompt_for_new_branch(issue_json, issue_body_json, auto_approve=False): 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 + 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: + prompt_to_close_bad_ticket( + issue_json, '{0} is not a maintainer of the {1} package'.format(issue_owner, repo) + ) + return + if auto_approve and \ not ticket_requires_approval('new_branch', issue_body_json): click.echo('- Auto-approving the new branch request for "{0}" on '