@@ -185,6 +185,10 @@ fn find_assign_command(ctx: &Context, event: &IssuesEvent) -> Option<String> {
185
185
} )
186
186
}
187
187
188
+ fn is_self_assign ( assignee : & str , pr_author : & str ) -> bool {
189
+ assignee. to_lowercase ( ) == pr_author. to_lowercase ( )
190
+ }
191
+
188
192
/// Returns a message if the PR is opened against the non-default branch.
189
193
fn non_default_branch ( event : & IssuesEvent ) -> Option < String > {
190
194
let target_branch = & event. issue . base . as_ref ( ) . unwrap ( ) . git_ref ;
@@ -260,6 +264,9 @@ async fn determine_assignee(
260
264
) -> anyhow:: Result < ( Option < String > , bool ) > {
261
265
let teams = crate :: team_data:: teams ( & ctx. github ) . await ?;
262
266
if let Some ( name) = find_assign_command ( ctx, event) {
267
+ if is_self_assign ( & name, & event. issue . user . login ) {
268
+ return Ok ( ( Some ( name. to_string ( ) ) , true ) ) ;
269
+ }
263
270
// User included `r?` in the opening PR body.
264
271
match find_reviewer_from_names ( & teams, config, & event. issue , & [ name] ) {
265
272
Ok ( assignee) => return Ok ( ( Some ( assignee) , true ) ) ,
@@ -448,12 +455,16 @@ pub(super) async fn handle_command(
448
455
// welcome message).
449
456
return Ok ( ( ) ) ;
450
457
}
451
- let teams = crate :: team_data:: teams ( & ctx. github ) . await ?;
452
- match find_reviewer_from_names ( & teams, config, issue, & [ name] ) {
453
- Ok ( assignee) => assignee,
454
- Err ( e) => {
455
- issue. post_comment ( & ctx. github , & e. to_string ( ) ) . await ?;
456
- return Ok ( ( ) ) ;
458
+ if is_self_assign ( & name, & event. user ( ) . login ) {
459
+ name. to_string ( )
460
+ } else {
461
+ let teams = crate :: team_data:: teams ( & ctx. github ) . await ?;
462
+ match find_reviewer_from_names ( & teams, config, issue, & [ name] ) {
463
+ Ok ( assignee) => assignee,
464
+ Err ( e) => {
465
+ issue. post_comment ( & ctx. github , & e. to_string ( ) ) . await ?;
466
+ return Ok ( ( ) ) ;
467
+ }
457
468
}
458
469
}
459
470
}
0 commit comments