Files
2026-08-01 17:25:00 +02:00

47 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Clone the TTG workspace repos into the category-folder structure,
# based on scripts/repos.list.
#
# Usage:
# ./clone-repos.sh [target-dir]
#
# Without a target dir it clones into the parent directory of the devarea
# checkout (the workspace root). Existing directories are skipped, so the
# script can be re-run safely.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT="${1:-$(cd "$SCRIPT_DIR/../.." && pwd)}"
LIST="$SCRIPT_DIR/repos.list"
cloned=0
skipped=0
failed=0
while IFS='|' read -r path url; do
# comments and empty lines
[[ -z "$path" || "$path" == \#* ]] && continue
target="$ROOT/$path"
if [ -e "$target/.git" ]; then
echo "skip $path (already exists)"
skipped=$((skipped + 1))
continue
fi
mkdir -p "$(dirname "$target")"
if git clone "$url" "$target"; then
cloned=$((cloned + 1))
else
echo "ERROR $path ($url)" >&2
failed=$((failed + 1))
fi
done < "$LIST"
echo
echo "Done: $cloned cloned, $skipped skipped, $failed failed."
[ "$failed" -eq 0 ]