@@ -72,7 +72,7 @@ const RETURNING_USER_WELCOME_MESSAGE_NO_REVIEWER: &str =
7272
7373const ON_VACATION_WARNING : & str = "{username} is on vacation.
7474
75- Please choose another assignee .";
75+ They may take a while to respond .";
7676
7777const NON_DEFAULT_BRANCH : & str =
7878 "Pull requests are usually filed against the {default} branch for this repo, \
@@ -342,7 +342,8 @@ async fn determine_assignee(
342342 return Ok ( ( Some ( name. to_string ( ) ) , true ) ) ;
343343 }
344344 // User included `r?` in the opening PR body.
345- match find_reviewer_from_names ( & db_client, & teams, config, & event. issue , & [ name] ) . await {
345+ match find_reviewer_from_names ( & db_client, & teams, config, & event. issue , ctx, & [ name] ) . await
346+ {
346347 Ok ( assignee) => return Ok ( ( Some ( assignee) , true ) ) ,
347348 Err ( e) => {
348349 event
@@ -356,8 +357,15 @@ async fn determine_assignee(
356357 // Errors fall-through to try fallback group.
357358 match find_reviewers_from_diff ( config, diff) {
358359 Ok ( candidates) if !candidates. is_empty ( ) => {
359- match find_reviewer_from_names ( & db_client, & teams, config, & event. issue , & candidates)
360- . await
360+ match find_reviewer_from_names (
361+ & db_client,
362+ & teams,
363+ config,
364+ & event. issue ,
365+ ctx,
366+ & candidates,
367+ )
368+ . await
361369 {
362370 Ok ( assignee) => return Ok ( ( Some ( assignee) , false ) ) ,
363371 Err ( FindReviewerError :: TeamNotFound ( team) ) => log:: warn!(
@@ -396,7 +404,9 @@ async fn determine_assignee(
396404 }
397405
398406 if let Some ( fallback) = config. adhoc_groups . get ( "fallback" ) {
399- match find_reviewer_from_names ( & db_client, & teams, config, & event. issue , fallback) . await {
407+ match find_reviewer_from_names ( & db_client, & teams, config, & event. issue , ctx, fallback)
408+ . await
409+ {
400410 Ok ( assignee) => return Ok ( ( Some ( assignee) , false ) ) ,
401411 Err ( e) => {
402412 log:: trace!(
@@ -507,6 +517,10 @@ pub(super) async fn handle_command(
507517 // posts contain commands to instruct the user, not things that the bot
508518 // should respond to.
509519 if event. user ( ) . login == ctx. username . as_str ( ) {
520+ tracing:: debug!(
521+ "Received command from {}, which is the bot itself, ignoring" ,
522+ ctx. username. as_str( )
523+ ) ;
510524 return Ok ( ( ) ) ;
511525 }
512526
@@ -605,6 +619,7 @@ pub(super) async fn handle_command(
605619 & teams,
606620 config,
607621 issue,
622+ ctx,
608623 & [ team_name. to_string ( ) ] ,
609624 )
610625 . await
@@ -809,6 +824,7 @@ async fn find_reviewer_from_names(
809824 teams : & Teams ,
810825 config : & AssignConfig ,
811826 issue : & Issue ,
827+ ctx : & Context ,
812828 names : & [ String ] ,
813829) -> Result < String , FindReviewerError > {
814830 let candidates = candidate_reviewers_from_names ( teams, config, issue, names) ?;
@@ -843,6 +859,24 @@ async fn find_reviewer_from_names(
843859 return Ok ( "ghost" . to_string ( ) ) ;
844860 }
845861
862+ let pick = candidates
863+ . into_iter ( )
864+ . choose ( & mut rand:: thread_rng ( ) )
865+ . expect ( "candidate_reviewers_from_names should return at least one entry" )
866+ . to_string ( ) ;
867+
868+ if config. is_on_vacation ( & pick) {
869+ let result = issue
870+ . post_comment (
871+ & ctx. github ,
872+ & ON_VACATION_WARNING . replace ( "{username}" , & pick) ,
873+ )
874+ . await ;
875+ if let Err ( err) = result {
876+ tracing:: error!( ?err, "Failed to post vacation warning" ) ;
877+ }
878+ }
879+
846880 // filter out team members without capacity
847881 // let filtered_candidates = filter_by_capacity(db, &candidates)
848882 // .await
@@ -864,11 +898,7 @@ async fn find_reviewer_from_names(
864898 // );
865899
866900 // Return unfiltered list of candidates
867- Ok ( candidates
868- . into_iter ( )
869- . choose ( & mut rand:: thread_rng ( ) )
870- . expect ( "candidate_reviewers_from_names should return at least one entry" )
871- . to_string ( ) )
901+ Ok ( pick)
872902}
873903
874904/// Returns a list of candidate usernames (from relevant teams) to choose as a reviewer.
0 commit comments