From 3a7f5cdb6cf751ec3fe9b1e339b447bc6a9130d6 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Tue, 10 Mar 2026 08:20:24 -0400 Subject: [PATCH] Fix unused_assignments warning in run_from_branch Return worktree_path from the match expression instead of mutating a pre-initialized variable. Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/crates/arc-workflows/src/cli/run.rs | 83 ++++++++++++------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/lib/crates/arc-workflows/src/cli/run.rs b/lib/crates/arc-workflows/src/cli/run.rs index 6b731ff92..51378d676 100644 --- a/lib/crates/arc-workflows/src/cli/run.rs +++ b/lib/crates/arc-workflows/src/cli/run.rs @@ -1422,48 +1422,47 @@ async fn run_from_branch( }; let emitter = Arc::new(EventEmitter::new()); - let mut worktree_path: Option = None; - - let sandbox: Arc = match sandbox_provider { - SandboxProvider::Local | SandboxProvider::Docker => { - // Re-attach worktree to the existing run branch - let wt = logs_dir.join("worktree"); - crate::git::replace_worktree(&original_cwd, &wt, run_branch) - .map_err(|e| anyhow::anyhow!("failed to attach worktree to {run_branch}: {e}"))?; - std::env::set_current_dir(&wt)?; - let mut env = arc_agent::LocalSandbox::new(wt.clone()); - let emitter_cb = Arc::clone(&emitter); - env.set_event_callback(Arc::new(move |event| { - emitter_cb.emit(&crate::event::WorkflowRunEvent::Sandbox { event }); - })); - worktree_path = Some(wt); - Arc::new(env) - } - #[cfg(feature = "exedev")] - SandboxProvider::Exe => { - let exe_config = resolve_exe_config(None, &run_defaults); - let clone_params = resolve_exe_clone_params(&original_cwd); - let mgmt_ssh = arc_exe::OpensshRunner::connect_raw("exe.dev") - .await - .map_err(|e| anyhow::anyhow!("Failed to connect to exe.dev: {e}"))?; - let config = exe_config.unwrap_or_default(); - let mut env = arc_exe::ExeSandbox::new( - Box::new(mgmt_ssh), - config, - clone_params, - Some(run_id.clone()), - github_app.clone(), - ); - let emitter_cb = Arc::clone(&emitter); - env.set_event_callback(Arc::new(move |event| { - emitter_cb.emit(&crate::event::WorkflowRunEvent::Sandbox { event }); - })); - Arc::new(env) - } - SandboxProvider::Daytona => { - bail!("--run-branch resume is not yet supported with --sandbox daytona"); - } - }; + let (sandbox, worktree_path): (Arc, Option) = + match sandbox_provider { + SandboxProvider::Local | SandboxProvider::Docker => { + // Re-attach worktree to the existing run branch + let wt = logs_dir.join("worktree"); + crate::git::replace_worktree(&original_cwd, &wt, run_branch).map_err(|e| { + anyhow::anyhow!("failed to attach worktree to {run_branch}: {e}") + })?; + std::env::set_current_dir(&wt)?; + let mut env = arc_agent::LocalSandbox::new(wt.clone()); + let emitter_cb = Arc::clone(&emitter); + env.set_event_callback(Arc::new(move |event| { + emitter_cb.emit(&crate::event::WorkflowRunEvent::Sandbox { event }); + })); + (Arc::new(env), Some(wt)) + } + #[cfg(feature = "exedev")] + SandboxProvider::Exe => { + let exe_config = resolve_exe_config(None, &run_defaults); + let clone_params = resolve_exe_clone_params(&original_cwd); + let mgmt_ssh = arc_exe::OpensshRunner::connect_raw("exe.dev") + .await + .map_err(|e| anyhow::anyhow!("Failed to connect to exe.dev: {e}"))?; + let config = exe_config.unwrap_or_default(); + let mut env = arc_exe::ExeSandbox::new( + Box::new(mgmt_ssh), + config, + clone_params, + Some(run_id.clone()), + github_app.clone(), + ); + let emitter_cb = Arc::clone(&emitter); + env.set_event_callback(Arc::new(move |event| { + emitter_cb.emit(&crate::event::WorkflowRunEvent::Sandbox { event }); + })); + (Arc::new(env), None) + } + SandboxProvider::Daytona => { + bail!("--run-branch resume is not yet supported with --sandbox daytona"); + } + }; // Initialize remote sandboxes and checkout the run branch if sandbox.is_remote() {