@@ -14,6 +14,7 @@ use std::sync::Arc;
14
14
pub ( super ) async fn handle_pull_request_edited (
15
15
repo_state : Arc < RepositoryState > ,
16
16
db : Arc < PgDbClient > ,
17
+ mergeable_queue : Arc < MergeableQueue > ,
17
18
payload : PullRequestEdited ,
18
19
) -> anyhow:: Result < ( ) > {
19
20
let pr = & payload. pull_request ;
@@ -33,6 +34,10 @@ pub(super) async fn handle_pull_request_edited(
33
34
return Ok ( ( ) ) ;
34
35
} ;
35
36
37
+ mergeable_queue
38
+ . enqueue ( repo_state. repository ( ) . clone ( ) , pr_number)
39
+ . await ;
40
+
36
41
if !pr_model. is_approved ( ) {
37
42
return Ok ( ( ) ) ;
38
43
}
@@ -214,6 +219,7 @@ mod tests {
214
219
database:: MergeableState ,
215
220
tests:: mocks:: { User , default_branch_name, default_repo_name, run_test} ,
216
221
} ;
222
+ use octocrab:: models:: pulls:: MergeableState as OctocrabMergeableState ;
217
223
218
224
#[ sqlx:: test]
219
225
async fn unapprove_on_base_edited ( pool : sqlx:: PgPool ) {
@@ -348,7 +354,7 @@ mod tests {
348
354
run_test ( pool. clone ( ) , |mut tester| async {
349
355
tester
350
356
. edit_pr ( default_repo_name ( ) , default_pr_number ( ) , |pr| {
351
- pr. mergeable_state = octocrab :: models :: pulls :: MergeableState :: Dirty ;
357
+ pr. mergeable_state = OctocrabMergeableState :: Dirty ;
352
358
} )
353
359
. await ?;
354
360
tester
@@ -448,4 +454,33 @@ mod tests {
448
454
} )
449
455
. await ;
450
456
}
457
+
458
+ #[ sqlx:: test]
459
+ async fn mergeable_queue_processes_pr_base_change ( pool : sqlx:: PgPool ) {
460
+ run_test ( pool, |mut tester| async {
461
+ tester
462
+ . edit_pr ( default_repo_name ( ) , default_pr_number ( ) , |pr| {
463
+ pr. mergeable_state = OctocrabMergeableState :: Clean ;
464
+ } )
465
+ . await ?;
466
+ tester
467
+ . wait_for_default_pr ( |pr| pr. mergeable_state == MergeableState :: Mergeable )
468
+ . await ?;
469
+
470
+ let branch = tester. create_branch ( "beta" ) . clone ( ) ;
471
+ tester
472
+ . edit_pr ( default_repo_name ( ) , default_pr_number ( ) , |pr| {
473
+ pr. base_branch = branch;
474
+ pr. mergeable_state = OctocrabMergeableState :: Unknown ;
475
+ } )
476
+ . await ?;
477
+ tester
478
+ . wait_for_default_pr ( |pr| {
479
+ pr. base_branch == "beta" && pr. mergeable_state == MergeableState :: Unknown
480
+ } )
481
+ . await ?;
482
+ Ok ( tester)
483
+ } )
484
+ . await ;
485
+ }
451
486
}
0 commit comments