Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@
>
> 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.

While its intended usage is for RFCs, you can use its tracking on any issue or pull request which needs an async review/decision cycle.

## 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:
Expand Down
3 changes: 2 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down
19 changes: 15 additions & 4 deletions src/github/command.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -218,8 +218,12 @@ fn from_invocation_line<'a>(
setup: &'a RfcbotConfig,
command: &'a str,
) -> DashResult<RfcBotCommand<'a>> {
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()
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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);
}
}