Skip to content

Commit 07c7408

Browse files
committed
Get rid of username notification checker in merge commit messages
1 parent a007de5 commit 07c7408

File tree

4 files changed

+12
-45
lines changed

4 files changed

+12
-45
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,12 @@ itertools = "0.14"
5959

6060
# Text processing
6161
pulldown-cmark = "0.13"
62-
regex = "1"
6362

6463
[dev-dependencies]
6564
insta = "1.26"
6665
wiremock = "0.6"
6766
base64 = "0.22"
6867
tracing-test = "0.2"
69-
regex = "1"
7068
parking_lot = "0.12"
7169
thread_local = "1"
7270
sqlparser = { version = "0.59", features = ["visitor"] }

src/bors/mod.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use crate::github::api::client::GithubRepositoryClient;
1818
use crate::permissions::UserPermissions;
1919
#[cfg(test)]
2020
use crate::tests::TestSyncMarker;
21-
use crate::utils::text::suppress_github_mentions;
2221

2322
mod command;
2423
pub mod comment;
@@ -128,25 +127,20 @@ pub fn create_merge_commit_message(pr: handlers::PullRequestData, merge_type: Me
128127
MergeType::Auto => pr.db.approver().unwrap_or("<unknown>"),
129128
};
130129

131-
let mut pr_description = suppress_github_mentions(&pr.github.message);
132-
match &merge_type {
133-
// Strip all PR text for try builds, to avoid useless issue pings on the repository.
130+
let pr_description = match &merge_type {
134131
// Only keep any lines starting with `CUSTOM_TRY_JOB_PREFIX`.
135-
MergeType::Try { try_jobs } => {
136-
// If we do not have any custom try jobs, keep the ones that might be in the PR
137-
// description.
138-
pr_description = if try_jobs.is_empty() {
139-
pr_description
140-
.lines()
141-
.map(|l| l.trim())
142-
.filter(|l| l.starts_with(CUSTOM_TRY_JOB_PREFIX))
143-
.join("\n")
144-
} else {
145-
// If we do have custom jobs, ignore the original description completely
146-
String::new()
147-
};
132+
MergeType::Try { try_jobs } if try_jobs.is_empty() => {
133+
pr.github
134+
.message
135+
.lines()
136+
.map(|l| l.trim())
137+
.filter(|l| l.starts_with(CUSTOM_TRY_JOB_PREFIX))
138+
.join("\n")
148139
}
149-
MergeType::Auto => {}
140+
// If we do not have any custom try jobs, keep the ones that might be in the PR
141+
// description.
142+
MergeType::Try { .. } => String::new(),
143+
MergeType::Auto => pr.github.message.clone(),
150144
};
151145

152146
let mut message = format!(

src/utils/text.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
1-
use regex::{Captures, Regex};
21
use std::borrow::Cow;
32

4-
/// Replaces github @mentions with backticks to prevent accidental pings
5-
pub fn suppress_github_mentions(text: &str) -> String {
6-
if !text.contains('@') {
7-
return text.to_string();
8-
}
9-
10-
let pattern = r"\B(@\S+)";
11-
12-
let re = Regex::new(pattern).unwrap();
13-
re.replace_all(text, |caps: &Captures| format!("`{}`", &caps[1]))
14-
.to_string()
15-
}
16-
173
/// Pluralizes a piece of text.
184
pub fn pluralize(base: &str, count: usize) -> Cow<'_, str> {
195
if count == 1 {
@@ -27,16 +13,6 @@ pub fn pluralize(base: &str, count: usize) -> Cow<'_, str> {
2713
mod tests {
2814
use super::*;
2915

30-
#[test]
31-
fn test_suppress_github_mentions() {
32-
assert_eq!(suppress_github_mentions("r? @matklad\n"), "r? `@matklad`\n");
33-
assert_eq!(suppress_github_mentions("@bors r+\n"), "`@bors` r+\n");
34-
assert_eq!(
35-
suppress_github_mentions("mail@example.com"),
36-
"mail@example.com"
37-
)
38-
}
39-
4016
#[test]
4117
fn pluralize_zero() {
4218
assert_eq!(pluralize("foo", 0), "foos");

0 commit comments

Comments
 (0)