@@ -61,13 +61,19 @@ const RETURNING_USER_WELCOME_MESSAGE: &str = "r? @{assignee}
6161const RETURNING_USER_WELCOME_MESSAGE_NO_REVIEWER : & str =
6262 "@{author}: no appropriate reviewer found, use r? to override" ;
6363
64+ const ON_VACATION_WARNING : & str = "{username} is on vacation. Please do not assign them to PRs." ;
65+
6466const NON_DEFAULT_BRANCH : & str =
6567 "Pull requests are usually filed against the {default} branch for this repo, \
6668 but this one is against {target}. \
6769 Please double check that you specified the right target!";
6870
6971const SUBMODULE_WARNING_MSG : & str = "These commits modify **submodules**." ;
7072
73+ fn on_vacation_msg ( user : & str ) -> String {
74+ ON_VACATION_WARNING . replace ( "{username}" , user)
75+ }
76+
7177#[ derive( Debug , PartialEq , Eq , serde:: Serialize , serde:: Deserialize ) ]
7278struct AssignData {
7379 user : Option < String > ,
@@ -295,6 +301,7 @@ async fn determine_assignee(
295301 is there maybe a misconfigured group?",
296302 event. issue. global_id( )
297303 ) ,
304+ // TODO: post a comment on the PR if the reviewers were filtered due to being on vacation
298305 Err (
299306 e @ FindReviewerError :: NoReviewer { .. }
300307 | e @ FindReviewerError :: AllReviewersFiltered { .. } ,
@@ -438,7 +445,19 @@ pub(super) async fn handle_command(
438445 }
439446 let username = match cmd {
440447 AssignCommand :: Own => event. user ( ) . login . clone ( ) ,
441- AssignCommand :: User { username } => username,
448+ AssignCommand :: User { username } => {
449+ // Allow users on vacation to assign themselves to a PR, but not anyone else.
450+ if config. is_on_vacation ( & username)
451+ && event. user ( ) . login . to_lowercase ( ) != username. to_lowercase ( )
452+ {
453+ // This is a comment, so there must already be a reviewer assigned. No need to assign anyone else.
454+ issue
455+ . post_comment ( & ctx. github , & on_vacation_msg ( & username) )
456+ . await ?;
457+ return Ok ( ( ) ) ;
458+ }
459+ username
460+ }
442461 AssignCommand :: Release => {
443462 log:: trace!(
444463 "ignoring release on PR {:?}, must always have assignee" ,
@@ -604,7 +623,7 @@ impl fmt::Display for FindReviewerError {
604623 write ! (
605624 f,
606625 "Could not assign reviewer from: `{}`.\n \
607- User(s) `{}` are either the PR author or are already assigned, \
626+ User(s) `{}` are either the PR author, already assigned, or on vacation , \
608627 and there are no other candidates.\n \
609628 Use r? to specify someone else to assign.",
610629 initial. join( "," ) ,
@@ -680,6 +699,7 @@ fn candidate_reviewers_from_names<'a>(
680699 let mut filter = |name : & & str | -> bool {
681700 let name_lower = name. to_lowercase ( ) ;
682701 let ok = name_lower != issue. user . login . to_lowercase ( )
702+ && !config. is_on_vacation ( name)
683703 && !issue
684704 . assignees
685705 . iter ( )
0 commit comments