diff --git a/Cargo.lock b/Cargo.lock index 85ed884c..c53beea6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4778,6 +4778,7 @@ dependencies = [ "serde_json", "session-store", "tempfile", + "ticket", "tokio", "tui", ] diff --git a/crates/ticket/src/lib.rs b/crates/ticket/src/lib.rs index 73c498c2..b7f20a52 100644 --- a/crates/ticket/src/lib.rs +++ b/crates/ticket/src/lib.rs @@ -514,6 +514,14 @@ impl TicketDoctorReport { path, }); } + + pub fn push_warning(&mut self, message: impl Into, path: Option) { + self.diagnostics.push(TicketDoctorDiagnostic { + severity: TicketDoctorSeverity::Warning, + message: message.into(), + path, + }); + } } pub trait TicketBackend { @@ -1010,15 +1018,13 @@ impl TicketBackend for LocalTicketBackend { ); } if status == TicketStatus::Closed && !dir.join("resolution.md").is_file() { - report.push_error( - format!("missing resolution.md for closed ticket: {}", dir.display()), + report.push_warning( + format!("closed ticket missing resolution.md: {}", dir.display()), Some(dir.join("resolution.md")), ); } if thread.exists() { - for diagnostic in doctor_thread_events(&thread)? { - report.push_error(diagnostic, Some(thread.clone())); - } + doctor_thread_events(&thread, &mut report)?; } if artifacts.exists() { doctor_artifacts(&artifacts, &mut report)?; @@ -1339,17 +1345,19 @@ fn parse_event_comment(comment: &str) -> BTreeMap { attrs } -fn doctor_thread_events(path: &Path) -> Result> { +fn doctor_thread_events(path: &Path, report: &mut TicketDoctorReport) -> Result<()> { let content = fs::read_to_string(path).map_err(|e| io_err(path, e))?; - let mut diagnostics = Vec::new(); for (line_no, line) in content.lines().enumerate() { let trimmed = line.trim(); if trimmed.starts_with("") { - diagnostics.push(format!( - "malformed thread event comment at {}:{}", - path.display(), - line_no + 1 - )); + report.push_error( + format!( + "malformed thread event comment at {}:{}", + path.display(), + line_no + 1 + ), + Some(path.to_path_buf()), + ); } if let Some(comment) = trimmed .strip_prefix("