Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
perf: reuse repo/config in `wt remove` approval path (#1875)
Maximilian Roos8bbcd24d5375
diff --git a/src/main.rs b/src/main.rsindex fb8d259d6..5061ff6f7 100644--- a/src/main.rs+++ b/src/main.rs@@ -15,7 +15,7 @@ use worktrunk::styling::{};use commands::command_approval::approve_hooks;-use commands::context::CommandEnv;+use commands::command_executor::CommandContext;use commands::list::progressive::RenderMode;use commands::worktree::RemoveResult;@@ -737,11 +737,23 @@ fn handle_remove_command(spec: RemoveCommandArgs) -> anyhow::Result<()> {let repo = Repository::current().context("Failed to remove worktree")?;+ // Resolve current worktree context for hook approval+ let current_wt = repo.current_worktree();+ let approve_worktree_path = current_wt.root()?;+ let approve_branch = current_wt+ .branch()+ .context("Failed to determine current branch")?;+// Helper: approve remove hooks using current worktree context// Returns true if hooks should run (user approved)let approve_remove = |yes: bool| -> anyhow::Result<bool> {- let env = CommandEnv::for_action_branchless()?;- let ctx = env.context(yes);+ let ctx = CommandContext::new(+ &repo,+ &config,+ approve_branch.as_deref(),+ &approve_worktree_path,+ yes,+ );let approved = approve_hooks(&ctx,&[