@@ -513,17 +513,21 @@ pub fn construct_branch_protection(
513
513
branch_protection : & rust_team_data:: v1:: BranchProtection ,
514
514
) -> api:: BranchProtection {
515
515
let uses_homu = branch_protection. merge_bots . contains ( & MergeBot :: Homu ) ;
516
- let required_approving_review_count: u8 = if uses_homu {
517
- 0
516
+ // When homu manages a branch, we should not require a PR nor approvals
517
+ // for that branch, because homu pushes to these branches directly.
518
+ let branch_protection_mode = if uses_homu {
519
+ BranchProtectionMode :: PrNotRequired
518
520
} else {
519
- match branch_protection. mode {
520
- BranchProtectionMode :: PrRequired {
521
- required_approvals, ..
522
- } => required_approvals
523
- . try_into ( )
524
- . expect ( "Too large required approval count" ) ,
525
- BranchProtectionMode :: PrNotRequired => 0 ,
526
- }
521
+ branch_protection. mode . clone ( )
522
+ } ;
523
+
524
+ let required_approving_review_count: u8 = match branch_protection_mode {
525
+ BranchProtectionMode :: PrRequired {
526
+ required_approvals, ..
527
+ } => required_approvals
528
+ . try_into ( )
529
+ . expect ( "Too large required approval count" ) ,
530
+ BranchProtectionMode :: PrNotRequired => 0 ,
527
531
} ;
528
532
let mut push_allowances: Vec < PushAllowanceActor > = branch_protection
529
533
. allowed_merge_teams
@@ -544,7 +548,7 @@ pub fn construct_branch_protection(
544
548
} ) ) ;
545
549
}
546
550
547
- let mut checks = match & branch_protection . mode {
551
+ let mut checks = match & branch_protection_mode {
548
552
BranchProtectionMode :: PrRequired { ci_checks, .. } => ci_checks. clone ( ) ,
549
553
BranchProtectionMode :: PrNotRequired => {
550
554
vec ! [ ]
@@ -561,7 +565,7 @@ pub fn construct_branch_protection(
561
565
required_status_check_contexts : checks,
562
566
push_allowances,
563
567
requires_approving_reviews : matches ! (
564
- branch_protection . mode ,
568
+ branch_protection_mode ,
565
569
BranchProtectionMode :: PrRequired { .. }
566
570
) ,
567
571
}
0 commit comments