Skip to content

Commit

Permalink
feat: valdiate proposed change in triagetoml for PRs ✨
Browse files Browse the repository at this point in the history
fixes rust-lang/rust#106104

a successful run is visible here: meysam81/triagebot-test#2 (comment)
  • Loading branch information
meysam81 committed Nov 12, 2023
1 parent 619e2f1 commit 1316aa6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ lazy_static::lazy_static! {
RwLock::new(HashMap::new());
}

pub fn config_file_name() -> &'static str {
CONFIG_FILE_NAME
}

#[derive(PartialEq, Eq, Debug, serde::Deserialize)]
#[serde(rename_all = "kebab-case")]
pub(crate) struct Config {
Expand Down
23 changes: 23 additions & 0 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,29 @@ macro_rules! issue_handlers {
config: &Arc<Config>,
errors: &mut Vec<HandlerError>,
) {
if event.issue.is_pr() {
if let Ok(Some(diff)) = event.issue.diff(&ctx.github).await {
if let Some(source) = &event.issue.head {
if diff.contains(config::config_file_name()) {
if let Some(Some(triagebot_toml)) = ctx.github
.raw_file(&source.repo.full_name, &source.git_ref, crate::config::config_file_name())
.await.ok() {
match toml::from_slice::<crate::handlers::Config>(&triagebot_toml) {
Ok(_) => {},
Err(err) => {
errors.push(HandlerError::Message(format!(
"The triagebot.toml file is not a valid config file.\n\
Error: {}",
err
)));
}
}
}
}
}
}
}

$(
match $name::parse_input(ctx, event, config.$name.as_ref()).await {
Err(err) => errors.push(HandlerError::Message(err)),
Expand Down

0 comments on commit 1316aa6

Please sign in to comment.