From 488d5071944a1d47be3ff0f76abea79b6e3df46f Mon Sep 17 00:00:00 2001 From: Luke Street Date: Tue, 15 Apr 2025 16:19:56 -0600 Subject: [PATCH] Permit game versions with .'s --- src/github/mod.rs | 13 +++++++------ src/handlers/report.rs | 29 ++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/github/mod.rs b/src/github/mod.rs index b8ff10f..967e7e7 100644 --- a/src/github/mod.rs +++ b/src/github/mod.rs @@ -107,11 +107,12 @@ pub async fn run( .send() .await .context("Failed to fetch workflows")?; - let Some(workflow) = workflows - .items - .iter() - .find(|w| w.path.ends_with("build.yml") || w.path.ends_with("progress.yml")) - else { + let Some(workflow) = workflows.items.iter().find(|w| { + w.path.ends_with("build.yml") + || w.path.ends_with("build.yaml") + || w.path.ends_with("progress.yml") + || w.path.ends_with("progress.yaml") + }) else { log::warn!("No known workflow found for {}/{}", owner_name, repo_name); return Ok(()); }; @@ -268,7 +269,7 @@ async fn process_workflow_run( } static REGEX: OnceLock = OnceLock::new(); let regex = REGEX - .get_or_init(|| Regex::new(r"^(?P[A-z0-9_\-]+)[_-]report(?:[_-].*)?$").unwrap()); + .get_or_init(|| Regex::new(r"^(?P[A-z0-9_.\-]+)[_-]report(?:[_-].*)?$").unwrap()); let sem = Arc::new(Semaphore::new(3)); let mut set = JoinSet::new(); struct TaskResult { diff --git a/src/handlers/report.rs b/src/handlers/report.rs index 8cebde7..c006199 100644 --- a/src/handlers/report.rs +++ b/src/handlers/report.rs @@ -168,23 +168,34 @@ impl From<&Measures> for TemplateMeasures { } } +fn is_valid_extension(ext: &str) -> bool { + // FIXME: hack for versions that have .nn where nn is a number + ext.chars().any(|c| c.is_ascii_alphabetic()) +} + fn extract_extension(params: ReportParams) -> (ReportParams, Option) { if let Some(commit) = params.commit.as_deref() { if let Some((commit, ext)) = commit.rsplit_once('.') { - return ( - ReportParams { commit: Some(commit.to_string()), ..params }, - Some(ext.to_string()), - ); + if is_valid_extension(ext) { + return ( + ReportParams { commit: Some(commit.to_string()), ..params }, + Some(ext.to_string()), + ); + } } } else if let Some(version) = params.version.as_deref() { if let Some((version, ext)) = version.rsplit_once('.') { - return ( - ReportParams { version: Some(version.to_string()), ..params }, - Some(ext.to_string()), - ); + if is_valid_extension(ext) { + return ( + ReportParams { version: Some(version.to_string()), ..params }, + Some(ext.to_string()), + ); + } } } else if let Some((repo, ext)) = params.repo.rsplit_once('.') { - return (ReportParams { repo: repo.to_string(), ..params }, Some(ext.to_string())); + if is_valid_extension(ext) { + return (ReportParams { repo: repo.to_string(), ..params }, Some(ext.to_string())); + } } (params, None) }