#!/usr/bin/env bash

remote="ssh://git@gitea.apps.sustainabledelivery.com:3022/QWAN/agentic_vendingmachine_cpp.git"

peer_repo="${1:-agentic_vendingmachine_cpp_practice}"
base_dir=$(dirname $(dirname $(realpath $0)))

usage() {
  [[ "$1" == "" ]] || printf "%s\n\n" "$1" >&2
  echo "Usage: $0 <peer repo>
  where peer repo is a repo in a peer directory to this one " >&2
  exit 1
}

[[ "${peer_repo}" == "" ]] && usage "peer repo missing"

exercise_location="$base_dir/$peer_repo"
git clone "${remote}"  "${exercise_location}" || exit 2

cd "$exercise_location"
rm -rf .git transcripts
git init  >&2
git add .
git commit -am "initial commit" >&2

echo "${exercise_location}"
