@@ -185,6 +185,10 @@ fn find_assign_command(ctx: &Context, event: &IssuesEvent) -> Option<String> {
185185 } )
186186}
187187
188+ fn is_self_assign ( assignee : & str , pr_author : & str ) -> bool {
189+ assignee. to_lowercase ( ) == pr_author. to_lowercase ( )
190+ }
191+
188192/// Returns a message if the PR is opened against the non-default branch.
189193fn non_default_branch ( event : & IssuesEvent ) -> Option < String > {
190194 let target_branch = & event. issue . base . as_ref ( ) . unwrap ( ) . git_ref ;
@@ -260,6 +264,9 @@ async fn determine_assignee(
260264) -> anyhow:: Result < ( Option < String > , bool ) > {
261265 let teams = crate :: team_data:: teams ( & ctx. github ) . await ?;
262266 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+ }
263270 // User included `r?` in the opening PR body.
264271 match find_reviewer_from_names ( & teams, config, & event. issue , & [ name] ) {
265272 Ok ( assignee) => return Ok ( ( Some ( assignee) , true ) ) ,
@@ -448,12 +455,16 @@ pub(super) async fn handle_command(
448455 // welcome message).
449456 return Ok ( ( ) ) ;
450457 }
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+ }
457468 }
458469 }
459470 }
0 commit comments