33
33
review_with_reviewer = 'r? @%s\n \n (rust-highfive has picked a reviewer for you, use r? to override)'
34
34
review_without_reviewer = '@%s: no appropriate reviewer found, use r? to override'
35
35
36
- reviewer_re = re .compile (" \ \ b[rR]\?[:\- ]*@([a-zA-Z0-9\-]+)" )
37
- reviewer_group_re = re .compile (" \ \ b[rR]\?[:\- ]*@?(?:([a-zA-Z0-9\-]+)/)([a-zA-Z0-9\-]+)" )
38
- submodule_re = re .compile (".*\+Subproject\scommit\s.*" , re .DOTALL | re .MULTILINE )
36
+ reviewer_re = re .compile (r" \b[rR]\?[:\- ]*@([a-zA-Z0-9\-]+)" )
37
+ reviewer_group_re = re .compile (r" \b[rR]\?[:\- ]*@?(?:([a-zA-Z0-9\-]+)/)([a-zA-Z0-9\-]+)" )
38
+ submodule_re = re .compile (r ".*\+Subproject\scommit\s.*" , re .DOTALL | re .MULTILINE )
39
39
target_re = re .compile ("^[+-]{3} [ab]/compiler/rustc_target/src/spec/" , re .MULTILINE )
40
40
41
- rustaceans_api_url = "http://www.ncameron.org/rustaceans/user?username={username}"
42
-
43
-
44
41
class UnsupportedRepoError (IOError ):
45
42
pass
46
43
@@ -68,10 +65,13 @@ def run(self, event):
68
65
return "Ping received! The webhook is configured correctly!\n "
69
66
elif event == "pull_request" and self .payload ["action" ] == "opened" :
70
67
self .new_pr ()
71
- return 'OK\n '
68
+ return 'OK, handled new PR \n '
72
69
elif event == "issue_comment" and self .payload ["action" ] == "created" :
73
- self .new_comment ()
74
- return 'OK\n '
70
+ msg = self .new_comment ()
71
+ if msg is None :
72
+ return 'OK\n '
73
+ else :
74
+ return f"OK: { msg } \n "
75
75
else :
76
76
return 'Unsupported webhook event.\n '
77
77
@@ -433,12 +433,12 @@ def new_comment(self):
433
433
# Check the issue is a PR and is open.
434
434
if self .payload ['issue' , 'state' ] != 'open' \
435
435
or 'pull_request' not in self .payload ['issue' ]:
436
- return
436
+ return "skipped - closed issue"
437
437
438
438
commenter = self .payload ['comment' , 'user' , 'login' ]
439
439
# Ignore our own comments.
440
440
if commenter == self .integration_user :
441
- return
441
+ return "skipped - our own comment"
442
442
443
443
owner = self .payload ['repository' , 'owner' , 'login' ]
444
444
repo = self .payload ['repository' , 'name' ]
@@ -451,7 +451,7 @@ def new_comment(self):
451
451
)):
452
452
# Check if commenter is a collaborator.
453
453
if not self .is_collaborator (commenter , owner , repo ):
454
- return
454
+ return "skipped, comment not by author, collaborator, or assignee"
455
455
456
456
# Check for r? and set the assignee.
457
457
msg = self .payload ['comment' , 'body' ]
@@ -462,3 +462,6 @@ def new_comment(self):
462
462
reviewer , owner , repo , issue , self .integration_user ,
463
463
author , None
464
464
)
465
+ return f"set assignee to { reviewer } "
466
+ else :
467
+ return "no reviewer found"
0 commit comments