Skip to content

Commit 4fca11d

Browse files
committed
Use ErrorComment for emitting the validation config error
1 parent a8013bb commit 4fca11d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/handlers/check_commits.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use anyhow::Context as _;
44
use anyhow::bail;
55

66
use super::Context;
7+
use crate::interactions::ErrorComment;
78
use crate::{
89
config::Config,
910
db::issue_data::IssueData,
@@ -157,7 +158,8 @@ async fn handle_new_state(
157158
}
158159

159160
for error_to_add in errors_to_add {
160-
let comment = event.issue.post_comment(&ctx.github, &error_to_add).await?;
161+
let error_comment = ErrorComment::new(&event.issue, &error_to_add);
162+
let comment = error_comment.post(&ctx.github).await?;
161163
state.data.last_errors.push((error_to_add, comment.node_id));
162164
}
163165
}

src/interactions.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use tokio_postgres::Client as DbClient;
44

55
use crate::{
66
db::issue_data::IssueData,
7-
github::{GithubClient, Issue},
7+
github::{Comment, GithubClient, Issue},
88
};
99
use std::fmt::Write;
1010

@@ -24,7 +24,7 @@ impl<'a> ErrorComment<'a> {
2424
}
2525
}
2626

27-
pub async fn post(&self, client: &GithubClient) -> anyhow::Result<()> {
27+
pub async fn post(&self, client: &GithubClient) -> anyhow::Result<Comment> {
2828
let mut body = String::new();
2929
writeln!(body, "**Error**: {}", self.message)?;
3030
writeln!(body)?;
@@ -33,8 +33,7 @@ impl<'a> ErrorComment<'a> {
3333
"Please file an issue on GitHub at [triagebot](https://github.com/rust-lang/triagebot) if there's \
3434
a problem with this bot, or reach out on [#t-infra](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra) on Zulip."
3535
)?;
36-
self.issue.post_comment(client, &body).await?;
37-
Ok(())
36+
self.issue.post_comment(client, &body).await
3837
}
3938
}
4039

0 commit comments

Comments
 (0)