huskies: merge 876

This commit is contained in:
dave
2026-04-29 21:14:27 +00:00
parent 56244e8e35
commit db526bbdb2
6 changed files with 65 additions and 63 deletions
+49
View File
@@ -133,6 +133,55 @@ mod tests {
);
}
#[tokio::test]
async fn remove_worktree_by_story_id_cleans_git_metadata_and_branch() {
let tmp = TempDir::new().unwrap();
let project_root = tmp.path().join("my-project");
fs::create_dir_all(&project_root).unwrap();
init_git_repo(&project_root);
let story_id = "89_regression_remove";
let expected_branch = format!("feature/story-{story_id}");
super::super::create::create_worktree(&project_root, story_id, &empty_config(), 3001)
.await
.unwrap();
let wt_path = super::super::worktree_path(&project_root, story_id);
assert!(wt_path.exists(), "worktree must exist before removal");
let result = remove_worktree_by_story_id(&project_root, story_id, &empty_config()).await;
assert!(
result.is_ok(),
"Expected removal to succeed: {:?}",
result.err()
);
// Regression: `git worktree list` must not show the removed worktree.
let wt_list_output = std::process::Command::new("git")
.args(["worktree", "list", "--porcelain"])
.current_dir(&project_root)
.output()
.expect("git worktree list");
let wt_list = String::from_utf8_lossy(&wt_list_output.stdout);
assert!(
!wt_list.contains(&*wt_path.to_string_lossy()),
"git worktree list should not contain the removed worktree path, but got:\n{wt_list}"
);
// Regression: feature branch must be deleted after worktree removal.
let branch_output = std::process::Command::new("git")
.args(["branch", "--list", &expected_branch])
.current_dir(&project_root)
.output()
.expect("git branch --list");
let branch_list = String::from_utf8_lossy(&branch_output.stdout);
assert!(
branch_list.trim().is_empty(),
"Feature branch '{expected_branch}' should be deleted, but found: {branch_list}"
);
}
#[tokio::test]
async fn remove_worktree_async_removes_directory() {
let tmp = TempDir::new().unwrap();