| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- @echo off
- REM ================================================================
- REM autogit - one-click commit and push (double-click to run)
- REM
- REM KEEP THIS FILE PURE ASCII. No Chinese, no accents, nothing.
- REM cmd.exe parses .bat using the OEM code page. A UTF-8 file with
- REM non-ASCII bytes gets read as mojibake, and a mangled comment line
- REM can end up being executed as a command.
- REM Every Chinese message is printed by autogit.py instead.
- REM ================================================================
- chcp 65001 >nul 2>nul
- setlocal
- cd /d "%~dp0"
- REM Tell python that this .bat owns the final "press any key" pause,
- REM so python does not ask for a key twice.
- set "AUTOGIT_WRAPPED=1"
- set "PY="
- REM ---- 1) prefer the py launcher, Microsoft's multi-version entry ----
- py -3 -c "import sys;sys.exit(0 if sys.version_info>=(3,8) else 1)" >nul 2>nul
- if not errorlevel 1 set "PY=py -3"
- REM ---- 2) fall back to python on PATH ----
- REM WindowsApps\python.exe is the Microsoft Store stub. It exists on
- REM disk but fails unless Python came from the Store, so we must really
- REM run it once instead of just checking that the file is present.
- if not defined PY (
- python -c "import sys;sys.exit(0 if sys.version_info>=(3,8) else 1)" >nul 2>nul
- if not errorlevel 1 set "PY=python"
- )
- if not defined PY (
- echo.
- echo [FAIL] Python 3.8 or newer was not found.
- echo.
- echo Install Python, or make sure "py" or "python" is on PATH.
- echo Then run this file again.
- echo.
- pause
- exit /b 9009
- )
- %PY% "%~dp0autogit.py" %*
- set "RC=%ERRORLEVEL%"
- if not "%RC%"=="0" echo [autogit] exit code %RC%
- echo.
- pause
- exit /b %RC%
|