Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions desktop/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ user-idle = { version = "0.6", default-features = false }
atomic-write-file = "0.3"
anyhow = "1"
dirs = "6"
dunce = "1"
tauri = { version = "2", features = ["macos-private-api"] }
tauri-plugin-deep-link = "2"
tauri-plugin-opener = "2"
Expand Down
4 changes: 2 additions & 2 deletions desktop/src-tauri/src/commands/project_git_workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use super::project_git_exec::{
};
use super::project_repo_paths::{
canonical_repos_roots, canonicalize_repos_root, default_repos_root_candidates,
find_local_repo_dir, local_repo_candidates,
find_local_repo_dir, local_repo_candidates, strip_extended_path_prefix,
};
use crate::app_state::AppState;
use crate::managed_agents::{load_managed_agents, spawn_key_refusal};
Expand Down Expand Up @@ -425,7 +425,7 @@ pub(crate) fn clone_project_repository_blocking(
.into_iter()
.next()
.ok_or_else(|| "Could not derive a directory name for the repository.".to_string())?;
let repo_dir = repos_root.join(repo_name);
let repo_dir = strip_extended_path_prefix(&repos_root.join(repo_name));
if repo_dir.exists() {
return Err(format!(
"{} already exists but is not a git checkout.",
Expand Down
24 changes: 23 additions & 1 deletion desktop/src-tauri/src/commands/project_repo_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub(crate) fn find_local_repo_dir(
.map(|url| checkout_origin_matches(&candidate_path, &repos_root, url))
.unwrap_or(true)
{
return Ok(Some(candidate_path));
return Ok(Some(strip_extended_path_prefix(&candidate_path)));
}
}
}
Expand Down Expand Up @@ -170,6 +170,16 @@ pub(crate) fn canonicalize_repos_root(
Ok(repos_root)
}

/// Strip the Windows extended-length path prefix (`\\?\`) that
/// `PathBuf::canonicalize()` adds on Windows. Git for Windows rejects
/// `\\?\`-prefixed destinations, so canonical paths must be cleaned before
/// being passed to the git CLI.
pub(crate) fn strip_extended_path_prefix(
path: &std::path::Path,
) -> std::path::PathBuf {
dunce::simplified(path).to_path_buf()
}

pub(crate) fn canonical_repos_roots(
repos_dir: Option<&str>,
) -> Result<Vec<std::path::PathBuf>, String> {
Expand All @@ -190,3 +200,15 @@ pub(crate) fn canonical_repos_roots(
}
Ok(roots)
}

#[cfg(test)]
mod tests {
use super::strip_extended_path_prefix;
use std::path::PathBuf;

#[test]
fn strip_extended_path_prefix_leaves_normal_path_untouched() {
let path = PathBuf::from("/home/james/.buzz/REPOS/owner--repo");
assert_eq!(strip_extended_path_prefix(&path), path);
}
}