huskies: merge 576_bug_overview_command_reads_story_files_from_filesystem_instead_of_crdt

This commit is contained in:
dave
2026-04-15 14:02:01 +00:00
parent c34b119526
commit 70fecafd41
+4 -49
View File
@@ -105,58 +105,13 @@ fn find_story_merge_commit(root: &std::path::Path, num_str: &str) -> Option<Stri
if hash.is_empty() { None } else { Some(hash) } if hash.is_empty() { None } else { Some(hash) }
} }
/// Find the human-readable name of a story by searching content store then filesystem. /// Find the human-readable name of a story by searching CRDT then content store.
fn find_story_name(root: &std::path::Path, num_str: &str) -> Option<String> { fn find_story_name(root: &std::path::Path, num_str: &str) -> Option<String> {
// Try content store first. let (_, _, _, content) = crate::chat::lookup::find_story_by_number(root, num_str)?;
for id in crate::db::all_content_ids() { let content = content?;
let file_num = id.split('_').next().unwrap_or(""); crate::io::story_metadata::parse_front_matter(&content)
if file_num == num_str
&& let Some(c) = crate::db::read_content(&id)
{
return crate::io::story_metadata::parse_front_matter(&c)
.ok()
.and_then(|m| m.name);
}
}
// Fallback: filesystem scan.
let stages = [
"1_backlog",
"2_current",
"3_qa",
"4_merge",
"5_done",
"6_archived",
];
for stage in &stages {
let dir = root.join(".huskies").join("work").join(stage);
if !dir.exists() {
continue;
}
if let Ok(entries) = std::fs::read_dir(&dir) {
for entry in entries.flatten() {
let path = entry.path();
if path.extension().and_then(|e| e.to_str()) != Some("md") {
continue;
}
if let Some(stem) = path.file_stem().and_then(|s| s.to_str()) {
let file_num = stem
.split('_')
.next()
.filter(|s| !s.is_empty() && s.chars().all(|c| c.is_ascii_digit()))
.unwrap_or("");
if file_num == num_str {
return std::fs::read_to_string(&path).ok().and_then(|c| {
crate::io::story_metadata::parse_front_matter(&c)
.ok() .ok()
.and_then(|m| m.name) .and_then(|m| m.name)
});
}
}
}
}
}
None
} }
/// Return the `git show --stat` output for a commit. /// Return the `git show --stat` output for a commit.