@@ -61,13 +61,19 @@ const RETURNING_USER_WELCOME_MESSAGE: &str = "r? @{assignee}
61
61
const RETURNING_USER_WELCOME_MESSAGE_NO_REVIEWER : & str =
62
62
"@{author}: no appropriate reviewer found, use r? to override" ;
63
63
64
+ const ON_VACATION_WARNING : & str = "{username} is on vacation. Please do not assign them to PRs." ;
65
+
64
66
const NON_DEFAULT_BRANCH : & str =
65
67
"Pull requests are usually filed against the {default} branch for this repo, \
66
68
but this one is against {target}. \
67
69
Please double check that you specified the right target!";
68
70
69
71
const SUBMODULE_WARNING_MSG : & str = "These commits modify **submodules**." ;
70
72
73
+ fn on_vacation_msg ( user : & str ) -> String {
74
+ ON_VACATION_WARNING . replace ( "{username}" , user)
75
+ }
76
+
71
77
#[ derive( Debug , PartialEq , Eq , serde:: Serialize , serde:: Deserialize ) ]
72
78
struct AssignData {
73
79
user : Option < String > ,
@@ -295,6 +301,7 @@ async fn determine_assignee(
295
301
is there maybe a misconfigured group?",
296
302
event. issue. global_id( )
297
303
) ,
304
+ // TODO: post a comment on the PR if the reviewers were filtered due to being on vacation
298
305
Err (
299
306
e @ FindReviewerError :: NoReviewer { .. }
300
307
| e @ FindReviewerError :: AllReviewersFiltered { .. } ,
@@ -438,7 +445,19 @@ pub(super) async fn handle_command(
438
445
}
439
446
let username = match cmd {
440
447
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
+ }
442
461
AssignCommand :: Release => {
443
462
log:: trace!(
444
463
"ignoring release on PR {:?}, must always have assignee" ,
@@ -604,7 +623,7 @@ impl fmt::Display for FindReviewerError {
604
623
write ! (
605
624
f,
606
625
"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 , \
608
627
and there are no other candidates.\n \
609
628
Use r? to specify someone else to assign.",
610
629
initial. join( "," ) ,
@@ -680,6 +699,7 @@ fn candidate_reviewers_from_names<'a>(
680
699
let mut filter = |name : & & str | -> bool {
681
700
let name_lower = name. to_lowercase ( ) ;
682
701
let ok = name_lower != issue. user . login . to_lowercase ( )
702
+ && !config. is_on_vacation ( name)
683
703
&& !issue
684
704
. assignees
685
705
. iter ( )
0 commit comments