Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

Commit

Permalink
Gracefully handle r? of invalid user
Browse files Browse the repository at this point in the history
Don't crash; instead post a comment informing people that that user
couldn't be assigned.

Also handle `r? @ghost` properly: treat it as clearing all assignees but
still do the other things that highfive normally does (e.g. setting
`S-waiting-on-review`).
  • Loading branch information
camelid committed Dec 6, 2020
1 parent 7b24638 commit 3c94cbc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions highfive/newpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,21 @@ def api_req(self, method, url, data=None, media_type=None):

def set_assignee(self, assignee, owner, repo, issue, user, author, to_mention):
try:
assignees = [] if assignee == 'ghost' else [assignee]

self.api_req(
"PATCH", issue_url % (owner, repo, issue),
{"assignee": assignee}
{"assignees": assignees}
)['body']
except urllib.error.HTTPError as e:
if e.code == 201:
pass
else:
print(f"failed to assign {assignee} to {owner}/{repo}#{issue}")
raise e
print(f"error was: {e}")
print("posting error comment")
error_msg = f":stop_sign: @{assignee} could not be assigned"
self.post_comment(error_msg, owner, repo, issue)

self.run_commands(to_mention, owner, repo, issue, user)

Expand Down

0 comments on commit 3c94cbc

Please sign in to comment.