-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgithub_update.bat
More file actions
83 lines (72 loc) · 1.88 KB
/
github_update.bat
File metadata and controls
83 lines (72 loc) · 1.88 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
@echo off
setlocal enabledelayedexpansion
::
:: Configurable variables
::
set "INITIAL_COMMIT_MSG=Initial"
::
:: Cool Output Messages
::
echo ==============================
echo Github Repository Update
echo ==============================
::
:: Confirm before proceeding
::
set /p "confirm=Are you sure you want to proceed? (y/n): "
if /i not "!confirm!"=="y" (
echo ==============================
echo Operation cancelled.
echo ==============================
pause
exit /b 1
)
::
:: Find the last version file in _changelogs/ folder and use its name (without extension) as default commit msg
::
set "defaultCommitMsg="
for /f "delims=" %%I in ('dir /a-d /b /o-d /tw "_changelogs" 2^>nul ^| findstr /r "^[0-9]*\."') do (
set "defaultCommitMsg=%%~nI"
goto :foundDefault
)
:foundDefault
::
:: Ask for commit message for this update (cannot be empty), default to changelog filename or initial
::
set "commitMsg=%defaultCommitMsg%"
if "!commitMsg!"=="" set "commitMsg=%INITIAL_COMMIT_MSG%"
echo Default commit message: "!commitMsg!"
set /p "commitMsg=Enter your commit message [!commitMsg!]: "
if "!commitMsg!"=="" set "commitMsg=%INITIAL_COMMIT_MSG%"
::
:: Cool message before starting the Git commands
::
echo ==============================
echo Staging all files...
echo ==============================
::
:: Stage all files except batch script itself (optional: modify if you want to exclude)
::
git add .
::
:: Commit with user input message
::
echo ==============================
echo Committing with message: "!commitMsg!"
echo ==============================
git commit -m "!commitMsg!"
::
:: Push to specified branch
::
echo ==============================
echo Pushing to branch: main
echo ==============================
git push -u origin main
::
:: Completion message
::
echo ==============================
echo Operation Complete
echo ==============================
pause
endlocal