Skip to content

Commit d13d4c6

Browse files
committed
Do not require PRs for branches managed by homu
1 parent 5b4de53 commit d13d4c6

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

sync-team/src/github/mod.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -506,17 +506,21 @@ pub fn construct_branch_protection(
506506
branch_protection: &rust_team_data::v1::BranchProtection,
507507
) -> api::BranchProtection {
508508
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
511513
} 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,
520524
};
521525
let mut push_allowances: Vec<PushAllowanceActor> = branch_protection
522526
.allowed_merge_teams
@@ -537,7 +541,7 @@ pub fn construct_branch_protection(
537541
}));
538542
}
539543

540-
let mut checks = match &branch_protection.mode {
544+
let mut checks = match &branch_protection_mode {
541545
BranchProtectionMode::PrRequired { ci_checks, .. } => ci_checks.clone(),
542546
BranchProtectionMode::PrNotRequired => {
543547
vec![]
@@ -554,7 +558,7 @@ pub fn construct_branch_protection(
554558
required_status_check_contexts: checks,
555559
push_allowances,
556560
requires_approving_reviews: matches!(
557-
branch_protection.mode,
561+
branch_protection_mode,
558562
BranchProtectionMode::PrRequired { .. }
559563
),
560564
}

0 commit comments

Comments
 (0)