fix: grant claude worktree access to git metadata dirs
This commit is contained in:
parent
f0850b3fd3
commit
2618c2ce77
1 changed files with 47 additions and 1 deletions
|
|
@ -203,7 +203,7 @@ fn codex_additional_writable_dirs(working_dir: &str) -> Vec<String> {
|
|||
|
||||
fn build_agent_cli_args(agent: &Agent, working_dir: &str) -> Vec<String> {
|
||||
let mut args = agent.tool.to_non_interactive_args();
|
||||
if agent.tool == AgentTool::Codex {
|
||||
if matches!(agent.tool, AgentTool::Codex | AgentTool::ClaudeCode) {
|
||||
for dir in codex_additional_writable_dirs(working_dir) {
|
||||
args.push("--add-dir".to_string());
|
||||
args.push(dir);
|
||||
|
|
@ -1240,6 +1240,52 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_build_agent_cli_args_adds_git_metadata_dirs_for_claude_worktree() {
|
||||
let repo = setup_test_repo();
|
||||
let repo_path = repo.path().to_str().expect("utf8 path");
|
||||
let base_branch = current_branch(repo_path);
|
||||
let (worktree_path, _branch_name) =
|
||||
worktree_manager::create_worktree(repo_path, &base_branch, 203)
|
||||
.expect("worktree creation should succeed");
|
||||
|
||||
let agent = build_test_agent(crate::models::agent::AgentTool::ClaudeCode);
|
||||
let args = build_agent_cli_args(&agent, &worktree_path);
|
||||
let add_dirs = collect_add_dirs(&args);
|
||||
|
||||
let rev_parse = Command::new("git")
|
||||
.args(["rev-parse", "--git-dir", "--git-common-dir"])
|
||||
.current_dir(&worktree_path)
|
||||
.output()
|
||||
.expect("git rev-parse should succeed");
|
||||
assert!(rev_parse.status.success(), "git rev-parse should succeed");
|
||||
|
||||
let expected_dirs: Vec<String> = String::from_utf8_lossy(&rev_parse.stdout)
|
||||
.lines()
|
||||
.map(|line| {
|
||||
let path = Path::new(line);
|
||||
let absolute = if path.is_absolute() {
|
||||
path.to_path_buf()
|
||||
} else {
|
||||
Path::new(&worktree_path).join(path)
|
||||
};
|
||||
std::fs::canonicalize(&absolute)
|
||||
.unwrap_or(absolute)
|
||||
.to_string_lossy()
|
||||
.to_string()
|
||||
})
|
||||
.collect();
|
||||
|
||||
for expected in expected_dirs {
|
||||
assert!(
|
||||
add_dirs.contains(&expected),
|
||||
"Expected --add-dir to contain '{}', got {:?}",
|
||||
expected,
|
||||
add_dirs
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_validate_developer_completion_rejects_branch_without_commit() {
|
||||
let repo = setup_test_repo();
|
||||
|
|
|
|||
Loading…
Reference in a new issue