Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/dwarves

ci/mirror.sh

#!/bin/sh
# ci-mirror, on dwarf (every 5 minutes): fetch each constellation branch from its forge
# with dwarf's existing read access, and push it to builder-64's local bare mirrors.
# builder-64 holds no forge credential and never talks to a forge. Serial, one fetch at
# a time (git.gunnar.rs caps concurrent transfers per user).
set -u
HERE=$(cd "$(dirname "$0")" && pwd)
LIST=${CI_REPOS:-$HERE/repos.txt}
M=${CI_MIRROR:-$HOME/d-ci2/mirror}
HOST=${CI_HOST:-builder-64}
mkdir -p "$M"
exec 9>"$M/.lock"; flock -n 9 || exit 0
grep -v '^#' "$LIST" | while read -r name url branch ci fmt; do
  [ -n "$name" ] || continue
  g="$M/$name.git"
  [ -d "$g" ] || git init -q --bare --object-format="${fmt:-sha1}" "$g"
  ok=0
  for i in 1 2 3; do
    if git -C "$g" fetch -q "$url" "+refs/heads/$branch:refs/heads/$branch" </dev/null; then ok=1; break; fi
    sleep 5
  done
  [ $ok = 1 ] || { echo "ci-mirror: $name: fetch failed" >&2; continue; }
  # The LFS objects of the branch travel beside it: builder-64 never fetches them.
  git -C "$g" lfs fetch "$url" "$branch" </dev/null >/dev/null 2>&1 || echo "ci-mirror: $name: lfs fetch failed" >&2
  ssh -n "$HOST" "test -d /work/ci/mirror/$name.git || git init -q --bare --object-format=${fmt:-sha1} /work/ci/mirror/$name.git"
  git -C "$g" push -q "$HOST:/work/ci/mirror/$name.git" "+refs/heads/$branch:refs/heads/$branch" </dev/null \
    || echo "ci-mirror: $name: push to $HOST failed" >&2
  [ -d "$g/lfs/objects" ] && rsync -a "$g/lfs/objects/" "$HOST:/work/ci/mirror/$name.git/lfs/objects/"
done