@@ -72,7 +72,7 @@ const RETURNING_USER_WELCOME_MESSAGE_NO_REVIEWER: &str =
72
72
73
73
const ON_VACATION_WARNING : & str = "{username} is on vacation.
74
74
75
- Please choose another assignee .";
75
+ They may take a while to respond .";
76
76
77
77
const NON_DEFAULT_BRANCH : & str =
78
78
"Pull requests are usually filed against the {default} branch for this repo, \
@@ -342,7 +342,8 @@ async fn determine_assignee(
342
342
return Ok ( ( Some ( name. to_string ( ) ) , true ) ) ;
343
343
}
344
344
// 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
+ {
346
347
Ok ( assignee) => return Ok ( ( Some ( assignee) , true ) ) ,
347
348
Err ( e) => {
348
349
event
@@ -356,8 +357,15 @@ async fn determine_assignee(
356
357
// Errors fall-through to try fallback group.
357
358
match find_reviewers_from_diff ( config, diff) {
358
359
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
361
369
{
362
370
Ok ( assignee) => return Ok ( ( Some ( assignee) , false ) ) ,
363
371
Err ( FindReviewerError :: TeamNotFound ( team) ) => log:: warn!(
@@ -396,7 +404,9 @@ async fn determine_assignee(
396
404
}
397
405
398
406
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
+ {
400
410
Ok ( assignee) => return Ok ( ( Some ( assignee) , false ) ) ,
401
411
Err ( e) => {
402
412
log:: trace!(
@@ -507,6 +517,10 @@ pub(super) async fn handle_command(
507
517
// posts contain commands to instruct the user, not things that the bot
508
518
// should respond to.
509
519
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
+ ) ;
510
524
return Ok ( ( ) ) ;
511
525
}
512
526
@@ -605,6 +619,7 @@ pub(super) async fn handle_command(
605
619
& teams,
606
620
config,
607
621
issue,
622
+ ctx,
608
623
& [ team_name. to_string ( ) ] ,
609
624
)
610
625
. await
@@ -809,6 +824,7 @@ async fn find_reviewer_from_names(
809
824
teams : & Teams ,
810
825
config : & AssignConfig ,
811
826
issue : & Issue ,
827
+ ctx : & Context ,
812
828
names : & [ String ] ,
813
829
) -> Result < String , FindReviewerError > {
814
830
let candidates = candidate_reviewers_from_names ( teams, config, issue, names) ?;
@@ -843,6 +859,24 @@ async fn find_reviewer_from_names(
843
859
return Ok ( "ghost" . to_string ( ) ) ;
844
860
}
845
861
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
+
846
880
// filter out team members without capacity
847
881
// let filtered_candidates = filter_by_capacity(db, &candidates)
848
882
// .await
@@ -864,11 +898,7 @@ async fn find_reviewer_from_names(
864
898
// );
865
899
866
900
// 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)
872
902
}
873
903
874
904
/// Returns a list of candidate usernames (from relevant teams) to choose as a reviewer.
0 commit comments