@@ -506,17 +506,21 @@ pub fn construct_branch_protection(
506
506
branch_protection : & rust_team_data:: v1:: BranchProtection ,
507
507
) -> api:: BranchProtection {
508
508
let uses_homu = branch_protection. merge_bots . contains ( & MergeBot :: Homu ) ;
509
- let required_approving_review_count: u8 = if uses_homu {
510
- 0
509
+ // When homu manages a branch, we should not require a PR nor approvals
510
+ // for that branch, because homu pushes to these branches directly.
511
+ let branch_protection_mode = if uses_homu {
512
+ BranchProtectionMode :: PrNotRequired
511
513
} else {
512
- match branch_protection. mode {
513
- BranchProtectionMode :: PrRequired {
514
- required_approvals, ..
515
- } => required_approvals
516
- . try_into ( )
517
- . expect ( "Too large required approval count" ) ,
518
- BranchProtectionMode :: PrNotRequired => 0 ,
519
- }
514
+ branch_protection. mode . clone ( )
515
+ } ;
516
+
517
+ let required_approving_review_count: u8 = match branch_protection_mode {
518
+ BranchProtectionMode :: PrRequired {
519
+ required_approvals, ..
520
+ } => required_approvals
521
+ . try_into ( )
522
+ . expect ( "Too large required approval count" ) ,
523
+ BranchProtectionMode :: PrNotRequired => 0 ,
520
524
} ;
521
525
let mut push_allowances: Vec < PushAllowanceActor > = branch_protection
522
526
. allowed_merge_teams
@@ -537,7 +541,7 @@ pub fn construct_branch_protection(
537
541
} ) ) ;
538
542
}
539
543
540
- let mut checks = match & branch_protection . mode {
544
+ let mut checks = match & branch_protection_mode {
541
545
BranchProtectionMode :: PrRequired { ci_checks, .. } => ci_checks. clone ( ) ,
542
546
BranchProtectionMode :: PrNotRequired => {
543
547
vec ! [ ]
@@ -554,7 +558,7 @@ pub fn construct_branch_protection(
554
558
required_status_check_contexts : checks,
555
559
push_allowances,
556
560
requires_approving_reviews : matches ! (
557
- branch_protection . mode ,
561
+ branch_protection_mode ,
558
562
BranchProtectionMode :: PrRequired { .. }
559
563
) ,
560
564
}
0 commit comments