123456789101112131415161718192021222324252627 | #!/bin/sh
# fetch.sh GIT_DIR REPOS_FILE: clone or update the bare repositories that
# `make preview` renders. Run from the top of the checkout.
set -eu
git_dir=$1
repos=$2
top=$(pwd)
mkdir -p "$git_dir"
grep -v '^[[:space:]]*\(#\|$\)' "$repos" | while read -r name url desc; do
case $url in
*://* | *@*:*) ;;
*) url=$(cd "$top/$url" && pwd) ;;
esac
dir=$git_dir/$name.git
if [ ! -d "$dir" ]; then
echo "clone $name <- $url"
git clone --quiet --bare "$url" "$dir"
git -C "$dir" config remote.origin.fetch '+refs/heads/*:refs/heads/*'
else
echo "fetch $name <- $url"
git -C "$dir" remote set-url origin "$url"
git -C "$dir" fetch --quiet --prune --tags origin
fi
if [ -n "$desc" ]; then
printf '%s\n' "$desc" >"$dir/description"
fi
done
|