Clone a git repository into a target directory.
(mut repo: String, target_dir: &Path)
| 228 | |
| 229 | /// Clone a git repository into a target directory. |
| 230 | fn clone_repo(mut repo: String, target_dir: &Path) -> Result<(), Error> { |
| 231 | // Check if this is one of the few packages that needs to be replaced. |
| 232 | for (to_replace, replace_with) in PACKAGE_REPO_RENAMES { |
| 233 | if repo == to_replace { |
| 234 | repo = replace_with.to_string(); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | // Arch linux replaces the literal `+` chars with spelled out `plus` equivalents in their |
| 239 | // repository urls. This is to prevent any issues with external tooling and such. |
| 240 | repo = repo.replace("+", "plus"); |
| 241 | |
| 242 | let ssh_url = format!("{SSH_HOST}:{REPO_BASE_URL}/{repo}.git"); |
| 243 | |
| 244 | let output = &Command::new("git") |
| 245 | .arg("clone") |
| 246 | .arg(&ssh_url) |
| 247 | .arg(target_dir) |
| 248 | .output() |
| 249 | .map_err(|source| Error::Io { |
| 250 | context: format!("cloning the package source repository \"{repo}\""), |
| 251 | source, |
| 252 | })?; |
| 253 | |
| 254 | ensure_success( |
| 255 | output, |
| 256 | format!("Cloning the package source repository \"{repo}\""), |
| 257 | ) |
| 258 | } |
no test coverage detected