From 07c7408adfbfcdb4d1f2ebc9b6e8156c991e3c2b Mon Sep 17 00:00:00 2001 From: Nurseit Date: Wed, 12 Nov 2025 00:40:20 +0600 Subject: [PATCH 1/4] Get rid of username notification checker in merge commit messages --- Cargo.lock | 1 - Cargo.toml | 2 -- src/bors/mod.rs | 30 ++++++++++++------------------ src/utils/text.rs | 24 ------------------------ 4 files changed, 12 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f4fba36d..59127870 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -295,7 +295,6 @@ dependencies = [ "octocrab", "parking_lot", "pulldown-cmark", - "regex", "reqwest", "secrecy", "serde", diff --git a/Cargo.toml b/Cargo.toml index c2a0d7b0..0befe492 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,14 +59,12 @@ itertools = "0.14" # Text processing pulldown-cmark = "0.13" -regex = "1" [dev-dependencies] insta = "1.26" wiremock = "0.6" base64 = "0.22" tracing-test = "0.2" -regex = "1" parking_lot = "0.12" thread_local = "1" sqlparser = { version = "0.59", features = ["visitor"] } diff --git a/src/bors/mod.rs b/src/bors/mod.rs index d46da393..3fbd2adc 100644 --- a/src/bors/mod.rs +++ b/src/bors/mod.rs @@ -18,7 +18,6 @@ use crate::github::api::client::GithubRepositoryClient; use crate::permissions::UserPermissions; #[cfg(test)] use crate::tests::TestSyncMarker; -use crate::utils::text::suppress_github_mentions; mod command; pub mod comment; @@ -128,25 +127,20 @@ pub fn create_merge_commit_message(pr: handlers::PullRequestData, merge_type: Me MergeType::Auto => pr.db.approver().unwrap_or(""), }; - let mut pr_description = suppress_github_mentions(&pr.github.message); - match &merge_type { - // Strip all PR text for try builds, to avoid useless issue pings on the repository. + let pr_description = match &merge_type { // Only keep any lines starting with `CUSTOM_TRY_JOB_PREFIX`. - MergeType::Try { try_jobs } => { - // If we do not have any custom try jobs, keep the ones that might be in the PR - // description. - pr_description = if try_jobs.is_empty() { - pr_description - .lines() - .map(|l| l.trim()) - .filter(|l| l.starts_with(CUSTOM_TRY_JOB_PREFIX)) - .join("\n") - } else { - // If we do have custom jobs, ignore the original description completely - String::new() - }; + MergeType::Try { try_jobs } if try_jobs.is_empty() => { + pr.github + .message + .lines() + .map(|l| l.trim()) + .filter(|l| l.starts_with(CUSTOM_TRY_JOB_PREFIX)) + .join("\n") } - MergeType::Auto => {} + // If we do not have any custom try jobs, keep the ones that might be in the PR + // description. + MergeType::Try { .. } => String::new(), + MergeType::Auto => pr.github.message.clone(), }; let mut message = format!( diff --git a/src/utils/text.rs b/src/utils/text.rs index 81f7b943..18de5cd9 100644 --- a/src/utils/text.rs +++ b/src/utils/text.rs @@ -1,19 +1,5 @@ -use regex::{Captures, Regex}; use std::borrow::Cow; -/// Replaces github @mentions with backticks to prevent accidental pings -pub fn suppress_github_mentions(text: &str) -> String { - if !text.contains('@') { - return text.to_string(); - } - - let pattern = r"\B(@\S+)"; - - let re = Regex::new(pattern).unwrap(); - re.replace_all(text, |caps: &Captures| format!("`{}`", &caps[1])) - .to_string() -} - /// Pluralizes a piece of text. pub fn pluralize(base: &str, count: usize) -> Cow<'_, str> { if count == 1 { @@ -27,16 +13,6 @@ pub fn pluralize(base: &str, count: usize) -> Cow<'_, str> { mod tests { use super::*; - #[test] - fn test_suppress_github_mentions() { - assert_eq!(suppress_github_mentions("r? @matklad\n"), "r? `@matklad`\n"); - assert_eq!(suppress_github_mentions("@bors r+\n"), "`@bors` r+\n"); - assert_eq!( - suppress_github_mentions("mail@example.com"), - "mail@example.com" - ) - } - #[test] fn pluralize_zero() { assert_eq!(pluralize("foo", 0), "foos"); From 3d65776d2fa232acc75168c6b6bda8bd5e948909 Mon Sep 17 00:00:00 2001 From: Nurseit Date: Wed, 12 Nov 2025 01:01:47 +0600 Subject: [PATCH 2/4] Return back regex crate --- Cargo.lock | 1 + Cargo.toml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 59127870..f4fba36d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -295,6 +295,7 @@ dependencies = [ "octocrab", "parking_lot", "pulldown-cmark", + "regex", "reqwest", "secrecy", "serde", diff --git a/Cargo.toml b/Cargo.toml index 0befe492..c2a0d7b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,12 +59,14 @@ itertools = "0.14" # Text processing pulldown-cmark = "0.13" +regex = "1" [dev-dependencies] insta = "1.26" wiremock = "0.6" base64 = "0.22" tracing-test = "0.2" +regex = "1" parking_lot = "0.12" thread_local = "1" sqlparser = { version = "0.59", features = ["visitor"] } From 14971cc381e762e1444d75de778d16856f04ee97 Mon Sep 17 00:00:00 2001 From: Nurseit Date: Wed, 12 Nov 2025 01:10:06 +0600 Subject: [PATCH 3/4] Apply fmt all --- src/bors/mod.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/bors/mod.rs b/src/bors/mod.rs index 3fbd2adc..edb7f799 100644 --- a/src/bors/mod.rs +++ b/src/bors/mod.rs @@ -129,14 +129,13 @@ pub fn create_merge_commit_message(pr: handlers::PullRequestData, merge_type: Me let pr_description = match &merge_type { // Only keep any lines starting with `CUSTOM_TRY_JOB_PREFIX`. - MergeType::Try { try_jobs } if try_jobs.is_empty() => { - pr.github - .message - .lines() - .map(|l| l.trim()) - .filter(|l| l.starts_with(CUSTOM_TRY_JOB_PREFIX)) - .join("\n") - } + MergeType::Try { try_jobs } if try_jobs.is_empty() => pr + .github + .message + .lines() + .map(|l| l.trim()) + .filter(|l| l.starts_with(CUSTOM_TRY_JOB_PREFIX)) + .join("\n"), // If we do not have any custom try jobs, keep the ones that might be in the PR // description. MergeType::Try { .. } => String::new(), From ac5a8fffdd439f4d97c4cf53fc402e8987c2ccc7 Mon Sep 17 00:00:00 2001 From: Nurseit Date: Thu, 13 Nov 2025 01:36:20 +0600 Subject: [PATCH 4/4] Return back comments --- src/bors/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bors/mod.rs b/src/bors/mod.rs index edb7f799..c1caf39d 100644 --- a/src/bors/mod.rs +++ b/src/bors/mod.rs @@ -129,6 +129,8 @@ pub fn create_merge_commit_message(pr: handlers::PullRequestData, merge_type: Me let pr_description = match &merge_type { // Only keep any lines starting with `CUSTOM_TRY_JOB_PREFIX`. + // If we do not have any custom try jobs, keep the ones that might be in the PR + // description. MergeType::Try { try_jobs } if try_jobs.is_empty() => pr .github .message @@ -136,8 +138,7 @@ pub fn create_merge_commit_message(pr: handlers::PullRequestData, merge_type: Me .map(|l| l.trim()) .filter(|l| l.starts_with(CUSTOM_TRY_JOB_PREFIX)) .join("\n"), - // If we do not have any custom try jobs, keep the ones that might be in the PR - // description. + // If we do have custom jobs, ignore the original description completely MergeType::Try { .. } => String::new(), MergeType::Auto => pr.github.message.clone(), };