diff --git a/src/config.rs b/src/config.rs index 8312aab3..db4e8ca4 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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 { diff --git a/src/handlers.rs b/src/handlers.rs index 7e4a04f9..acb18c15 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -133,6 +133,29 @@ macro_rules! issue_handlers { config: &Arc, errors: &mut Vec, ) { + 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::(&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)),