-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-upload.bat
More file actions
84 lines (70 loc) · 1.89 KB
/
github-upload.bat
File metadata and controls
84 lines (70 loc) · 1.89 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
@echo off
setlocal EnableDelayedExpansion
cd /d "%~dp0"
for %%I in ("%cd%") do set "REPO_PATH=%%~fI"
set "REMOTE_URL=https://github.com/fullydigital-design/cvbuilder.git"
set "DEFAULT_NAME=fullydigital-design"
set "DEFAULT_EMAIL=fullydigital-design@users.noreply.github.com"
where git >nul 2>nul
if errorlevel 1 (
echo [ERROR] Git is not installed or not on PATH.
pause
exit /b 1
)
git config --global --add safe.directory "%REPO_PATH%" >nul 2>nul
git rev-parse --is-inside-work-tree >nul 2>nul
if errorlevel 1 (
echo [INFO] Initializing Git repository...
git init || goto :fail
)
git config --get user.name >nul 2>nul
if errorlevel 1 (
echo [INFO] Setting local git user.name to "%DEFAULT_NAME%".
git config user.name "%DEFAULT_NAME%" || goto :fail
)
git config --get user.email >nul 2>nul
if errorlevel 1 (
echo [INFO] Setting local git user.email to "%DEFAULT_EMAIL%".
git config user.email "%DEFAULT_EMAIL%" || goto :fail
)
git branch -M main || goto :fail
git remote get-url origin >nul 2>nul
if errorlevel 1 (
echo [INFO] Adding origin remote...
git remote add origin "%REMOTE_URL%" || goto :fail
) else (
echo [INFO] Updating origin remote...
git remote set-url origin "%REMOTE_URL%" || goto :fail
)
echo [INFO] Staging all changes...
git add -A || goto :fail
git diff --cached --quiet
if errorlevel 1 (
set "COMMIT_MSG=chore: sync project to GitHub"
if not "%~1"=="" (
set "COMMIT_MSG="
for %%A in (%*) do (
if defined COMMIT_MSG (
set "COMMIT_MSG=!COMMIT_MSG! %%~A"
) else (
set "COMMIT_MSG=%%~A"
)
)
)
echo [INFO] Creating commit: !COMMIT_MSG!
git commit -m "!COMMIT_MSG!" || goto :fail
) else (
echo [INFO] No staged changes to commit.
)
echo [INFO] Pushing to origin/main...
git push -u origin main || goto :fail
echo.
echo [OK] Upload complete.
endlocal
exit /b 0
:fail
echo.
echo [ERROR] Upload failed.
pause
endlocal
exit /b 1