Skip to content

Commit 5f839be

Browse files
committed
Roundtrip GitHub App branch push allowances
1 parent 75725fe commit 5f839be

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

sync-team/src/github/mod.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,24 @@ impl SyncGitHub {
321321
.branch_protections(&actual_repo.org, &actual_repo.name)?;
322322
for branch_protection in &expected_repo.branch_protections {
323323
let actual_branch_protection = actual_protections.remove(&branch_protection.pattern);
324-
let expected_branch_protection =
324+
let mut expected_branch_protection =
325325
construct_branch_protection(expected_repo, branch_protection);
326+
327+
// We don't model GitHub App push allowance actors in team.
328+
// However, we don't want to remove existing accesses of GH apps to
329+
// branches.
330+
// So if there is an existing branch protection, we copy its GitHub app
331+
// push allowances into the expected branch protection, to roundtrip the app access.
332+
if let Some((_, actual_branch_protection)) = &actual_branch_protection {
333+
expected_branch_protection.push_allowances.extend(
334+
actual_branch_protection
335+
.push_allowances
336+
.iter()
337+
.filter(|allowance| matches!(allowance, PushAllowanceActor::App(_)))
338+
.cloned(),
339+
);
340+
}
341+
326342
let operation = {
327343
match actual_branch_protection {
328344
Some((database_id, bp)) if bp != expected_branch_protection => {

0 commit comments

Comments
 (0)