Repository navigation
Expand file tree
/
Copy pathpush.bat
More file actions
111 lines (99 loc) · 2.8 KB
/
Copy pathpush.bat
File metadata and controls
111 lines (99 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
@echo off
chcp 65001 >nul 2>&1
setlocal enabledelayedexpansion
echo.
echo ============================================
echo Lazyscript - GitHub Push
echo ============================================
echo.
:: --- Step 0: Navigate to script's own directory ---
cd /d "%~dp0"
echo [dir] %cd%
echo.
:: --- Step 1: Check git is available ---
where git >nul 2>&1
if errorlevel 1 (
echo [ERROR] git not found in PATH.
echo Install Git: https://git-scm.com/download/win
echo.
pause
exit /b 1
)
:: --- Step 2: Check we are inside a git repo ---
git rev-parse --is-inside-work-tree >nul 2>&1
if errorlevel 1 (
echo [ERROR] Not a git repository.
echo Run this script from inside the lazyscript folder.
echo.
pause
exit /b 1
)
:: --- Step 2b: Install commit-message cleanup hook ---
if not exist "hooks\prepare-commit-msg" goto after_hook
if not exist ".git\hooks" mkdir ".git\hooks" >nul 2>&1
copy /Y "hooks\prepare-commit-msg" ".git\hooks\prepare-commit-msg" >nul
:after_hook
:: --- Step 3: Stage everything (respects .gitignore) ---
echo [1/4] Staging files...
git add -A
echo Done.
echo.
:: --- Step 4: Check if there is anything to commit ---
git diff --cached --quiet
if not errorlevel 1 (
echo [info] Nothing to commit - already up to date.
echo.
echo ============================================
echo All good, nothing to push.
echo ============================================
echo.
pause
exit /b 0
)
:: --- Step 5: Build commit message with timestamp ---
for /f "tokens=1-3 delims=/ " %%a in ('date /t') do set TODAY=%%a-%%b-%%c
for /f "tokens=1-2 delims=: " %%a in ('time /t') do set NOW=%%a%%b
set MSG=Update lazyscript [%TODAY% %NOW%]
echo [2/4] Committing...
echo msg: !MSG!
git commit -m "!MSG!"
if errorlevel 1 (
echo [ERROR] Commit failed.
echo.
pause
exit /b 1
)
:: Reject leftover third-party trailers
git log -1 --format=%%B | findstr /I /C:"Co-authored-by: Cursor" /C:"Co-authored-by: Claude" /C:"Made-with: Cursor" /C:"Made-with: Claude" /C:"Co-authored-by: OpenAI" /C:"Co-authored-by: ChatGPT" >nul 2>&1
if not errorlevel 1 (
echo [ERROR] Commit still has third-party co-author trailers. Aborting push.
pause
exit /b 1
)
echo Done.
echo.
:: --- Step 6: Push ---
echo [3/4] Pushing to origin...
git push origin
if errorlevel 1 (
echo.
echo [ERROR] Push failed.
echo Possible causes:
echo - No internet connection
echo - Not authenticated (run: git credential-manager)
echo - Remote rejected (check branch name)
echo.
pause
exit /b 1
)
:: --- Step 7: Done ---
echo.
echo [4/4] Verifying...
git log --oneline -1
echo.
echo ============================================
echo Push successful!
echo ============================================
echo.
pause
exit /b 0