@echo off
setlocal EnableExtensions
title Sync Windows scripts from git

set "REPO=C:\work\ai-horse-race.maspis.com.gitclone"

echo ========================================
echo  Sync scripts\windows from GitHub
echo ========================================
echo.

if not exist "%REPO%\.git" (
  echo [STEP 1] Clone repo (first time only)...
  if not exist "C:\work" mkdir "C:\work"
  cd /d C:\work
  git clone https://github.com/NaoyaOshima708/ai-horse-race.maspis.com.git ai-horse-race.maspis.com.gitclone
  if errorlevel 1 (
    echo [ERROR] git clone failed. Check network and URL.
    pause
    exit /b 1
  )
)

echo [STEP 2] git pull origin main...
cd /d "%REPO%"
git fetch origin
git pull origin main
if errorlevel 1 (
  echo [ERROR] git pull failed.
  pause
  exit /b 1
)

echo.
echo [STEP 3] scripts\windows contents:
dir /b "%REPO%\scripts\windows\*.bat" 2>nul
dir /b "%REPO%\scripts\windows\*.py" 2>nul
echo.
echo OK. Example: double-click check_o1_datakubun.bat
pause
exit /b 0
