#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=lib.sh
source "${SCRIPT_DIR}/lib.sh"

VERL_DIR="${ROOT_DIR}/../../verl"

echo "[host] ensure verl repo exists at: ${VERL_DIR}"
if [[ -d "${VERL_DIR}/.git" ]]; then
  echo "verl_repo_exists: skip"
  exit 0
fi

if [[ -d "${VERL_DIR}" && ! -d "${VERL_DIR}/.git" ]]; then
  echo "ERROR: ${VERL_DIR} exists but is not a git repo; please fix manually." >&2
  exit 1
fi

echo "cloning volcengine/verl -> ${VERL_DIR}"
git clone https://github.com/volcengine/verl.git "${VERL_DIR}"
