#!/bin/bash
# Creates 180 local checkouts whose origin is a public gitlab.com gitlab-org project and adds them to a
# running dev server's T3 home. Usage: setup-checkouts.sh <paths.txt> <dir> <worktree>
set -e; paths=$1; dir=$2; wt=$3; i=0
while read p; do i=$((i+1)); d=$dir/p$(printf %03d $i); mkdir -p $d; git -C $d init -q -b main
  git -C $d remote add origin "https://gitlab.com/$p.git"
  (cd $wt/apps/server && node src/bin.ts project add --base-dir $wt/.t3 $d >/dev/null); done < "$paths"
