Add more information to scm_request_processor

As requested in https://pagure.io/releng/issue/12296 I'm adding more info for
user not a maintainer invalid ticket resolution.

Signed-off-by: Michal Konecny <mkonecny@redhat.com>
This commit is contained in:
Michal Konecny 2024-09-19 12:11:02 +02:00
parent b4d420f210
commit a120f81941
2 changed files with 28 additions and 5 deletions

View file

@ -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",
)

View file

@ -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