diff --git a/push_to_gitea.bat b/push_to_gitea.bat index bb327b5..e98dba4 100644 --- a/push_to_gitea.bat +++ b/push_to_gitea.bat @@ -1,32 +1,23 @@ @echo off -chcp 65001 > nul cd /d "%~dp0" echo. echo ========================================= echo DBX CORM - Gitea Push -echo https://gitea.no1king.freeddns.org/king/dbx-corm echo ========================================= echo. -REM 민감 파일 추적 확인 -echo [1/5] Checking for sensitive files... +echo [1/4] Checking for sensitive files... + set FOUND=0 -for %%F in ( - .env - cafe24_tokens.json - manual-ordering.json -) do ( - git ls-files --error-unmatch "%%F" >nul 2>&1 - if not errorlevel 1 ( - echo [ERROR] Sensitive file is tracked by git: %%F - set FOUND=1 - ) -) +call :check_file .env +call :check_file cafe24_tokens.json +call :check_file manual-ordering.json + if %FOUND%==1 ( echo. echo PUSH BLOCKED. Remove with: - echo git rm --cached ^ + echo git rm --cached FILENAME echo git commit -m "remove sensitive file" echo. pause @@ -35,57 +26,38 @@ if %FOUND%==1 ( echo OK. echo. -REM Git 상태 -echo [2/5] Git status: +echo [2/4] Git status: echo ----------------------------------------- git status -s echo ----------------------------------------- echo. -REM 변경사항 없으면 종료 -git diff --quiet -set DIFF1=%errorlevel% -git diff --cached --quiet -set DIFF2=%errorlevel% -git ls-files --others --exclude-standard | findstr /r "." >nul -set DIFF3=%errorlevel% - -if "%DIFF1%"=="0" if "%DIFF2%"=="0" if not "%DIFF3%"=="0" ( - echo No changes to commit. Exiting. - pause - exit /b 0 -) - -REM 스테이징 -echo [3/5] Staging files... +echo [3/4] Staging all changes... git add -A echo OK. echo. -REM 커밋 메시지 입력 -echo [4/5] Enter commit message: +echo Enter commit message (or press Enter to skip commit and just push): +set "MSG=" set /p MSG=^>^> -if "%MSG%"=="" ( - echo [ERROR] Empty commit message. - pause - exit /b 1 -) - -git commit -m "%MSG%" -if errorlevel 1 ( - echo [ERROR] Commit failed. - pause - exit /b 1 +if not "%MSG%"=="" ( + git diff --cached --quiet + if errorlevel 1 ( + git commit -m "%MSG%" + if errorlevel 1 ( + echo [ERROR] Commit failed. + pause + exit /b 1 + ) + ) else ( + echo No staged changes. Skipping commit. + ) ) echo. -REM Push -echo [5/5] Pushing to Gitea... +echo [4/4] Pushing to Gitea... git push -u origin master -if errorlevel 1 ( - git push -u origin main -) if %errorlevel%==0 ( echo. @@ -99,3 +71,12 @@ if %errorlevel%==0 ( ) echo. pause +exit /b 0 + +:check_file +git ls-files --error-unmatch "%~1" >nul 2>&1 +if not errorlevel 1 ( + echo [ERROR] Sensitive file is tracked by git: %~1 + set FOUND=1 +) +exit /b 0