()
| 354 | |
| 355 | #[tokio::test] |
| 356 | async fn test_detect_project_name_from_worktree() { |
| 357 | let temp_base = TempDir::new().unwrap(); |
| 358 | let main_repo_dir = temp_base.path().join("my-real-project"); |
| 359 | std::fs::create_dir(&main_repo_dir).unwrap(); |
| 360 | |
| 361 | let output = std::process::Command::new("git") |
| 362 | .args(["init"]) |
| 363 | .current_dir(&main_repo_dir) |
| 364 | .output() |
| 365 | .unwrap(); |
| 366 | assert!(output.status.success()); |
| 367 | |
| 368 | std::process::Command::new("git") |
| 369 | .args(["config", "user.email", "test@example.com"]) |
| 370 | .current_dir(&main_repo_dir) |
| 371 | .output() |
| 372 | .unwrap(); |
| 373 | std::process::Command::new("git") |
| 374 | .args(["config", "user.name", "Test User"]) |
| 375 | .current_dir(&main_repo_dir) |
| 376 | .output() |
| 377 | .unwrap(); |
| 378 | |
| 379 | std::fs::write(main_repo_dir.join("file.txt"), "content").unwrap(); |
| 380 | std::process::Command::new("git") |
| 381 | .args(["add", "."]) |
| 382 | .current_dir(&main_repo_dir) |
| 383 | .output() |
| 384 | .unwrap(); |
| 385 | std::process::Command::new("git") |
| 386 | .args(["commit", "-m", "init"]) |
| 387 | .current_dir(&main_repo_dir) |
| 388 | .output() |
| 389 | .unwrap(); |
| 390 | |
| 391 | // Create worktree with a different name |
| 392 | let worktree_dir = temp_base.path().join("my-real-project-wt"); |
| 393 | std::process::Command::new("git") |
| 394 | .args([ |
| 395 | "worktree", |
| 396 | "add", |
| 397 | worktree_dir.to_str().unwrap(), |
| 398 | "-b", |
| 399 | "wt-proj", |
| 400 | ]) |
| 401 | .current_dir(&main_repo_dir) |
| 402 | .output() |
| 403 | .unwrap(); |
| 404 | |
| 405 | // Detect project name from worktree — should return main repo's name |
| 406 | let name = detect_project_name(&worktree_dir).await.unwrap(); |
| 407 | assert_eq!(name, "my-real-project"); |
| 408 | |
| 409 | // Clean up |
| 410 | std::fs::remove_dir_all(&worktree_dir).ok(); |
| 411 | } |
| 412 | } |
nothing calls this directly
no test coverage detected