Skip to content

[ENH,MNT] Assign Bot (assigned issues>2) #2702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 12, 2025
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion .github/utilities/issue_assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
It checks if a comment on an issue or PR includes the trigger
phrase (as defined) and a mentioned user.
If it does, it assigns the issue to the mentioned user.
Users without write access can only have up to 2 open issues assigned.
Users with write access (or admin) are exempt from this limit.
If a non-write user already has 2 or more open issues, the bot
comments on the issue with links to the currently assigned open issues.
"""

import json
Expand All @@ -29,4 +33,36 @@
mentioned_users.remove("aeon-actions-bot")

for user in mentioned_users:
issue.add_to_assignees(user)
user_obj = g.get_user(user)
permission = repo.get_collaborator_permission(user_obj)

if permission in ["admin", "write"]:
issue.add_to_assignees(user)
else:
# First check if the user is already assigned to this issue
if user in [assignee.login for assignee in issue.assignees]:
continue

# search for open issues only
query = f"repo:{repo.full_name} is:issue is:open assignee:{user}"
issues_assigned_to_user = g.search_issues(query)
assigned_count = issues_assigned_to_user.totalCount

if assigned_count >= 2:
# link to issue
assigned_issues_list = [
f"[#{assigned_issue.number}]({assigned_issue.html_url})"
for assigned_issue in issues_assigned_to_user
]

comment_message = (
f"@{user}, you already have {assigned_count} open issues assigned. "
"Users without write access are limited to 2 open issues.\n\n"
"Here are the open issues assigned to you:\n"
+ "\n".join(
f"- {issue_link}" for issue_link in assigned_issues_list
)
)
issue.create_comment(comment_message)
else:
issue.add_to_assignees(user)