From 60279a20d6b90a9b954daee9a04af4a9a0a0b155 Mon Sep 17 00:00:00 2001 From: MarcoIeni <11428655+MarcoIeni@users.noreply.github.com> Date: Wed, 27 Aug 2025 12:59:38 +0200 Subject: [PATCH] support mentioning rust-rfcbot --- README.md | 7 ++++--- src/config.rs | 3 ++- src/github/command.rs | 19 +++++++++++++++---- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5b1323a9..35e1577d 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ > > The new account used by the bot is [rust-rfcbot](https://github.com/rust-rfcbot). > -> You still need to ping the old account, i.e. `@rfcbot`. +> You can mention either `@rfcbot` or `@rust-rfcbot`. -[rfcbot](https://github.com/rfcbot) manages asynchronous decision making on Rust issues and PRs. Status of Final Comment Periods can be viewed on [the relevant dashboard page](http://rfcbot.rs). +[rust-rfcbot](https://github.com/rust-rfcbot) manages asynchronous decision making on Rust issues and PRs. Status of Final Comment Periods can be viewed on [the relevant dashboard page](http://rfcbot.rs). It listens for commands on all repositories owned by the [rust-lang](https://github.com/rust-lang), [rust-lang-nursery](https://github.com/rust-lang-nursery), and [rust-lang-deprecated](https://github.com/rust-lang-deprecated) organizations. @@ -16,10 +16,11 @@ While its intended usage is for RFCs, you can use its tracking on any issue or p ## Usage -rfcbot accepts commands in GitHub comments. All commands take the form: +rfcbot accepts commands in GitHub comments. All commands take one of the following forms: ``` @rfcbot COMMAND [PARAMS] +@rust-rfcbot COMMAND [PARAMS] ``` Each command must start on its own line, but otherwise the bot doesn't care if there's other text in the comment. This is valid: diff --git a/src/config.rs b/src/config.rs index c6e98eb2..16f1a6c0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -32,7 +32,8 @@ use std::collections::BTreeMap; use std::env; -pub const RFC_BOT_MENTION: &str = "@rfcbot"; +/// All valid mention handles that should trigger rfcbot. +pub const RFC_BOT_MENTIONS: [&str; 2] = ["@rfcbot", "@rust-rfcbot"]; pub const GH_ORGS: [&str; 3] = ["rust-lang", "rust-lang-nursery", "rust-lang-deprecated"]; lazy_static! { diff --git a/src/github/command.rs b/src/github/command.rs index b9a51abd..a9dcb64b 100644 --- a/src/github/command.rs +++ b/src/github/command.rs @@ -1,7 +1,7 @@ use std::collections::BTreeSet; use std::fmt; -use crate::config::RFC_BOT_MENTION; +use crate::config::RFC_BOT_MENTIONS; use crate::error::{DashError, DashResult}; use crate::teams::{RfcbotConfig, TeamLabel}; @@ -218,8 +218,12 @@ fn from_invocation_line<'a>( setup: &'a RfcbotConfig, command: &'a str, ) -> DashResult> { - let mut tokens = command - .trim_start_matches(RFC_BOT_MENTION) + // Strip bot mention prefix + let mention_stripped = RFC_BOT_MENTIONS + .iter() + .fold(command, |acc, mention| acc.trim_start_matches(mention)); + + let mut tokens = mention_stripped .trim() .trim_start_matches(':') .trim() @@ -271,7 +275,7 @@ impl<'a> RfcBotCommand<'a> { command .lines() .map(str::trim) - .filter(|&l| l.starts_with(RFC_BOT_MENTION)) + .filter(|&l| RFC_BOT_MENTIONS.iter().any(|m| l.starts_with(m))) .map(move |l| from_invocation_line(setup, l)) .filter_map(Result::ok) } @@ -658,4 +662,11 @@ somemoretext"; some_text!("@bob"), RfcBotCommand::FeedbackRequest("bob") ); + + #[test] + fn accepts_rust_rfcbot_alias() { + let body = "@rust-rfcbot: fcp cancel"; + let with_alias = ensure_take_singleton(parse_commands(body)); + assert_eq!(with_alias, RfcBotCommand::FcpCancel); + } }