-
Notifications
You must be signed in to change notification settings - Fork 209
[MNT] issue-assign-bot - only users with write access should be able to assign others #2739
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
Open
shinymack
wants to merge
17
commits into
aeon-toolkit:main
Choose a base branch
from
shinymack:issue-assign-bot-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e903c2a
only admins can assign others
shinymack b8a9346
Merge branch 'aeon-toolkit:main' into issue-assign-bot-1
shinymack 6d6a4bb
improve comment message
shinymack f27a0b9
Merge branch 'issue-assign-bot-1' of https://github.com/shinymack/aeo…
shinymack 47640c3
Merge branch 'main' into issue-assign-bot-1
shinymack 6dd73be
Automatic `pre-commit` fixes
shinymack bc80e63
fixes according to latest code
shinymack 4bf6b70
Automatic `pre-commit` fixes
shinymack 6f6bb88
changes according to latest code
shinymack cddee39
resolve merge conflicts
shinymack c3f7fce
Merge branch 'main' into issue-assign-bot-1
shinymack 47d267c
Automatic `pre-commit` fixes
shinymack 31325dd
adjust according to latest code
shinymack a63b0b9
Merge branch 'issue-assign-bot-1' of https://github.com/shinymack/aeo…
shinymack c974625
Merge branch 'main' into issue-assign-bot-1
MatthewMiddlehurst b70d126
Merge branch 'main' into issue-assign-bot-1
shinymack 6748e84
Merge branch 'main' into issue-assign-bot-1
shinymack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,22 @@ | |
mentioned_users = [user[1:] for user in mentioned_users] | ||
mentioned_users.remove("aeon-actions-bot") | ||
|
||
# Get permissions of the commenter | ||
commenter_permission = repo.get_collaborator_permission(commenter) | ||
|
||
for user in mentioned_users: | ||
if user != commenter and commenter_permission not in ["admin", "write"]: | ||
comment_msg = ( | ||
f"@{commenter}, you cannot assign @{user}" | ||
" because you lack write access.\n" | ||
"Only users with write access can assign others." | ||
) | ||
issue.create_comment(comment_msg) | ||
continue | ||
elif user != commenter and commenter_permission in ["admin", "write"]: | ||
issue.add_to_assignees(user) | ||
continue | ||
Comment on lines
+52
to
+54
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this conflicts with the code below. |
||
|
||
user_obj = g.get_user(user) | ||
permission = repo.get_collaborator_permission(user_obj) | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think a message should be written for each invalid user, just a single one for all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MatthewMiddlehurst Should i use two arrays for valid and invalid users, then comment for the invalid users and then move onto the 2 issue limit code for valid users.
also the "assign me" statement doesn't check for the 2 issue limit, should i also fix that?
and for the code conflicting with the below one, do you mean that even when an admin is assigning someone it should check the 2 issue limit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just have a single printout if they try to assign someone else after the for loop. No need to @ them for each user they try to add.
If you continue the loop the code below wont run. there is lots of duplication going on im pretty sure