diff --git a/tests/plugins/test_scm_request_processor.py b/tests/plugins/test_scm_request_processor.py index f5a23e0..cd89672 100644 --- a/tests/plugins/test_scm_request_processor.py +++ b/tests/plugins/test_scm_request_processor.py @@ -1538,7 +1538,7 @@ class TestCreateNewBranch: "sls": sls, } self.toddler.dist_git.get_project_contributors.return_value = { - "users": {"admin": [], "commit": [], "collaborators": []}, + "users": {"admin": ["admin"], "commit": [], "collaborators": []}, "groups": {"admin": ["group"], "commit": [], "collaborators": []}, } mock_fedora_account.user_member_of.return_value = False @@ -1557,10 +1557,19 @@ class TestCreateNewBranch: mock_fedora_account.get_user_by_username(), "group" ) + ticket_text = ( + "zlopez is not a maintainer of the {0} package.\n" + "Current maintainers of the package.\n" + "Users:\n" + "- admin\n" + "Groups:\n" + "- group" + ).format(repo) + self.toddler.pagure_io.close_issue.assert_called_with( 100, namespace=scm_request_processor.PROJECT_NAMESPACE, - message="zlopez is not a maintainer of the {0} package".format(repo), + message=ticket_text, reason="Invalid", ) diff --git a/toddlers/plugins/scm_request_processor.py b/toddlers/plugins/scm_request_processor.py index 761174c..4bcb1a3 100644 --- a/toddlers/plugins/scm_request_processor.py +++ b/toddlers/plugins/scm_request_processor.py @@ -688,6 +688,7 @@ class SCMRequestProcessor(ToddlerBase): if fnmatch.fnmatch(branch_name, u["branches"]) ) ) + _log.debug("- Users maintaining the package {0}".format(maintainers)) # Get the list of FAS groups who can maintain the package access_groups = ( @@ -699,8 +700,10 @@ class SCMRequestProcessor(ToddlerBase): if fnmatch.fnmatch(branch_name, g["branches"]) ) ) + _log.debug("- Groups maintaining the package {0}".format(access_groups)) group_member = False fas_user = fedora_account.get_user_by_username(issue_owner) + _log.debug("- User requesting new branch {0}".format(fas_user)) if fas_user: for access_group in access_groups: # Check if the requestor is part of any of the FAS groups @@ -709,12 +712,23 @@ class SCMRequestProcessor(ToddlerBase): group_member = True break if issue_owner not in maintainers and not group_member: + ticket_text = ( + "{0} is not a maintainer of the {1} package.\n" + "Current maintainers of the package.\n" + "Users:\n" + "{2}\n" + "Groups:\n" + "{3}" + ).format( + issue_owner, + repo, + "\n".join(["- " + user for user in maintainers]), + "\n".join(["- " + group for group in access_groups]), + ) self.pagure_io.close_issue( issue["id"], namespace=PROJECT_NAMESPACE, - message="{0} is not a maintainer of the {1} package".format( - issue_owner, repo - ), + message=ticket_text, reason="Invalid", ) return