From 095f1337d6502081658973ae3487dee8c6b34e1a Mon Sep 17 00:00:00 2001 From: Can Celik Date: Fri, 28 Aug 2026 18:25:07 +0300 Subject: fix: trust worktree repositories per request (#3344) refs #3044 --- src/cli/worktree.rs | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'src/cli/worktree.rs') diff --git a/src/cli/worktree.rs b/src/cli/worktree.rs index 4a36876a..4003eb6a 100644 --- a/src/cli/worktree.rs +++ b/src/cli/worktree.rs @@ -28,6 +28,7 @@ pub(super) fn run_worktree_command(args: &[String]) -> std::io::Result { fn worktree_list(args: &[String]) -> std::io::Result { let mut workspace_id = None; let mut cwd = None; + let mut trust_repository = false; let mut index = 0; while index < args.len() { @@ -48,6 +49,10 @@ fn worktree_list(args: &[String]) -> std::io::Result { cwd = Some(normalize_path_arg(value)?); index += 2; } + "--trust-repository" => { + trust_repository = true; + index += 1; + } "--json" => index += 1, other => { eprintln!("unknown option: {other}"); @@ -56,11 +61,15 @@ fn worktree_list(args: &[String]) -> std::io::Result { } } if workspace_id.is_some() && cwd.is_some() { - eprintln!("usage: herdr worktree list [--workspace ID | --cwd PATH]"); + eprintln!("usage: herdr worktree list [--workspace ID | --cwd PATH] [--trust-repository]"); return Ok(2); } - super::runtime::worktree_list(WorktreeListParams { workspace_id, cwd }) + super::runtime::worktree_list(WorktreeListParams { + workspace_id, + cwd, + trust_repository, + }) } fn worktree_create(args: &[String]) -> std::io::Result { @@ -71,6 +80,7 @@ fn worktree_create(args: &[String]) -> std::io::Result { let mut path = None; let mut label = None; let mut focus = false; + let mut trust_repository = false; let mut index = 0; while index < args.len() { @@ -131,6 +141,10 @@ fn worktree_create(args: &[String]) -> std::io::Result { focus = false; index += 1; } + "--trust-repository" => { + trust_repository = true; + index += 1; + } "--json" => index += 1, other => { eprintln!("unknown option: {other}"); @@ -140,7 +154,7 @@ fn worktree_create(args: &[String]) -> std::io::Result { } if workspace_id.is_some() && cwd.is_some() { eprintln!( - "usage: herdr worktree create [--workspace ID | --cwd PATH] [--branch NAME] [--base REF] [--path PATH] [--label TEXT] [--focus] [--no-focus]" + "usage: herdr worktree create [--workspace ID | --cwd PATH] [--branch NAME] [--base REF] [--path PATH] [--label TEXT] [--focus] [--no-focus] [--trust-repository]" ); return Ok(2); } @@ -153,6 +167,7 @@ fn worktree_create(args: &[String]) -> std::io::Result { path, label, focus, + trust_repository, }) } @@ -163,6 +178,7 @@ fn worktree_open(args: &[String]) -> std::io::Result { let mut branch = None; let mut label = None; let mut focus = false; + let mut trust_repository = false; let mut index = 0; while index < args.len() { @@ -215,6 +231,10 @@ fn worktree_open(args: &[String]) -> std::io::Result { focus = false; index += 1; } + "--trust-repository" => { + trust_repository = true; + index += 1; + } "--json" => index += 1, other => { eprintln!("unknown option: {other}"); @@ -224,13 +244,13 @@ fn worktree_open(args: &[String]) -> std::io::Result { } if workspace_id.is_some() && cwd.is_some() { eprintln!( - "usage: herdr worktree open [--workspace ID | --cwd PATH] (--path PATH | --branch NAME) [--label TEXT] [--focus] [--no-focus]" + "usage: herdr worktree open [--workspace ID | --cwd PATH] (--path PATH | --branch NAME) [--label TEXT] [--focus] [--no-focus] [--trust-repository]" ); return Ok(2); } if path.is_some() == branch.is_some() { eprintln!( - "usage: herdr worktree open [--workspace ID | --cwd PATH] (--path PATH | --branch NAME) [--label TEXT] [--focus] [--no-focus]" + "usage: herdr worktree open [--workspace ID | --cwd PATH] (--path PATH | --branch NAME) [--label TEXT] [--focus] [--no-focus] [--trust-repository]" ); return Ok(2); } @@ -242,12 +262,14 @@ fn worktree_open(args: &[String]) -> std::io::Result { branch, label, focus, + trust_repository, }) } fn worktree_remove(args: &[String]) -> std::io::Result { let mut workspace_id = None; let mut force = false; + let mut trust_repository = false; let mut index = 0; while index < args.len() { @@ -264,6 +286,10 @@ fn worktree_remove(args: &[String]) -> std::io::Result { force = true; index += 1; } + "--trust-repository" => { + trust_repository = true; + index += 1; + } "--json" => index += 1, other => { eprintln!("unknown option: {other}"); @@ -273,26 +299,27 @@ fn worktree_remove(args: &[String]) -> std::io::Result { } let Some(workspace_id) = workspace_id else { - eprintln!("usage: herdr worktree remove --workspace ID [--force]"); + eprintln!("usage: herdr worktree remove --workspace ID [--force] [--trust-repository]"); return Ok(2); }; super::runtime::worktree_remove(WorktreeRemoveParams { workspace_id, force, + trust_repository, }) } fn print_worktree_help() { eprintln!("herdr worktree commands:"); - eprintln!(" herdr worktree list [--workspace ID | --cwd PATH]"); + eprintln!(" herdr worktree list [--workspace ID | --cwd PATH] [--trust-repository]"); eprintln!( - " herdr worktree create [--workspace ID | --cwd PATH] [--branch NAME] [--base REF] [--path PATH] [--label TEXT] [--focus] [--no-focus]" + " herdr worktree create [--workspace ID | --cwd PATH] [--branch NAME] [--base REF] [--path PATH] [--label TEXT] [--focus] [--no-focus] [--trust-repository]" ); eprintln!( - " herdr worktree open [--workspace ID | --cwd PATH] (--path PATH | --branch NAME) [--label TEXT] [--focus] [--no-focus]" + " herdr worktree open [--workspace ID | --cwd PATH] (--path PATH | --branch NAME) [--label TEXT] [--focus] [--no-focus] [--trust-repository]" ); - eprintln!(" herdr worktree remove --workspace ID [--force]"); + eprintln!(" herdr worktree remove --workspace ID [--force] [--trust-repository]"); } fn normalize_path_arg(value: &str) -> std::io::Result { -- cgit v1.2.3