diff --git a/Cargo.lock b/Cargo.lock index c07bfd17..cdfe9a4c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1919,6 +1919,7 @@ dependencies = [ "openssl", "parser", "postgres-native-tls", + "rand", "regex", "reqwest", "rust_team_data", diff --git a/Cargo.toml b/Cargo.toml index 509d1c2e..22c9dd28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,7 @@ native-tls = "0.2" serde_path_to_error = "0.1.2" octocrab = "0.5" comrak = "0.8.2" +rand = "0.7" [dependencies.serde] version = "1" diff --git a/src/handlers/glacier.rs b/src/handlers/glacier.rs index d98fb489..f431809e 100644 --- a/src/handlers/glacier.rs +++ b/src/handlers/glacier.rs @@ -5,6 +5,7 @@ use crate::{config::GlacierConfig, github::Event, handlers::Context}; use octocrab::models::Object; use octocrab::params::repos::Reference; use parser::command::glacier::GlacierCommand; +use rand::Rng as _; pub(super) async fn handle_command( ctx: &Context, @@ -46,17 +47,22 @@ pub(super) async fn handle_command( unreachable!() }; - fork.create_ref( - &Reference::Branch(format!("triagebot-ice-{}", number)), - master, - ) - .await?; + let pr_branch_name = format!( + "triagebot-ice-{}-{}", + number, + rand::thread_rng() + .sample_iter(&rand::distributions::Alphanumeric) + .take(8) + .collect::() + ); + fork.create_ref(&Reference::Branch(pr_branch_name.clone()), master) + .await?; fork.create_file( format!("ices/{}.rs", number), format!("Add ICE reproduction for issue rust-lang/rust#{}.", number), body, ) - .branch(format!("triagebot-ice-{}", number)) + .branch(pr_branch_name.clone()) .send() .await?; @@ -64,7 +70,7 @@ pub(super) async fn handle_command( .pulls("rust-lang", "glacier") .create( format!("ICE - rust-lang/rust#{}", number), - format!("rustbot:triagebot-ice-{}", number), + format!("rustbot:{}", pr_branch_name), "master", ) .body(format!(