(repo_path: &Path, remote_name: &str, url: &str)
| 161 | } |
| 162 | |
| 163 | pub async fn add_remote(repo_path: &Path, remote_name: &str, url: &str) -> Result<(), String> { |
| 164 | tokio::task::spawn_blocking({ |
| 165 | let repo_path = repo_path.to_owned(); |
| 166 | let remote_name = remote_name.to_owned(); |
| 167 | let url = url.to_owned(); |
| 168 | move || -> Result<(), String> { |
| 169 | let repo = Repository::open(&repo_path) |
| 170 | .map_err(|e| format!("Failed to open repository: {e}"))?; |
| 171 | |
| 172 | let result = repo.remote(&remote_name, &url); |
| 173 | match result { |
| 174 | Ok(_) => Ok(()), |
| 175 | Err(e) => { |
| 176 | if e.code() == git2::ErrorCode::Exists { |
| 177 | Ok(()) |
| 178 | } else { |
| 179 | Err(format!("Failed to add remote: {e}")) |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | }) |
| 185 | .await |
| 186 | .map_err(|e| format!("Task join error: {e}"))? |
| 187 | } |
| 188 | |
| 189 | pub async fn fetch_branch( |
| 190 | repo_path: &Path, |
no outgoing calls