huskies: merge 530_story_eliminate_filesystem_markdown_shadows_entirely_crdt_db_is_the_only_story_store
This commit is contained in:
@@ -61,7 +61,7 @@ pub async fn handle_delete(
|
||||
agents: &AgentPool,
|
||||
) -> String {
|
||||
// Find the story by numeric prefix: CRDT → content store → filesystem.
|
||||
let (story_id, stage, path, content) =
|
||||
let (story_id, stage, _path, content) =
|
||||
match crate::chat::lookup::find_story_by_number(project_root, story_number) {
|
||||
Some(found) => found,
|
||||
None => {
|
||||
@@ -72,7 +72,6 @@ pub async fn handle_delete(
|
||||
};
|
||||
|
||||
let story_name = content
|
||||
.or_else(|| std::fs::read_to_string(&path).ok())
|
||||
.and_then(|contents| {
|
||||
crate::io::story_metadata::parse_front_matter(&contents)
|
||||
.ok()
|
||||
@@ -103,23 +102,9 @@ pub async fn handle_delete(
|
||||
// Remove the worktree if one exists (best-effort; ignore errors).
|
||||
let _ = crate::worktree::prune_worktree_sync(project_root, &story_id);
|
||||
|
||||
// Delete the story file.
|
||||
if let Err(e) = std::fs::remove_file(&path) {
|
||||
return format!("Failed to delete story {story_number}: {e}");
|
||||
}
|
||||
|
||||
// Commit the deletion to git.
|
||||
let commit_msg = format!("huskies: delete {story_id}");
|
||||
let work_rel = std::path::PathBuf::from(".huskies").join("work");
|
||||
let _ = std::process::Command::new("git")
|
||||
.args(["add", "-A"])
|
||||
.arg(&work_rel)
|
||||
.current_dir(project_root)
|
||||
.output();
|
||||
let _ = std::process::Command::new("git")
|
||||
.args(["commit", "-m", &commit_msg])
|
||||
.current_dir(project_root)
|
||||
.output();
|
||||
// Delete from the content store and CRDT.
|
||||
crate::db::delete_content(&story_id);
|
||||
crate::db::delete_item(&story_id);
|
||||
|
||||
// Build the response.
|
||||
let stage_label = stage_display_name(&stage);
|
||||
@@ -265,47 +250,24 @@ mod tests {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let project_root = tmp.path();
|
||||
|
||||
// Init a bare git repo so the commit step doesn't fail fatally.
|
||||
std::process::Command::new("git")
|
||||
.args(["init"])
|
||||
.current_dir(project_root)
|
||||
.output()
|
||||
.unwrap();
|
||||
std::process::Command::new("git")
|
||||
.args(["config", "user.email", "test@test.com"])
|
||||
.current_dir(project_root)
|
||||
.output()
|
||||
.unwrap();
|
||||
std::process::Command::new("git")
|
||||
.args(["config", "user.name", "Test"])
|
||||
.current_dir(project_root)
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
let backlog_dir = project_root.join(".huskies").join("work").join("1_backlog");
|
||||
std::fs::create_dir_all(&backlog_dir).unwrap();
|
||||
let story_path = backlog_dir.join("42_story_some_feature.md");
|
||||
std::fs::write(&story_path, "---\nname: Some Feature\n---\n\n# Story 42\n").unwrap();
|
||||
|
||||
// Initial commit so git doesn't complain about no commits.
|
||||
std::process::Command::new("git")
|
||||
.args(["add", "-A"])
|
||||
.current_dir(project_root)
|
||||
.output()
|
||||
.unwrap();
|
||||
std::process::Command::new("git")
|
||||
.args(["commit", "-m", "init"])
|
||||
.current_dir(project_root)
|
||||
.output()
|
||||
.unwrap();
|
||||
// Seed the story in the content store + CRDT (no filesystem needed).
|
||||
crate::db::ensure_content_store();
|
||||
crate::db::write_item_with_content(
|
||||
"9975_story_some_feature",
|
||||
"1_backlog",
|
||||
"---\nname: Some Feature\n---\n\n# Story 9975\n",
|
||||
);
|
||||
|
||||
let agents = std::sync::Arc::new(crate::agents::AgentPool::new_test(3000));
|
||||
let response = handle_delete("Timmy", "42", project_root, &agents).await;
|
||||
let response = handle_delete("Timmy", "9975", project_root, &agents).await;
|
||||
|
||||
assert!(
|
||||
response.contains("Some Feature") && response.contains("backlog"),
|
||||
"unexpected response: {response}"
|
||||
);
|
||||
assert!(!story_path.exists(), "story file should have been deleted");
|
||||
assert!(
|
||||
crate::db::read_content("9975_story_some_feature").is_none(),
|
||||
"content store should no longer contain the deleted story"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user