Create a new worktree.
(
repo_path: &Path,
branch: &str,
path: &Path,
new_branch: bool,
)
| 580 | |
| 581 | /// Create a new worktree. |
| 582 | pub fn create_worktree( |
| 583 | repo_path: &Path, |
| 584 | branch: &str, |
| 585 | path: &Path, |
| 586 | new_branch: bool, |
| 587 | ) -> Result<()> { |
| 588 | let path_str = path.display().to_string(); |
| 589 | let args: Vec<&str> = if new_branch { |
| 590 | vec!["worktree", "add", "-b", branch, &path_str] |
| 591 | } else { |
| 592 | vec!["worktree", "add", &path_str, branch] |
| 593 | }; |
| 594 | |
| 595 | let (success, _, stderr) = run_git(repo_path, &args)?; |
| 596 | if !success { |
| 597 | return Err(anyhow!("Failed to create worktree: {}", stderr)); |
| 598 | } |
| 599 | Ok(()) |
| 600 | } |
| 601 | |
| 602 | /// Remove a worktree. |
| 603 | pub fn remove_worktree(repo_path: &Path, path: &Path, force: bool) -> Result<()> { |
no test coverage detected