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

Commit 3c94cbc

Browse files
committed
Gracefully handle r? of invalid user
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`).
1 parent 7b24638 commit 3c94cbc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

highfive/newpr.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,21 @@ def api_req(self, method, url, data=None, media_type=None):
105105

106106
def set_assignee(self, assignee, owner, repo, issue, user, author, to_mention):
107107
try:
108+
assignees = [] if assignee == 'ghost' else [assignee]
109+
108110
self.api_req(
109111
"PATCH", issue_url % (owner, repo, issue),
110-
{"assignee": assignee}
112+
{"assignees": assignees}
111113
)['body']
112114
except urllib.error.HTTPError as e:
113115
if e.code == 201:
114116
pass
115117
else:
116118
print(f"failed to assign {assignee} to {owner}/{repo}#{issue}")
117-
raise e
119+
print(f"error was: {e}")
120+
print("posting error comment")
121+
error_msg = f":stop_sign: @{assignee} could not be assigned"
122+
self.post_comment(error_msg, owner, repo, issue)
118123

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

0 commit comments

Comments
 (0)