Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for syncing branch protection required approval count #59

Merged
merged 3 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ tempfile = "3.3"
serde_json = "1.0"

[dev-dependencies]
indexmap = "1.9"
indexmap = "2.1.0"
2 changes: 1 addition & 1 deletion src/github/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ impl GitHub {
let res: GraphResult<R> = resp.json_annotated().with_context(|| {
format!("Failed to decode response body on graphql request with query '{query}'")
})?;
if let Some(error) = res.errors.get(0) {
if let Some(error) = res.errors.first() {
bail!("graphql error: {}", error.message);
} else if let Some(data) = res.data {
Ok(data)
Expand Down
9 changes: 8 additions & 1 deletion src/github/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,14 @@ fn construct_branch_protection(
expected_repo: &rust_team_data::v1::Repo,
branch_protection: &rust_team_data::v1::BranchProtection,
) -> api::BranchProtection {
let required_approving_review_count = u8::from(!expected_repo.bots.contains(&Bot::Bors));
let required_approving_review_count: u8 = if expected_repo.bots.contains(&Bot::Bors) {
0
} else {
branch_protection
.required_approvals
.try_into()
.expect("Too large required approval count")
};
let push_allowances = expected_repo
.bots
.contains(&Bot::Bors)
Expand Down
Loading