diff --git a/Cargo.lock b/Cargo.lock index a49de59..8515842 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -192,6 +192,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "fastrand" version = "1.8.0" @@ -313,7 +319,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -326,6 +332,12 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + [[package]] name = "hermit-abi" version = "0.1.14" @@ -448,12 +460,22 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.1" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +dependencies = [ + "equivalent", + "hashbrown 0.14.3", "serde", ] @@ -778,12 +800,12 @@ dependencies = [ [[package]] name = "rust_team_data" version = "1.0.0" -source = "git+https://github.com/rust-lang/team#c46e938189fc085b902ce0e96cb1e611d2e400cc" +source = "git+https://github.com/rust-lang/team#3c2148cab16d60b9a0336076ac085bed7ddeb46b" dependencies = [ "chacha20poly1305", "getrandom", "hex", - "indexmap", + "indexmap 2.1.0", "serde", ] @@ -922,7 +944,7 @@ dependencies = [ "base64 0.13.0", "env_logger", "hyper-old-types", - "indexmap", + "indexmap 2.1.0", "log", "reqwest", "rust_team_data", diff --git a/Cargo.toml b/Cargo.toml index dfcf17b..1e54cb2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,4 +17,4 @@ tempfile = "3.3" serde_json = "1.0" [dev-dependencies] -indexmap = "1.9" +indexmap = "2.1.0" diff --git a/src/github/api.rs b/src/github/api.rs index 66bea84..af5d7c9 100644 --- a/src/github/api.rs +++ b/src/github/api.rs @@ -789,7 +789,7 @@ impl GitHub { let res: GraphResult = 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) diff --git a/src/github/mod.rs b/src/github/mod.rs index 7b82220..a0e5bbd 100644 --- a/src/github/mod.rs +++ b/src/github/mod.rs @@ -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)