#!/usr/bin/env bash # Clone all sourcehut-related repos and check out the latest tag. set -u REPOS=( sr.ht-apkbuilds builds.sr.ht git.sr.ht sr.ht-docs sr.ht-nginx core-go meta.sr.ht todo.sr.ht core.sr.ht go-away-config gensokyo status.sr.ht hub.sr.ht lists.sr.ht man.sr.ht paste.sr.ht sourcehut-ssh pages.sr.ht git-send-email.io sourcehut.org sourcehut-migrate srht.site api.sr.ht sr.ht-pkgbuilds sourcehut-go forgeperf gql.sr.ht git-am.io git-rebase.io ) clone_one() { local name="$1" local url="https://git.sr.ht/~sircmpwn/$name" local log="/tmp/srht-clone-$name.log" if [ -d "$name/.git" ]; then echo "SKIP $name (already cloned)" return 0 fi if ! git clone --quiet "$url" "$name" >"$log" 2>&1; then echo "FAIL $name (clone)" return 1 fi local tag tag=$(git -C "$name" tag --sort=-v:refname 2>/dev/null | head -n1) if [ -z "$tag" ]; then local branch branch=$(git -C "$name" rev-parse --abbrev-ref HEAD) echo "NOTAG $name (on $branch)" return 0 fi if git -C "$name" -c advice.detachedHead=false checkout --quiet "$tag" 2>>"$log"; then echo "OK $name @ $tag" else echo "FAIL $name (checkout $tag)" fi } export -f clone_one printf '%s\n' "${REPOS[@]}" | xargs -n1 -P6 -I{} bash -c 'clone_one "{}"'