diff --git a/Cargo.lock b/Cargo.lock index 8b8331a..91fb52d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1494,7 +1494,7 @@ dependencies = [ [[package]] name = "worklane" -version = "0.11.0" +version = "0.11.1" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 95b3d73..34709b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "worklane" -version = "0.11.0" +version = "0.11.1" edition = "2024" [dependencies] diff --git a/src/util.rs b/src/util.rs index 5e63fbd..b8a4591 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1706,7 +1706,13 @@ pub fn display_ticket_items(items: &[TicketItem]) { } pub fn collect_ticket_items(status_path: impl AsRef) -> Result> { - let entries: Vec<_> = fs::read_dir(status_path)?.filter_map(|e| e.ok()).collect(); + let entries: Vec<_> = fs::read_dir(status_path)? + .filter_map(|e| e.ok()) + // A status directory is a plain directory, so anything can be dropped in it. + // Without the extension a stray notes.txt was listed as a titleless ticket and + // counted in the summary alongside the real ones. + .filter(|e| e.path().extension().is_some_and(|ext| ext == "md")) + .collect(); let mut items: Vec = entries .iter() @@ -2152,6 +2158,29 @@ mod tests { fs::remove_dir_all(&dir).unwrap(); } + #[test] + fn collect_ticket_items_lists_only_md_files() { + let dir = std::env::temp_dir().join(format!("worklane-stray-{}", uuid::Uuid::new_v4())); + fs::create_dir_all(&dir).unwrap(); + + fs::write( + dir.join("11111111-0000-4000-8000-000000000001.md"), + "# Real\n\n## Metadata\n\n- **Owner**: alice\n", + ) + .unwrap(); + fs::write(dir.join("notes.txt"), "# Stray\n").unwrap(); + // A directory read_to_string happened to reject, so it was already skipped by + // accident. Kept here so the extension filter is what keeps it out. + fs::create_dir_all(dir.join("subdir")).unwrap(); + + let items = collect_ticket_items(&dir).unwrap(); + let titles: Vec<&str> = items.iter().map(|item| item.title.as_str()).collect(); + + assert_eq!(titles, vec!["Real"], "{titles:?}"); + + fs::remove_dir_all(&dir).unwrap(); + } + #[test] fn a_section_rule_matches_the_width_of_its_name() { let rendered = content_trim_colored("# T\n\n## Description\nbody\n", "");