fix(worktree): name siblings from primary checkout

This commit is contained in:
Felipe Coury
2026-05-07 20:47:52 -03:00
parent 1b31e12444
commit 1c604c0be6
2 changed files with 38 additions and 2 deletions
+30
View File
@@ -94,6 +94,36 @@ fn creates_reuses_lists_and_removes_managed_worktree() -> anyhow::Result<()> {
Ok(())
}
#[test]
fn creates_sibling_from_sibling_using_primary_repo_name() -> anyhow::Result<()> {
let fixture = GitFixture::new()?;
let first = codex_worktree::ensure_worktree(WorktreeRequest {
codex_home: fixture.codex_home.path().to_path_buf(),
source_cwd: fixture.repo.path().to_path_buf(),
branch: "fcoury/worktrees".to_string(),
base_ref: None,
dirty_policy: DirtyPolicy::Fail,
})?;
let second = codex_worktree::ensure_worktree(WorktreeRequest {
codex_home: fixture.codex_home.path().to_path_buf(),
source_cwd: first.info.workspace_cwd,
branch: "fcoury/test".to_string(),
base_ref: None,
dirty_policy: DirtyPolicy::Fail,
})?;
let canonical_repo = fixture.repo.path().canonicalize()?;
assert_eq!(
second.info.worktree_git_root,
canonical_repo.with_file_name(format!(
"{}.fcoury-test",
canonical_repo.file_name().unwrap().to_string_lossy()
))
);
Ok(())
}
#[test]
fn copy_tracked_preserves_staged_and_unstaged_diffs() -> anyhow::Result<()> {
let fixture = GitFixture::new()?;