-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub_update.bat
More file actions
61 lines (50 loc) · 1.79 KB
/
github_update.bat
File metadata and controls
61 lines (50 loc) · 1.79 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
@echo off
setlocal enabledelayedexpansion
:: Configurable variables
set "INITIAL_COMMIT_MSG=Initial"
:: Cool Output Messages
echo ==============================
echo Welcome to the Git Update Script!
echo ==============================
:: Confirm before proceeding
set /p "confirm=Are you sure you want to proceed? (y/n): "
if /i not "!confirm!"=="y" (
echo Operation cancelled.
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 All done! Your changes have been pushed to the repository.
echo ==============================
pause
endlocal