Skip to main content

git_clone_with_retry

Function git_clone_with_retry 

Source
pub(super) fn git_clone_with_retry(
    url: &str,
    branch: Option<&str>,
    dest: &Path,
) -> Result<()>
Expand description

Build every package referenced by a top-level robonix_manifest.yaml. Two phases:

  1. fetchpath: entries already on disk; url: entries get git clone --depth 1 into rbnx-boot/cache/<name>/ (idempotent — skipped when the cache dir already exists).
  2. build — for each resolved package, run its build.sh.

rbnx boot deliberately does NOT do either; it just verifies both phases happened (warns + remediates if not). This lets “fetch → build” be a controlled offline step the user can run when they have network / time, then rbnx boot is a fast, online-optional bring-up. git clone --depth 1 with bounded retries.

Clones the repo into dest, retrying transient failures. Between attempts it removes any partial checkout git left behind, because git refuses to clone into a non-empty directory and a half-written tree would otherwise turn one flaky network moment into a permanent failure.

Retries exist because a deployment build clones several remotes over several minutes, and any one of them dying takes the whole build with it. On a runner whose only route to GitHub is a proxy that drops for stretches at a time, a single GnuTLS, handshake failed mid-build was enough to fail a run whose next attempt seconds later would have succeeded.

The last attempt’s exit status is what the error reports. Returns Err only after every attempt has failed, or if git could not be spawned at all — a missing git binary is not transient, so that is not retried.