Skip to content

Commit 4032d04

Browse files
authored
Merge pull request #2026 from Urgau/rework-concern-note-help
Rework `concern` and `note` help message
2 parents f658c5d + 0a8bcea commit 4032d04

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/handlers/concern.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub(super) async fn handle_command(
107107
}
108108

109109
// Create the new markdown content listing all the concerns
110-
let new_content = markdown_content(&concern_data.concerns);
110+
let new_content = markdown_content(&concern_data.concerns, &ctx.username);
111111

112112
// Add or remove the labels
113113
if concern_data
@@ -149,7 +149,7 @@ pub(super) async fn handle_command(
149149
Ok(())
150150
}
151151

152-
fn markdown_content(concerns: &[Concern]) -> String {
152+
fn markdown_content(concerns: &[Concern], bot: &str) -> String {
153153
if concerns.is_empty() {
154154
return "".to_string();
155155
}
@@ -185,7 +185,7 @@ fn markdown_content(concerns: &[Concern]) -> String {
185185
}
186186

187187
let _ = writeln!(md, "");
188-
let _ = writeln!(md, "Generated by triagebot, see [help](https://forge.rust-lang.org/triagebot/concern.html) for how to use them.");
188+
let _ = writeln!(md, "*Managed by `@{bot}`—see [help](https://forge.rust-lang.org/triagebot/concern.html) for details.*");
189189

190190
md
191191
}
@@ -210,14 +210,14 @@ fn simple_markdown_content() {
210210
];
211211

212212
assert_eq!(
213-
markdown_content(concerns),
213+
markdown_content(concerns, "rustbot"),
214214
r#"
215215
# Concerns
216216
217217
- [This is my concern about concern](https://github.com/fake-comment-1234) by [Urgau](https://github.com/Urgau)
218218
- ~~[This is a resolved concern](https://github.com/fake-comment-4561) by [Kobzol](https://github.com/Kobzol)~~ resolved [in this comment](https:://github.com/fake-comment-8888)
219219
220-
Generated by triagebot, see [help](https://forge.rust-lang.org/triagebot/concern.html) for how to use them.
220+
*Managed by `@rustbot`—see [help](https://forge.rust-lang.org/triagebot/concern.html) for details.*
221221
"#
222222
);
223223
}

src/handlers/note.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//!
1616
//! - [Summary title](link-to-comment) by [username](https://github.com/<username>)
1717
//!
18-
//! Generated by triagebot, see [help](https://forge.rust-lang.org/triagebot/note.html) for how to add more
18+
//! *Managed by `@bot`—see [help](https://forge.rust-lang.org/triagebot/note.html) for details*
1919
//! <!-- TRIAGEBOT_SUMMARY_END -->
2020
//! ```
2121
//!
@@ -37,6 +37,7 @@
3737
use crate::{config::NoteConfig, github::Event, handlers::Context, interactions::EditIssueBody};
3838
use itertools::Itertools;
3939
use parser::command::note::NoteCommand;
40+
use std::fmt::Write;
4041
use std::{cmp::Ordering, collections::HashMap};
4142
use tracing as log;
4243

@@ -100,7 +101,7 @@ impl NoteData {
100101
}
101102
}
102103

103-
pub(crate) fn to_markdown(&self) -> String {
104+
pub(crate) fn to_markdown(&self, bot: &str) -> String {
104105
if self.entries_by_url.is_empty() {
105106
return String::new();
106107
}
@@ -109,7 +110,7 @@ impl NoteData {
109110
for (_, entry) in self.entries_by_url.iter().sorted() {
110111
text.push_str(&entry.to_markdown());
111112
}
112-
text.push_str("\n\nGenerated by triagebot, see [help](https://forge.rust-lang.org/triagebot/note.html) for how to add more");
113+
let _ = writeln!(text, "\n\n*Managed by `@{bot}`—see [help](https://forge.rust-lang.org/triagebot/note.html) for details*");
113114
text
114115
}
115116
}
@@ -154,7 +155,7 @@ pub(super) async fn handle_command(
154155
}
155156
}
156157

157-
let new_markdown = current.to_markdown();
158+
let new_markdown = current.to_markdown(&ctx.username);
158159
log::debug!("New MD: {:#?}", new_markdown);
159160

160161
e.apply(&ctx.github, new_markdown, current).await?;

0 commit comments

Comments
 (0)