Combine refspecs to one call to git-fetch
@@ -352,13 +352,17 @@ pub fn fetch_refs_from_url(
username: &str,
password: &str,
) -> Result<(), git2::Error> {
- for refs_prefix in refs_prefixes {
- let spec = format!(
- "+{}:refs/namespaces/{}/{}",
- &refs_prefix,
+ let specs: Vec<_> = refs_prefixes
+ .iter()
+ .map(|r| {
+ format!(
+ "'+{}:refs/namespaces/{}/{}'",
+ &r,
josh::to_ns(upstream_repo),
- &refs_prefix
- );
+ &r
+ )
+ })
+ .collect();
let shell = josh::shell::Shell {
cwd: path.to_owned(),
@@ -370,7 +374,7 @@ pub fn fetch_refs_from_url(
format!("{}://{}@{}", &proto, &username, &rest)
};
- let cmd = format!("git fetch --no-tags {} '{}'", &nurl, &spec);
+ let cmd = format!("git fetch --no-tags {} {}", &nurl, &specs.join(" "));
tracing::info!("fetch_refs_from_url {:?} {:?} {:?}", cmd, path, "");
let (_stdout, stderr) =
@@ -390,7 +394,6 @@ pub fn fetch_refs_from_url(
if stderr.contains("error:") {
return Err(git2::Error::from_str("error"));
}
- }
return Ok(());
}
