the runtime your coding agents live on
Rust agentagent-orchestrationaiai-agentsclaude-codeclicodexcoding-agentsdeveloper-toolsdevtoolsmultiplexerrustterminalterminal-multiplexerterminal-uitmuxtuiworkspace-manager
fix: derive repo name for embedded bare layouts (#2660)
akbashb8387818f022
diff --git a/src/workspace/git/discovery.rs b/src/workspace/git/discovery.rsindex 3e867443c..f4506073a 100644--- a/src/workspace/git/discovery.rs+++ b/src/workspace/git/discovery.rs@@ -75,15 +75,14 @@ pub(super) fn git_space_metadata_from_info(info: &GitWorktreeInfo) -> GitSpaceMelet checkout_key = canonicalize_best_effort_path(&info.repo_root).display().to_string();- let label_path = if info+ let common_dir_name = info.git_common_dir.file_name()- .and_then(|name| name.to_str())- == Some(".git")- {- info.git_common_dir.parent().unwrap_or(&info.repo_root)- } else {- &info.git_common_dir+ .and_then(|name| name.to_str());+ let label_path = match common_dir_name {+ Some(".git") => info.git_common_dir.parent().unwrap_or(&info.repo_root),+ Some(".bare") => embedded_bare_repo_container(info).unwrap_or(&info.git_common_dir),+ _ => &info.git_common_dir,};let repo_name = label_path.file_name()@@ -99,6 +98,12 @@ pub(super) fn git_space_metadata_from_info(info: &GitWorktreeInfo) -> GitSpaceMe}}+fn embedded_bare_repo_container(info: &GitWorktreeInfo) -> Option<&Path> {+ let parent = info.git_common_dir.parent()?;+ let parent_git_dir = git_dir_for_repo_root(parent)?;+ (canonicalize_best_effort_path(&parent_git_dir) == info.git_common_dir).then_some(parent)+}+pub(super) fn canonicalize_best_effort_path(path: &Path) -> PathBuf {std::fs::canonicalize(path).unwrap_or_else(|_| path.to_path_buf())}@@ -421,7 +426,8 @@ mod tests {let checkout_auto_label = automatic_workspace_label(&checkout, &checkout_space.repo_root);assert_eq!(bare_space.key, checkout_space.key);- assert_eq!(bare_space.repo_name, checkout_space.repo_name);+ assert_eq!(bare_space.repo_name, ".bare");+ assert_eq!(checkout_space.repo_name, bare_space.repo_name);assert_eq!(bare_auto_label, bare.file_name().unwrap().to_str().unwrap());assert_eq!(checkout_auto_label,@@ -431,6 +437,55 @@ mod tests {std::fs::remove_dir_all(base).unwrap();}+ #[test]+ fn embedded_dot_bare_source_and_checkout_use_container_repo_name() {+ let base = temp_test_dir("embedded-dot-bare");+ let seed = base.join("seed");+ let repo = base.join("reported-repo");+ let bare = repo.join(".bare");+ let checkout = repo.join("develop");+ std::fs::create_dir_all(&seed).unwrap();+ std::fs::create_dir_all(&repo).unwrap();+ run_git(&seed, &["init", "--quiet"]);+ run_git(&seed, &["config", "user.email", "[email protected]"]);+ run_git(&seed, &["config", "user.name", "Herdr Test"]);+ run_git(+ &seed,+ &["commit", "--quiet", "--allow-empty", "-m", "initial"],+ );+ run_git(+ &base,+ &[+ "clone",+ "--quiet",+ "--bare",+ seed.to_str().unwrap(),+ bare.to_str().unwrap(),+ ],+ );+ std::fs::write(repo.join(".git"), "gitdir: ./.bare\n").unwrap();+ run_git(+ &bare,+ &[+ "worktree",+ "add",+ "--quiet",+ "-b",+ "develop",+ checkout.to_str().unwrap(),+ "HEAD",+ ],+ );++ let source = git_space_metadata(&repo).unwrap();+ let linked = git_space_metadata(&checkout).unwrap();++ assert_eq!(source.repo_name, "reported-repo");+ assert_eq!(linked.repo_name, source.repo_name);++ std::fs::remove_dir_all(base).unwrap();+ }+#[test]fn git_space_metadata_marks_bare_dot_git_repo() {let root = temp_test_dir("bare-dot-git");diff --git a/src/workspace/git/test_support.rs b/src/workspace/git/test_support.rsindex 01996782d..4520b62ad 100644--- a/src/workspace/git/test_support.rs+++ b/src/workspace/git/test_support.rs@@ -50,7 +50,7 @@ pub(crate) fn create_repo_with_linked_worktree(name: &str) -> (PathBuf, PathBuf,pub(crate) fn create_bare_repo_with_linked_worktree(name: &str) -> (PathBuf, PathBuf, PathBuf) {let base = temp_test_dir(name);let seed = base.join("seed");- let bare = base.join("herdr.git");+ let bare = base.join(".bare");let checkout = base.join("feature");init_repo_with_commit(&seed);run_git(