#!/usr/bin/env bash
set -euo pipefail
# Run from the checkout being tested after starting its isolated server.
state_dir="$1"
workspace="$state_dir/workspace"
mkdir -p "$workspace"
git -C "$workspace" init --quiet --initial-branch=main
printf '%s\n' '# Synthetic review workspace' > "$workspace/README.md"
git -C "$workspace" add README.md
git -C "$workspace" -c user.name=Scenario -c user.email=scenario@example.invalid commit --quiet -m 'Synthetic workspace'
git -C "$workspace" remote add origin https://github.com/scenario/review-workspace.git
node apps/server/src/bin.ts project add "$workspace" --title 'Review workspace' --base-dir "$state_dir"
