MCPcopy Create free account
hub / github.com/AI45Lab/Code / remove_worktree

Method remove_worktree

core/src/tools/builtin/git.rs:504–533  ·  view source on GitHub ↗

Remove a worktree.

(
        &self,
        args: &serde_json::Value,
        worktree: &dyn WorkspaceGitWorktreeProvider,
    )

Source from the content-addressed store, hash-verified

502
503 /// Remove a worktree.
504 async fn remove_worktree(
505 &self,
506 args: &serde_json::Value,
507 worktree: &dyn WorkspaceGitWorktreeProvider,
508 ) -> Result<ToolOutput> {
509 let path = match args.get("path").and_then(|v| v.as_str()) {
510 Some(p) => p,
511 None => {
512 return Ok(ToolOutput::error(
513 "path parameter is required for worktree remove",
514 ))
515 }
516 };
517
518 let force = args.get("force").and_then(|v| v.as_bool()).unwrap_or(false);
519
520 match worktree
521 .remove_worktree(WorkspaceGitRemoveWorktreeRequest {
522 path: path.to_string(),
523 force,
524 })
525 .await
526 {
527 Ok(result) => Ok(ToolOutput::success(format!(
528 "Removed worktree at: {}",
529 result.path
530 ))),
531 Err(e) => Ok(ToolOutput::error(format!("Failed to remove worktree: {e}"))),
532 }
533 }
534}
535
536fn short_commit_id(id: &str) -> &str {

Callers 1

worktreeMethod · 0.45

Calls 2

getMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected