@@ -87,6 +87,9 @@ const REVIEWER_ALREADY_ASSIGNED: &str =
87
87
88
88
Please choose another assignee." ;
89
89
90
+ // Special account that we use to prevent assignment.
91
+ const GHOST_ACCOUNT : & str = "ghost" ;
92
+
90
93
#[ derive( Debug , PartialEq , Eq , serde:: Serialize , serde:: Deserialize ) ]
91
94
struct AssignData {
92
95
user : Option < String > ,
@@ -132,7 +135,7 @@ pub(super) async fn handle_input(
132
135
// Don't auto-assign or welcome if the user manually set the assignee when opening.
133
136
if event. issue . assignees . is_empty ( ) {
134
137
let ( assignee, from_comment) = determine_assignee ( ctx, event, config, & diff) . await ?;
135
- if assignee. as_deref ( ) == Some ( "ghost" ) {
138
+ if assignee. as_deref ( ) == Some ( GHOST_ACCOUNT ) {
136
139
// "ghost" is GitHub's placeholder account for deleted accounts.
137
140
// It is used here as a convenient way to prevent assignment. This
138
141
// is typically used for rollups or experiments where you don't
@@ -473,6 +476,15 @@ pub(super) async fn handle_command(
473
476
}
474
477
} ;
475
478
479
+ // In the PR body, `r? ghost` means "do not assign anybody".
480
+ // When you send `r? ghost` in a PR comment, it should mean "unassign the current assignee".
481
+ // Only allow this for the PR author (usually when they forget to do `r? ghost` in the PR
482
+ // body), otherwise anyone could remove assignees from any PR.
483
+ if assignee == GHOST_ACCOUNT && issue. user . login == event. user ( ) . login {
484
+ issue. remove_assignees ( & ctx. github , Selection :: All ) . await ?;
485
+ return Ok ( ( ) ) ;
486
+ }
487
+
476
488
let db_client = ctx. db . get ( ) . await ;
477
489
let assignee = match find_reviewer_from_names (
478
490
& db_client,
@@ -693,11 +705,6 @@ async fn find_reviewer_from_names(
693
705
candidates
694
706
) ;
695
707
696
- // Special case user "ghost", we always skip filtering
697
- if candidates. contains ( "ghost" ) {
698
- return Ok ( "ghost" . to_string ( ) ) ;
699
- }
700
-
701
708
// Return unfiltered list of candidates
702
709
Ok ( candidates
703
710
. into_iter ( )
0 commit comments