Clone a local repository without hardlinks This creates an optimized copy of the source repository at the destination path. The clone operation repacks objects efficiently, typically resulting in 1-2 pack files instead of preserving fragmented pack structure. # Arguments `source_repo_path` - Path to the source repository to clone `destination_path` - Path where the cloned repository will be cre
(source_repo_path: &Path, destination_path: &Path)
| 495 | /// - The destination path cannot be created |
| 496 | /// - The clone operation fails |
| 497 | pub async fn clone_local(source_repo_path: &Path, destination_path: &Path) -> Result<(), String> { |
| 498 | tokio::task::spawn_blocking({ |
| 499 | let source_repo_path = source_repo_path.to_owned(); |
| 500 | let destination_path = destination_path.to_owned(); |
| 501 | move || -> Result<(), String> { |
| 502 | let mut builder = git2::build::RepoBuilder::new(); |
| 503 | builder.clone_local(git2::build::CloneLocal::NoLinks); |
| 504 | |
| 505 | builder |
| 506 | .clone( |
| 507 | source_repo_path.to_str().ok_or("Invalid source path")?, |
| 508 | &destination_path, |
| 509 | ) |
| 510 | .map_err(|e| format!("Failed to clone repository: {e}"))?; |
| 511 | |
| 512 | Ok(()) |
| 513 | } |
| 514 | }) |
| 515 | .await |
| 516 | .map_err(|e| format!("Task join error: {e}"))? |
| 517 | } |
| 518 | |
| 519 | /// Initializes and checks out all submodules recursively in a repository. |
| 520 | /// |
no outgoing calls