aboutsummaryrefslogtreecommitdiff
path: root/src/cli
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-08-28 18:25:07 +0300
committerGitHub <noreply@github.com>2026-08-28 18:25:07 +0300
commit095f1337d6502081658973ae3487dee8c6b34e1a (patch)
tree4174cac82dd51dabcc1fcef57b45df2462ef1918 /src/cli
parent13a9f6402fb77a31499bf758b56ca42b79936706 (diff)
fix: trust worktree repositories per request (#3344)
refs #3044
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/spec.rs12
-rw-r--r--src/cli/worktree.rs47
2 files changed, 45 insertions, 14 deletions
diff --git a/src/cli/spec.rs b/src/cli/spec.rs
index 134bf0bf..ed3c74a8 100644
--- a/src/cli/spec.rs
+++ b/src/cli/spec.rs
@@ -239,7 +239,8 @@ fn worktree_command() -> Command {
Command::new("list")
.about("List worktree workspaces")
.arg(option("workspace", "ID"))
- .arg(path_option("cwd", "PATH")),
+ .arg(path_option("cwd", "PATH"))
+ .arg(flag("trust-repository")),
)
.subcommand(
Command::new("create")
@@ -251,7 +252,8 @@ fn worktree_command() -> Command {
.arg(path_option("path", "PATH"))
.arg(option("label", "TEXT"))
.arg(flag("focus"))
- .arg(flag("no-focus")),
+ .arg(flag("no-focus"))
+ .arg(flag("trust-repository")),
)
.subcommand(
Command::new("open")
@@ -262,13 +264,15 @@ fn worktree_command() -> Command {
.arg(option("branch", "NAME"))
.arg(option("label", "TEXT"))
.arg(flag("focus"))
- .arg(flag("no-focus")),
+ .arg(flag("no-focus"))
+ .arg(flag("trust-repository")),
)
.subcommand(
Command::new("remove")
.about("Remove a worktree checkout")
.arg(option("workspace", "ID"))
- .arg(flag("force")),
+ .arg(flag("force"))
+ .arg(flag("trust-repository")),
)
}
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<i32> {
fn worktree_list(args: &[String]) -> std::io::Result<i32> {
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<i32> {
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<i32> {
}
}
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<i32> {
@@ -71,6 +80,7 @@ fn worktree_create(args: &[String]) -> std::io::Result<i32> {
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<i32> {
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<i32> {
}
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<i32> {
path,
label,
focus,
+ trust_repository,
})
}
@@ -163,6 +178,7 @@ fn worktree_open(args: &[String]) -> std::io::Result<i32> {
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<i32> {
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<i32> {
}
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<i32> {
branch,
label,
focus,
+ trust_repository,
})
}
fn worktree_remove(args: &[String]) -> std::io::Result<i32> {
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<i32> {
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<i32> {
}
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<String> {